diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index 5975144ffc45..806b2ffc6d94 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -75,8 +75,9 @@ struct rusage32 { int32_t ru_nivcsw; }; -#define FREEBSD32_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ +#define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ +/* 4.x version */ struct statfs32 { int32_t f_spare2; int32_t f_bsize; @@ -93,11 +94,11 @@ struct statfs32 { int32_t f_syncwrites; int32_t f_asyncwrites; char f_fstypename[MFSNAMELEN]; - char f_mntonname[FREEBSD32_MNAMELEN]; + char f_mntonname[FREEBSD4_MNAMELEN]; int32_t f_syncreads; int32_t f_asyncreads; int16_t f_spares1; - char f_mntfromname[FREEBSD32_MNAMELEN]; + char f_mntfromname[FREEBSD4_MNAMELEN]; 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 deccaf8fc710..a103204c241a 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -140,15 +140,15 @@ copy_statfs(struct statfs *in, struct statfs32 *out) bcopy(in->f_fstypename, out->f_fstypename, MFSNAMELEN); bcopy(in->f_mntonname, - out->f_mntonname, MNAMELEN); + out->f_mntonname, min(MNAMELEN, FREEBSD4_MNAMELEN)); CP(*in, *out, f_syncreads); CP(*in, *out, f_asyncreads); bcopy(in->f_mntfromname, - out->f_mntfromname, MNAMELEN); + out->f_mntfromname, min(MNAMELEN, FREEBSD4_MNAMELEN)); } int -freebsd32_getfsstat(struct thread *td, struct freebsd32_getfsstat_args *uap) +freebsd4_freebsd32_getfsstat(struct thread *td, struct freebsd4_freebsd32_getfsstat_args *uap) { int error; caddr_t sg; @@ -870,7 +870,7 @@ freebsd32_adjtime(struct thread *td, struct freebsd32_adjtime_args *uap) } int -freebsd32_statfs(struct thread *td, struct freebsd32_statfs_args *uap) +freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_args *uap) { int error; caddr_t sg; @@ -897,7 +897,7 @@ freebsd32_statfs(struct thread *td, struct freebsd32_statfs_args *uap) } int -freebsd32_fstatfs(struct thread *td, struct freebsd32_fstatfs_args *uap) +freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_args *uap) { int error; caddr_t sg; @@ -923,6 +923,33 @@ freebsd32_fstatfs(struct thread *td, struct freebsd32_fstatfs_args *uap) return (error); } +int +freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatfs_args *uap) +{ + int error; + caddr_t sg; + struct statfs32 *p32, s32; + struct statfs *p = NULL, s; + + p32 = uap->buf; + if (p32) { + sg = stackgap_init(); + p = stackgap_alloc(&sg, sizeof(struct statfs)); + uap->buf = (struct statfs32 *)p; + } + error = fhstatfs(td, (struct fhstatfs_args *) uap); + if (error) + return (error); + if (p32) { + error = copyin(p, &s, sizeof(s)); + if (error) + return (error); + copy_statfs(&s, &s32); + error = copyout(&s32, p32, sizeof(s32)); + } + return (error); +} + int freebsd32_semsys(struct thread *td, struct freebsd32_semsys_args *uap) { diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index c6e95503d94a..6f0631fdae73 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -64,8 +64,8 @@ 15 NOPROTO { int chmod(char *path, int mode); } 16 NOPROTO { int chown(char *path, int uid, int gid); } 17 MNOPROTO { int obreak(char *nsize); } break obreak_args int -18 STD { int freebsd32_getfsstat(struct statfs32 *buf, long bufsize, \ - int flags); } +18 COMPAT4 { int freebsd32_getfsstat(struct statfs32 *buf, \ + long bufsize, int flags); } 19 OBSOL olseek 20 MNOPROTO { pid_t getpid(void); } 21 NOPROTO { int mount(char *type, char *path, int flags, \ @@ -232,8 +232,9 @@ ; XXX this is a problem!!! 155 UNIMPL nfssvc 156 OBSOL ogetdirentries -157 STD { int freebsd32_statfs(char *path, struct statfs32 *buf); } -158 STD { int freebsd32_fstatfs(int fd, struct statfs32 *buf); } +157 COMPAT4 { int freebsd32_statfs(char *path, \ + struct statfs32 *buf); } +158 COMPAT4 { int freebsd32_fstatfs(int fd, struct statfs32 *buf);} 159 UNIMPL nosys 160 UNIMPL nosys 161 NOPROTO { int getfh(char *fname, struct fhandle *fhp); } @@ -414,8 +415,8 @@ 295 UNIMPL nosys 296 UNIMPL nosys ; XXX 297 is 300 in NetBSD -297 NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \ - struct statfs *buf); } +297 COMPAT4 { int freebsd32_fhstatfs(const struct fhandle *u_fhp, \ + struct statfs32 *buf); } 298 NOPROTO { int fhopen(const struct fhandle *u_fhp, int flags); } 299 NOPROTO { int fhstat(const struct fhandle *u_fhp, struct stat *sb); } ; syscall numbers for FreeBSD @@ -550,10 +551,12 @@ u_int32_t offsethi, size_t nbytes, struct sf_hdtr *hdtr, \ off_t *sbytes, int flags); } 394 UNIMPL mac_syscall -395 UNIMPL nosys -396 UNIMPL nosys -397 UNIMPL nosys -398 UNIMPL nosys +395 NOPROTO { int getfsstat(struct statfs *buf, long bufsize, \ + int flags); } +396 NOPROTO { int statfs(char *path, struct statfs *buf); } +397 NOPROTO { int fstatfs(int fd, struct statfs *buf); } +398 NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \ + struct statfs *buf); } 399 UNIMPL nosys ; XXX implement these? 400 UNIMPL ksem_close