Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F141921086
D54591.id169288.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D54591.id169288.diff
View Options
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -29,7 +29,10 @@
#ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
#define _COMPAT_FREEBSD32_FREEBSD32_H_
+#include <sys/cdefs.h>
#include <sys/abi_compat.h>
+#include <sys/devicestat.h>
+#include <sys/mount.h>
#include <sys/procfs.h>
#include <sys/socket.h>
#include <sys/user.h>
@@ -61,8 +64,8 @@
struct bintime32 {
time32_t sec;
- uint32_t frac[2];
-};
+ uint64_t frac;
+} __packed;
struct ffclock_estimate32 {
struct bintime32 update_time;
@@ -531,4 +534,28 @@
uint32_t pscr_args;
};
+struct devstat32 {
+ u_int sequence0;
+ int allocated;
+ u_int start_count;
+ u_int end_count;
+ struct bintime32 busy_from;
+ struct { u_int32_t stqe_next; } dev_links;
+ u_int32_t device_number;
+ char device_name[DEVSTAT_NAME_LEN];
+ int unit_number;
+ u_int64_t bytes[DEVSTAT_N_TRANS_FLAGS];
+ u_int64_t operations[DEVSTAT_N_TRANS_FLAGS];
+ struct bintime32 duration[DEVSTAT_N_TRANS_FLAGS];
+ struct bintime32 busy_time;
+ struct bintime32 creation_time;
+ u_int32_t block_size;
+ u_int64_t tag_types[3];
+ devstat_support_flags flags;
+ devstat_type_flags device_type;
+ devstat_priority priority;
+ u_int32_t id;
+ u_int sequence1;
+} __packed;
+
#endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c
--- a/sys/kern/subr_devstat.c
+++ b/sys/kern/subr_devstat.c
@@ -43,6 +43,10 @@
#include <vm/vm.h>
#include <vm/pmap.h>
+#ifdef COMPAT_FREEBSD32
+#include <compat/freebsd32/freebsd32.h>
+#endif
+
#include <machine/atomic.h>
SDT_PROVIDER_DEFINE(io);
@@ -398,25 +402,64 @@
*/
mygen = devstat_generation;
- error = SYSCTL_OUT(req, &mygen, sizeof(mygen));
+#ifdef COMPAT_FREEBSD32
+ if (req->flags & SCTL_MASK32) {
+ int32_t mygen32 = (int32_t)mygen;
+ error = SYSCTL_OUT(req, &mygen32, sizeof(mygen32));
+ } else
+#endif /* COMPAT_FREEBSD32 */
+ error = SYSCTL_OUT(req, &mygen, sizeof(mygen));
+ if (error != 0)
+ return (error);
if (devstat_num_devs == 0)
return(0);
- if (error != 0)
- return (error);
-
mtx_lock(&devstat_mutex);
nds = STAILQ_FIRST(&device_statq);
if (mygen != devstat_generation)
error = EBUSY;
mtx_unlock(&devstat_mutex);
-
if (error != 0)
return (error);
while (nds != NULL) {
- error = SYSCTL_OUT(req, nds, sizeof(struct devstat));
+#ifdef COMPAT_FREEBSD32
+ if (req->flags & SCTL_MASK32) {
+ /*
+ * The request came from a 32-bit process running
+ * on a 64-bit kernel; translate the struct before
+ * copying it out.
+ */
+ struct devstat32 ds32;
+ CP(*nds, ds32, sequence0);
+ CP(*nds, ds32, allocated);
+ CP(*nds, ds32, start_count);
+ CP(*nds, ds32, end_count);
+ BT_CP(*nds, ds32, busy_from);
+ PTROUT_CP(*nds, ds32, dev_links.stqe_next);
+ CP(*nds, ds32, device_number);
+ strcpy(ds32.device_name, nds->device_name);
+ CP(*nds, ds32, unit_number);
+ for (unsigned int i = 0; i < DEVSTAT_N_TRANS_FLAGS; i++) {
+ CP(*nds, ds32, bytes[i]);
+ CP(*nds, ds32, operations[i]);
+ BT_CP(*nds, ds32, duration[i]);
+ }
+ BT_CP(*nds, ds32, busy_time);
+ BT_CP(*nds, ds32, creation_time);
+ CP(*nds, ds32, block_size);
+ for (unsigned int i = 0; i < nitems(ds32.tag_types); i++)
+ CP(*nds, ds32, tag_types[i]);
+ CP(*nds, ds32, flags);
+ CP(*nds, ds32, device_type);
+ CP(*nds, ds32, priority);
+ PTROUT_CP(*nds, ds32, id);
+ CP(*nds, ds32, sequence1);
+ error = SYSCTL_OUT(req, &ds32, sizeof(ds32));
+ } else
+#endif /* COMPAT_FREEBSD32 */
+ error = SYSCTL_OUT(req, nds, sizeof(*nds));
if (error != 0)
return (error);
mtx_lock(&devstat_mutex);
@@ -428,7 +471,7 @@
if (error != 0)
return (error);
}
- return(error);
+ return (error);
}
/*
diff --git a/sys/sys/abi_compat.h b/sys/sys/abi_compat.h
--- a/sys/sys/abi_compat.h
+++ b/sys/sys/abi_compat.h
@@ -67,9 +67,9 @@
TS_CP((src), (dst), it_value); \
} while (0)
-#define BT_CP(src, dst, fld) do { \
- CP((src).fld, (dst).fld, sec); \
- *(uint64_t *)&(dst).fld.frac[0] = (src).fld.frac; \
+#define BT_CP(src, dst, fld) do { \
+ CP((src).fld, (dst).fld, sec); \
+ CP((src).fld, (dst).fld, frac); \
} while (0)
#endif /* !_COMPAT_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 13, 1:30 PM (13 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27628692
Default Alt Text
D54591.id169288.diff (4 KB)
Attached To
Mode
D54591: devstat: Provide 32-bit compatibility
Attached
Detach File
Event Timeline
Log In to Comment