Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Nov 2021 20:22:19 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2e89f95d6ae4 - main - freebsd32: fix types on statfs syscalls
Message-ID:  <202111172022.1AHKMJSR059564@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e89f95d6ae4e2f0f226589512d0efa88c95aa84

commit 2e89f95d6ae4e2f0f226589512d0efa88c95aa84
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2021-11-17 20:12:23 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2021-11-17 20:12:23 +0000

    freebsd32: fix types on statfs syscalls
    
    Rename struct statfs32 to struct ostatfs32 to mirror struct ostatfs.
    These structs are use for COMPAT4 support.  Stop using struct statfs32
    for modern implementations as struct statfs uses fixed-width types
    and it the same on all architectures.
    
    Reviewed by:    kevans
---
 sys/compat/freebsd32/freebsd32.h               | 12 ++++++------
 sys/compat/freebsd32/freebsd32_misc.c          | 18 +++++++++---------
 sys/compat/freebsd32/freebsd32_proto.h         |  8 ++++----
 sys/compat/freebsd32/freebsd32_systrace_args.c | 16 ++++++++--------
 sys/compat/freebsd32/syscalls.master           | 16 ++++++++--------
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index 8a14a42db813..1a5475595d76 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -115,11 +115,11 @@ struct umutex32 {
 	__uint32_t		m_spare[2];
 };
 
-#define FREEBSD4_MFSNAMELEN	16
-#define FREEBSD4_MNAMELEN	(88 - 2 * sizeof(int32_t))
+#define FREEBSD4_OMFSNAMELEN	16
+#define FREEBSD4_OMNAMELEN	(88 - 2 * sizeof(int32_t))
 
 /* 4.x version */
-struct statfs32 {
+struct ostatfs32 {
 	int32_t	f_spare2;
 	int32_t	f_bsize;
 	int32_t	f_iosize;
@@ -134,12 +134,12 @@ struct statfs32 {
 	int32_t	f_flags;
 	int32_t	f_syncwrites;
 	int32_t	f_asyncwrites;
-	char	f_fstypename[FREEBSD4_MFSNAMELEN];
-	char	f_mntonname[FREEBSD4_MNAMELEN];
+	char	f_fstypename[FREEBSD4_OMFSNAMELEN];
+	char	f_mntonname[FREEBSD4_OMNAMELEN];
 	int32_t	f_syncreads;
 	int32_t	f_asyncreads;
 	int16_t	f_spares1;
-	char	f_mntfromname[FREEBSD4_MNAMELEN];
+	char	f_mntfromname[FREEBSD4_OMNAMELEN];
 	int16_t	f_spares2 __packed;
 	int32_t f_spare[2];
 };
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 12d125132883..867c957f010a 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -154,7 +154,7 @@ CTASSERT(sizeof(struct timespec32) == 8);
 CTASSERT(sizeof(struct itimerval32) == 16);
 CTASSERT(sizeof(struct bintime32) == 12);
 #endif
-CTASSERT(sizeof(struct statfs32) == 256);
+CTASSERT(sizeof(struct ostatfs32) == 256);
 #ifdef __amd64__
 CTASSERT(sizeof(struct rusage32) == 72);
 #endif
@@ -260,7 +260,7 @@ freebsd32_wait6(struct thread *td, struct freebsd32_wait6_args *uap)
 
 #ifdef COMPAT_FREEBSD4
 static void
-copy_statfs(struct statfs *in, struct statfs32 *out)
+copy_statfs(struct statfs *in, struct ostatfs32 *out)
 {
 
 	statfs_scale_blocks(in, INT32_MAX);
@@ -281,11 +281,11 @@ copy_statfs(struct statfs *in, struct statfs32 *out)
 	strlcpy(out->f_fstypename,
 	      in->f_fstypename, MFSNAMELEN);
 	strlcpy(out->f_mntonname,
-	      in->f_mntonname, min(MNAMELEN, FREEBSD4_MNAMELEN));
+	      in->f_mntonname, min(MNAMELEN, FREEBSD4_OMNAMELEN));
 	out->f_syncreads = MIN(in->f_syncreads, INT32_MAX);
 	out->f_asyncreads = MIN(in->f_asyncreads, INT32_MAX);
 	strlcpy(out->f_mntfromname,
-	      in->f_mntfromname, min(MNAMELEN, FREEBSD4_MNAMELEN));
+	      in->f_mntfromname, min(MNAMELEN, FREEBSD4_OMNAMELEN));
 }
 #endif
 
@@ -295,11 +295,11 @@ freebsd4_freebsd32_getfsstat(struct thread *td,
     struct freebsd4_freebsd32_getfsstat_args *uap)
 {
 	struct statfs *buf, *sp;
-	struct statfs32 stat32;
+	struct ostatfs32 stat32;
 	size_t count, size, copycount;
 	int error;
 
-	count = uap->bufsize / sizeof(struct statfs32);
+	count = uap->bufsize / sizeof(struct ostatfs32);
 	size = count * sizeof(struct statfs);
 	error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, uap->mode);
 	if (size > 0) {
@@ -1828,7 +1828,7 @@ freebsd32_adjtime(struct thread *td, struct freebsd32_adjtime_args *uap)
 int
 freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_args *uap)
 {
-	struct statfs32 s32;
+	struct ostatfs32 s32;
 	struct statfs *sp;
 	int error;
 
@@ -1847,7 +1847,7 @@ freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_ar
 int
 freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_args *uap)
 {
-	struct statfs32 s32;
+	struct ostatfs32 s32;
 	struct statfs *sp;
 	int error;
 
@@ -1866,7 +1866,7 @@ freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_
 int
 freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatfs_args *uap)
 {
-	struct statfs32 s32;
+	struct ostatfs32 s32;
 	struct statfs *sp;
 	fhandle_t fh;
 	int error;
diff --git a/sys/compat/freebsd32/freebsd32_proto.h b/sys/compat/freebsd32/freebsd32_proto.h
index 102e574bdd2a..673618de8771 100644
--- a/sys/compat/freebsd32/freebsd32_proto.h
+++ b/sys/compat/freebsd32/freebsd32_proto.h
@@ -1012,21 +1012,21 @@ int	ofreebsd32_getdirentries(struct thread *, struct ofreebsd32_getdirentries_ar
 #define PAD64_REQUIRED
 #endif
 struct freebsd4_freebsd32_getfsstat_args {
-	char buf_l_[PADL_(struct statfs32 *)]; struct statfs32 * buf; char buf_r_[PADR_(struct statfs32 *)];
+	char buf_l_[PADL_(struct ostatfs32 *)]; struct ostatfs32 * buf; char buf_r_[PADR_(struct ostatfs32 *)];
 	char bufsize_l_[PADL_(long)]; long bufsize; char bufsize_r_[PADR_(long)];
 	char mode_l_[PADL_(int)]; int mode; char mode_r_[PADR_(int)];
 };
 struct freebsd4_freebsd32_statfs_args {
 	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
-	char buf_l_[PADL_(struct statfs32 *)]; struct statfs32 * buf; char buf_r_[PADR_(struct statfs32 *)];
+	char buf_l_[PADL_(struct ostatfs32 *)]; struct ostatfs32 * buf; char buf_r_[PADR_(struct ostatfs32 *)];
 };
 struct freebsd4_freebsd32_fstatfs_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
-	char buf_l_[PADL_(struct statfs32 *)]; struct statfs32 * buf; char buf_r_[PADR_(struct statfs32 *)];
+	char buf_l_[PADL_(struct ostatfs32 *)]; struct ostatfs32 * buf; char buf_r_[PADR_(struct ostatfs32 *)];
 };
 struct freebsd4_freebsd32_fhstatfs_args {
 	char u_fhp_l_[PADL_(const struct fhandle *)]; const struct fhandle * u_fhp; char u_fhp_r_[PADR_(const struct fhandle *)];
-	char buf_l_[PADL_(struct statfs32 *)]; struct statfs32 * buf; char buf_r_[PADR_(struct statfs32 *)];
+	char buf_l_[PADL_(struct ostatfs32 *)]; struct ostatfs32 * buf; char buf_r_[PADR_(struct ostatfs32 *)];
 };
 struct freebsd4_freebsd32_sendfile_args {
 	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
diff --git a/sys/compat/freebsd32/freebsd32_systrace_args.c b/sys/compat/freebsd32/freebsd32_systrace_args.c
index 6764f370d4c9..5532ba1b942e 100644
--- a/sys/compat/freebsd32/freebsd32_systrace_args.c
+++ b/sys/compat/freebsd32/freebsd32_systrace_args.c
@@ -3163,7 +3163,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
 	case 555: {
 		struct statfs_args *p = params;
 		uarg[0] = (intptr_t)p->path; /* const char * */
-		uarg[1] = (intptr_t)p->buf; /* struct statfs32 * */
+		uarg[1] = (intptr_t)p->buf; /* struct statfs * */
 		*n_args = 2;
 		break;
 	}
@@ -3171,14 +3171,14 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
 	case 556: {
 		struct fstatfs_args *p = params;
 		iarg[0] = p->fd; /* int */
-		uarg[1] = (intptr_t)p->buf; /* struct statfs32 * */
+		uarg[1] = (intptr_t)p->buf; /* struct statfs * */
 		*n_args = 2;
 		break;
 	}
 	/* getfsstat */
 	case 557: {
 		struct getfsstat_args *p = params;
-		uarg[0] = (intptr_t)p->buf; /* struct statfs32 * */
+		uarg[0] = (intptr_t)p->buf; /* struct statfs * */
 		iarg[1] = p->bufsize; /* long */
 		iarg[2] = p->mode; /* int */
 		*n_args = 3;
@@ -3188,7 +3188,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
 	case 558: {
 		struct fhstatfs_args *p = params;
 		uarg[0] = (intptr_t)p->u_fhp; /* const struct fhandle * */
-		uarg[1] = (intptr_t)p->buf; /* struct statfs32 * */
+		uarg[1] = (intptr_t)p->buf; /* struct statfs * */
 		*n_args = 2;
 		break;
 	}
@@ -8750,7 +8750,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
 			p = "userland const char *";
 			break;
 		case 1:
-			p = "userland struct statfs32 *";
+			p = "userland struct statfs *";
 			break;
 		default:
 			break;
@@ -8763,7 +8763,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
 			p = "int";
 			break;
 		case 1:
-			p = "userland struct statfs32 *";
+			p = "userland struct statfs *";
 			break;
 		default:
 			break;
@@ -8773,7 +8773,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
 	case 557:
 		switch (ndx) {
 		case 0:
-			p = "userland struct statfs32 *";
+			p = "userland struct statfs *";
 			break;
 		case 1:
 			p = "long";
@@ -8792,7 +8792,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
 			p = "userland const struct fhandle *";
 			break;
 		case 1:
-			p = "userland struct statfs32 *";
+			p = "userland struct statfs *";
 			break;
 		default:
 			break;
diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master
index b6ed5a7c6a21..bc836ae676c4 100644
--- a/sys/compat/freebsd32/syscalls.master
+++ b/sys/compat/freebsd32/syscalls.master
@@ -91,7 +91,7 @@
 16	AUE_CHOWN	NOPROTO	{ int chown(const char *path, int uid, int gid); }
 17	AUE_NULL	NOPROTO	{ void *break(char *nsize); }
 18	AUE_GETFSSTAT	COMPAT4	{ int freebsd32_getfsstat( \
-				    struct statfs32 *buf, long bufsize, \
+				    struct ostatfs32 *buf, long bufsize, \
 				    int mode); }
 19	AUE_LSEEK	COMPAT	{ int freebsd32_lseek(int fd, int offset, \
 				    int whence); }
@@ -314,9 +314,9 @@
 156	AUE_GETDIRENTRIES COMPAT { int freebsd32_getdirentries(int fd, \
 				    char *buf, u_int count, uint32_t *basep); }
 157	AUE_STATFS	COMPAT4	{ int freebsd32_statfs(const char *path, \
-				    struct statfs32 *buf); }
+				    struct ostatfs32 *buf); }
 158	AUE_FSTATFS	COMPAT4	{ int freebsd32_fstatfs(int fd, \
-				    struct statfs32 *buf); }
+				    struct ostatfs32 *buf); }
 159	AUE_NULL	UNIMPL	nosys
 160	AUE_LGETFH	UNIMPL	lgetfh
 161	AUE_NFS_GETFH	NOPROTO	{ int getfh(const char *fname, \
@@ -544,7 +544,7 @@
 296	AUE_NULL	UNIMPL	nosys
 297	AUE_FHSTATFS	COMPAT4	{ int freebsd32_fhstatfs( \
 				    const struct fhandle *u_fhp, \
-				    struct statfs32 *buf); }
+				    struct ostatfs32 *buf); }
 298	AUE_FHOPEN	NOPROTO	{ int fhopen(const struct fhandle *u_fhp, \
 			 	    int flags); }
 299	AUE_FHSTAT	COMPAT11 { int freebsd32_fhstat( \
@@ -1112,12 +1112,12 @@
 				    int fd, char *buf, size_t count, \
 				    off_t *basep); }
 555	AUE_STATFS	NOPROTO	{ int statfs(const char *path, \
-				    struct statfs32 *buf); }
-556	AUE_FSTATFS	NOPROTO	{ int fstatfs(int fd, struct statfs32 *buf); }
-557	AUE_GETFSSTAT	NOPROTO	{ int getfsstat(struct statfs32 *buf, \
+				    struct statfs *buf); }
+556	AUE_FSTATFS	NOPROTO	{ int fstatfs(int fd, struct statfs *buf); }
+557	AUE_GETFSSTAT	NOPROTO	{ int getfsstat(struct statfs *buf, \
 				    long bufsize, int mode); }
 558	AUE_FHSTATFS	NOPROTO	{ int fhstatfs(const struct fhandle *u_fhp, \
-				    struct statfs32 *buf); }
+				    struct statfs *buf); }
 #ifdef PAD64_REQUIRED
 559	AUE_MKNODAT	STD	{ int freebsd32_mknodat(int fd, \
 				    const char *path, mode_t mode, \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111172022.1AHKMJSR059564>