PERFORCE change 147247 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Tue Aug 12 17:05:46 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=147247
Change 147247 by hselasky at hselasky_laptop001 on 2008/08/12 17:05:07
Improve compatibility with other operating systems.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#17 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#24 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#17 (text+ko) ====
@@ -41,6 +41,32 @@
#define USB_USE_CONDVAR 0
#endif
+#ifndef USB_TD_GET_RUID
+#define USB_TD_GET_RUID(td) (td)->td_ucred->cr_ruid
+#endif
+
+#ifndef USB_TD_GET_RGID
+#define USB_TD_GET_RGID(td) (td)->td_ucred->cr_rgid
+#endif
+
+#ifndef USB_TD_GET_PROC
+#define USB_TD_GET_PROC(td) (td)->td_proc
+#endif
+
+#ifndef USB_PROC_GET_GID
+#define USB_PROC_GET_GID(td) (td)->p_pgid
+#endif
+
+#ifndef USB_VNOPS_FO_STAT
+#define USB_VNOPS_FO_STAT(fp, sb, cred, td) \
+ vnops.fo_stat(fp, sb, cred, td)
+#endif
+
+#ifndef USB_VNOPS_FO_TRUNCATE
+#define USB_VNOPS_FO_TRUNCATE(fp, length, cred, td) \
+ vnops.fo_truncate(fp, length, cred, td)
+#endif
+
/* Include files */
#include <sys/stdint.h>
==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#24 (text+ko) ====
@@ -1115,8 +1115,8 @@
bzero(&perm, sizeof(perm));
/* create a permissions mask */
- perm.uid = td->td_ucred->cr_ruid;
- perm.gid = td->td_ucred->cr_rgid;
+ perm.uid = USB_TD_GET_RUID(td);
+ perm.uid = USB_TD_GET_RGID(td);
perm.mode = 0;
if (fflags & FREAD)
perm.mode |= 0444;
@@ -1458,11 +1458,7 @@
error = EBUSY;
break;
}
-#if defined(__NetBSD__)
- f->async_p = td;
-#else
- f->async_p = td->td_proc;
-#endif
+ f->async_p = USB_TD_GET_PROC(td);
} else {
f->async_p = NULL;
}
@@ -1474,7 +1470,7 @@
error = EINVAL;
break;
}
- if (*(int *)addr != f->async_p->p_pgid) {
+ if (*(int *)addr != USB_PROC_GET_GID(f->async_p)) {
error = EPERM;
break;
}
@@ -1787,14 +1783,14 @@
static int
usb2_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td)
{
- return (vnops.fo_stat(fp, sb, cred, td));
+ return (USB_VNOPS_FO_STAT(fp, sb, cred, td));
}
#if __FreeBSD_version > 800009
static int
usb2_truncate_f(struct file *fp, off_t length, struct ucred *cred, struct thread *td)
{
- return (vnops.fo_truncate(fp, length, cred, td));
+ return (USB_VNOPS_FO_TRUNCATE(fp, length, cred, td));
}
#endif
More information about the p4-projects
mailing list