Date: Mon, 25 Jul 2011 06:53:25 +0000 From: gk@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r224525 - in soc2011/gk/ino64-head: lib/libc/gen lib/libc/include lib/libc/sys sys/compat/freebsd32 sys/compat/linux sys/compat/svr4 sys/fs/nfs sys/fs/nfsserver sys/fs/nullfs sys/fs/... Message-ID: <20110725065325.832111065674@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gk Date: Mon Jul 25 06:53:25 2011 New Revision: 224525 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=224525 Log: Increase MNAMELEN to 1024, add compatibility shims Malloc struct statfs in kernel, it became too big to be placed on stack Leave MFSNAMELEN untouched, otherwise compatibility shims for several sysctls have to be implemented. Added: soc2011/gk/ino64-head/lib/libc/gen/getmntinfo-compat8.c - copied, changed from r224306, soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h Modified: soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc soc2011/gk/ino64-head/lib/libc/gen/Symbol.map soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c soc2011/gk/ino64-head/lib/libc/gen/fts-compat8.c soc2011/gk/ino64-head/lib/libc/include/compat.h soc2011/gk/ino64-head/lib/libc/sys/Symbol.map soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32.h soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32_misc.c soc2011/gk/ino64-head/sys/compat/freebsd32/syscalls.master soc2011/gk/ino64-head/sys/compat/linux/linux_stats.c soc2011/gk/ino64-head/sys/compat/svr4/svr4_misc.c soc2011/gk/ino64-head/sys/fs/nfs/nfs_commonsubs.c soc2011/gk/ino64-head/sys/fs/nfsserver/nfs_nfsdserv.c soc2011/gk/ino64-head/sys/fs/nullfs/null_vfsops.c soc2011/gk/ino64-head/sys/fs/unionfs/union_vfsops.c soc2011/gk/ino64-head/sys/i386/ibcs2/ibcs2_stat.c soc2011/gk/ino64-head/sys/kern/kern_acct.c soc2011/gk/ino64-head/sys/kern/syscalls.master soc2011/gk/ino64-head/sys/kern/vfs_default.c soc2011/gk/ino64-head/sys/kern/vfs_syscalls.c soc2011/gk/ino64-head/sys/nfsserver/nfs_serv.c soc2011/gk/ino64-head/sys/sys/mount.h Modified: soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/gen/Makefile.inc Mon Jul 25 06:53:25 2011 (r224525) @@ -15,7 +15,8 @@ fpclassify.c frexp.c fstab.c ftok.c fts.c fts-compat.c fts-compat8.c \ ftw.c ftw-compat8.c getbootfile.c getbsize.c \ getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ - gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ + gethostname.c getloadavg.c getlogin.c \ + getmntinfo.c getmntinfo-compat8.c getnetgrent.c \ getosreldate.c getpagesize.c getpagesizes.c \ getpeereid.c getprogname.c getpwent.c getttyent.c \ getusershell.c getutxent.c getvfsbyname.c glob.c glob-compat8.c \ Modified: soc2011/gk/ino64-head/lib/libc/gen/Symbol.map ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/Symbol.map Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/gen/Symbol.map Mon Jul 25 06:53:25 2011 (r224525) @@ -166,7 +166,6 @@ getloadavg; getlogin; getlogin_r; - getmntinfo; setnetgrent; getnetgrent; endnetgrent; @@ -355,6 +354,7 @@ fts_set; fts_set_clientptr; ftw; + getmntinfo; getpagesizes; getutxent; getutxid; Modified: soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h Mon Jul 25 06:53:25 2011 (r224525) @@ -30,11 +30,15 @@ #ifndef _DIRENT_COMPAT_H_ #define _DIRENT_COMPAT_H_ +#include <dirent.h> + #define FREEBSD8_DIRSIZ(dp) \ (sizeof(struct freebsd8_dirent) - sizeof((dp)->d_name) + \ (((dp)->d_namlen + 1 + 3) &~ 3)) +struct freebsd8_dirent; struct freebsd8_stat; +struct freebsd8_statfs; struct freebsd8_dirent *freebsd8_readdir(DIR *); int freebsd8_readdir_r(DIR *, struct freebsd8_dirent *, @@ -43,4 +47,8 @@ int freebsd8_lstat(const char *, struct freebsd8_stat *); int freebsd8_fstat(int, struct freebsd8_stat *); +int freebsd8_statfs(const char *, struct freebsd8_statfs *); +int freebsd8_getfsstat(struct freebsd8_statfs *, long, int); +int freebsd8_getmntinfo(struct freebsd8_statfs **, int); + #endif /* _DIRENT_COMPAT_H_ */ Modified: soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/gen/fts-compat.c Mon Jul 25 06:53:25 2011 (r224525) @@ -97,7 +97,7 @@ */ struct _fts_private { FTS ftsp_fts; - struct statfs ftsp_statfs; + struct freebsd8_statfs ftsp_statfs; dev_t ftsp_dev; int ftsp_linksreliable; }; @@ -1219,7 +1219,7 @@ * avoidance. */ if (priv->ftsp_dev != ent->fts_dev) { - if (statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { + if (freebsd8_statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { priv->ftsp_dev = ent->fts_dev; priv->ftsp_linksreliable = 0; for (cpp = ufslike_filesystems; *cpp; cpp++) { Modified: soc2011/gk/ino64-head/lib/libc/gen/fts-compat8.c ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/fts-compat8.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/gen/fts-compat8.c Mon Jul 25 06:53:25 2011 (r224525) @@ -85,7 +85,7 @@ */ struct _fts_private { FTS ftsp_fts; - struct statfs ftsp_statfs; + struct freebsd8_statfs ftsp_statfs; dev_t ftsp_dev; int ftsp_linksreliable; }; @@ -1183,7 +1183,7 @@ * avoidance. */ if (priv->ftsp_dev != ent->fts_dev) { - if (statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { + if (freebsd8_statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { priv->ftsp_dev = ent->fts_dev; priv->ftsp_linksreliable = 0; for (cpp = ufslike_filesystems; *cpp; cpp++) { Copied and modified: soc2011/gk/ino64-head/lib/libc/gen/getmntinfo-compat8.c (from r224306, soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h) ============================================================================== --- soc2011/gk/ino64-head/lib/libc/gen/dirent-compat.h Sat Jul 16 10:43:25 2011 (r224306, copy source) +++ soc2011/gk/ino64-head/lib/libc/gen/getmntinfo-compat8.c Mon Jul 25 06:53:25 2011 (r224525) @@ -1,5 +1,5 @@ /* - * Copyright (c) 1983, 1993 + * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,20 +27,46 @@ * SUCH DAMAGE. */ -#ifndef _DIRENT_COMPAT_H_ -#define _DIRENT_COMPAT_H_ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); -#define FREEBSD8_DIRSIZ(dp) \ - (sizeof(struct freebsd8_dirent) - sizeof((dp)->d_name) + \ - (((dp)->d_namlen + 1 + 3) &~ 3)) - -struct freebsd8_stat; - -struct freebsd8_dirent *freebsd8_readdir(DIR *); -int freebsd8_readdir_r(DIR *, struct freebsd8_dirent *, - struct freebsd8_dirent **); -int freebsd8_stat(const char *, struct freebsd8_stat *); -int freebsd8_lstat(const char *, struct freebsd8_stat *); -int freebsd8_fstat(int, struct freebsd8_stat *); +#include <sys/param.h> +#include <sys/ucred.h> +#include <sys/mount.h> +#include <stdlib.h> -#endif /* _DIRENT_COMPAT_H_ */ +#include "dirent-compat.h" + +/* + * Return information about mounted filesystems. + */ +int +freebsd8_getmntinfo(struct freebsd8_statfs **mntbufp, int flags) +{ + static struct freebsd8_statfs *mntbuf; + static int mntsize; + static long bufsize; + + if (mntsize <= 0 && + (mntsize = freebsd8_getfsstat(0, 0, MNT_NOWAIT)) < 0) + return (0); + if (bufsize > 0 && + (mntsize = freebsd8_getfsstat(mntbuf, bufsize, flags)) < 0) + return (0); + while (bufsize <= mntsize * sizeof(struct freebsd8_statfs)) { + if (mntbuf) + free(mntbuf); + bufsize = (mntsize + 1) * sizeof(struct freebsd8_statfs); + if ((mntbuf = (struct freebsd8_statfs *)malloc(bufsize)) == 0) + return (0); + if ((mntsize = freebsd8_getfsstat(mntbuf, bufsize, flags)) < 0) + return (0); + } + *mntbufp = mntbuf; + return (mntsize); +} + +__sym_compat(getmntinfo, freebsd8_getmntinfo, FBSD_1.0); Modified: soc2011/gk/ino64-head/lib/libc/include/compat.h ============================================================================== --- soc2011/gk/ino64-head/lib/libc/include/compat.h Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/include/compat.h Mon Jul 25 06:53:25 2011 (r224525) @@ -55,6 +55,11 @@ __sym_compat(getdents, freebsd8_getdents, FBSD_1.0); __sym_compat(getdirentries, freebsd8_getdirentries, FBSD_1.0); +__sym_compat(getfsstat, freebsd8_getfsstat, FBSD_1.0); +__sym_compat(fhstatfs, freebsd8_fhstatfs, FBSD_1.0); +__sym_compat(fstatfs, freebsd8_fstatfs, FBSD_1.0); +__sym_compat(statfs, freebsd8_statfs, FBSD_1.0); + #undef __sym_compat #endif /* __LIBC_COMPAT_H__ */ Modified: soc2011/gk/ino64-head/lib/libc/sys/Symbol.map ============================================================================== --- soc2011/gk/ino64-head/lib/libc/sys/Symbol.map Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/lib/libc/sys/Symbol.map Mon Jul 25 06:53:25 2011 (r224525) @@ -88,11 +88,9 @@ fchown; fcntl; fhopen; - fhstatfs; flock; fork; fpathconf; - fstatfs; fsync; futimes; getaudit; @@ -103,7 +101,6 @@ getegid; geteuid; getfh; - getfsstat; getgid; getgroups; getitimer; @@ -276,7 +273,6 @@ socketpair; __stack_chk_fail; __stack_chk_guard; - statfs; swapcontext; swapoff; swapon; @@ -354,10 +350,13 @@ cap_enter; cap_getmode; fhstat; + fhstatfs; fstat; fstatat; + fstatfs; getdents; getdirentries; + getfsstat; getloginclass; lstat; posix_fallocate; @@ -368,6 +367,7 @@ rctl_remove_rule; setloginclass; stat; + statfs; }; FBSDprivate_1.0 { Modified: soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32.h ============================================================================== --- soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32.h Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32.h Mon Jul 25 06:53:25 2011 (r224525) @@ -84,7 +84,8 @@ struct timeval32 it_value; }; -#define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ +#define FREEBSD4_MFSNAMELEN 16 +#define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* 4.x version */ struct statfs32 { @@ -102,7 +103,7 @@ int32_t f_flags; int32_t f_syncwrites; int32_t f_asyncwrites; - char f_fstypename[MFSNAMELEN]; + char f_fstypename[FREEBSD4_MFSNAMELEN]; char f_mntonname[FREEBSD4_MNAMELEN]; int32_t f_syncreads; int32_t f_asyncreads; Modified: soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32_misc.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/compat/freebsd32/freebsd32_misc.c Mon Jul 25 06:53:25 2011 (r224525) @@ -1347,14 +1347,17 @@ freebsd4_freebsd32_statfs(struct thread *td, struct freebsd4_freebsd32_statfs_args *uap) { struct statfs32 s32; - struct statfs s; + struct statfs *sp; int error; - error = kern_statfs(td, uap->path, UIO_USERSPACE, &s); - if (error) - return (error); - copy_statfs(&s, &s32); - return (copyout(&s32, uap->buf, sizeof(s32))); + sp = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, uap->path, UIO_USERSPACE, sp); + if (error == 0) { + copy_statfs(sp, &s32); + error = copyout(&s32, uap->buf, sizeof(s32)); + } + free(sp, M_TEMP); + return (error); } #endif @@ -1363,14 +1366,17 @@ freebsd4_freebsd32_fstatfs(struct thread *td, struct freebsd4_freebsd32_fstatfs_args *uap) { struct statfs32 s32; - struct statfs s; + struct statfs *sp; int error; - error = kern_fstatfs(td, uap->fd, &s); - if (error) - return (error); - copy_statfs(&s, &s32); - return (copyout(&s32, uap->buf, sizeof(s32))); + sp = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fstatfs(td, uap->fd, sp); + if (error == 0) { + copy_statfs(sp, &s32); + error = copyout(&s32, uap->buf, sizeof(s32)); + } + free(sp, M_TEMP); + return (error); } #endif @@ -1379,17 +1385,20 @@ freebsd4_freebsd32_fhstatfs(struct thread *td, struct freebsd4_freebsd32_fhstatfs_args *uap) { struct statfs32 s32; - struct statfs s; + struct statfs *sp; fhandle_t fh; int error; if ((error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t))) != 0) return (error); - error = kern_fhstatfs(td, fh, &s); - if (error) - return (error); - copy_statfs(&s, &s32); - return (copyout(&s32, uap->buf, sizeof(s32))); + sp = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fhstatfs(td, fh, sp); + if (error == 0) { + copy_statfs(sp, &s32); + error = copyout(&s32, uap->buf, sizeof(s32)); + } + free(sp, M_TEMP); + return (error); } #endif Modified: soc2011/gk/ino64-head/sys/compat/freebsd32/syscalls.master ============================================================================== --- soc2011/gk/ino64-head/sys/compat/freebsd32/syscalls.master Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/compat/freebsd32/syscalls.master Mon Jul 25 06:53:25 2011 (r224525) @@ -696,13 +696,16 @@ size_t nbytes, struct sf_hdtr32 *hdtr, \ off_t *sbytes, int flags); } 394 AUE_NULL UNIMPL mac_syscall -395 AUE_GETFSSTAT NOPROTO { int getfsstat(struct statfs *buf, \ +395 AUE_GETFSSTAT COMPAT8|NOPROTO { int getfsstat( \ + struct freebsd8_statfs *buf, \ long bufsize, int flags); } -396 AUE_STATFS NOPROTO { int statfs(char *path, \ - struct statfs *buf); } -397 AUE_FSTATFS NOPROTO { int fstatfs(int fd, struct statfs *buf); } -398 AUE_FHSTATFS NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \ +396 AUE_STATFS COMPAT8|NOPROTO { int statfs(char *path, \ struct statfs *buf); } +397 AUE_FSTATFS COMPAT8|NOPROTO { int fstatfs(int fd, \ + struct freebsd8_statfs *buf); } +398 AUE_FHSTATFS COMPAT8|NOPROTO { int fhstatfs( \ + const struct fhandle *u_fhp, \ + struct freebsd8_statfs *buf); } 399 AUE_NULL UNIMPL nosys 400 AUE_NULL NOSTD|NOPROTO { int ksem_close(semid_t id); } 401 AUE_NULL NOSTD|NOPROTO { int ksem_post(semid_t id); } @@ -1006,3 +1009,10 @@ size_t count); } 538 AUE_GETDIRENTRIES STD { int freebsd32_getdirentries(int fd, \ char *buf, u_int count, int32_t *basep); } +539 AUE_GETFSSTAT NOPROTO { int getfsstat(struct statfs *buf, \ + long bufsize, int flags); } +540 AUE_STATFS NOPROTO { int statfs(char *path, \ + struct statfs *buf); } +541 AUE_FSTATFS NOPROTO { int fstatfs(int fd, struct statfs *buf); } +542 AUE_FHSTATFS NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \ + struct statfs *buf); } Modified: soc2011/gk/ino64-head/sys/compat/linux/linux_stats.c ============================================================================== --- soc2011/gk/ino64-head/sys/compat/linux/linux_stats.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/compat/linux/linux_stats.c Mon Jul 25 06:53:25 2011 (r224525) @@ -394,7 +394,7 @@ linux_statfs(struct thread *td, struct linux_statfs_args *args) { struct l_statfs linux_statfs; - struct statfs bsd_statfs; + struct statfs *bsd_statfs; char *path; int error, dev_shm; @@ -405,14 +405,17 @@ printf(ARGS(statfs, "%s, *"), path); #endif dev_shm = 0; - error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); + bsd_statfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); if (strncmp(path, "/dev/shm", sizeof("/dev/shm") - 1) == 0) dev_shm = (path[8] == '\0' || (path[8] == '/' && path[9] == '\0')); LFREEPATH(path); - if (error) + if (error == 0) + bsd_to_linux_statfs(bsd_statfs, &linux_statfs); + free(bsd_statfs, M_TEMP); + if (error != 0) return (error); - bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); if (dev_shm) linux_statfs.f_type = LINUX_SHMFS_MAGIC; return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); @@ -438,7 +441,7 @@ linux_statfs64(struct thread *td, struct linux_statfs64_args *args) { struct l_statfs64 linux_statfs; - struct statfs bsd_statfs; + struct statfs *bsd_statfs; char *path; int error; @@ -451,11 +454,14 @@ if (ldebug(statfs64)) printf(ARGS(statfs64, "%s, *"), path); #endif - error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); + bsd_statfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, bsd_statfs); LFREEPATH(path); - if (error) + if (error == 0) + bsd_to_linux_statfs64(bsd_statfs, &linux_statfs); + free(bsd_statfs, M_TEMP); + if (error != 0) return (error); - bsd_to_linux_statfs64(&bsd_statfs, &linux_statfs); return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); } @@ -463,17 +469,20 @@ linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args) { struct l_statfs linux_statfs; - struct statfs bsd_statfs; + struct statfs *bsd_statfs; int error; #ifdef DEBUG if (ldebug(fstatfs)) printf(ARGS(fstatfs, "%d, *"), args->fd); #endif - error = kern_fstatfs(td, args->fd, &bsd_statfs); - if (error) - return error; - bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); + bsd_statfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fstatfs(td, args->fd, bsd_statfs); + if (error == 0) + bsd_to_linux_statfs(bsd_statfs, &linux_statfs); + free(bsd_statfs, M_TEMP); + if (error != 0) + return (error); return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); } Modified: soc2011/gk/ino64-head/sys/compat/svr4/svr4_misc.c ============================================================================== --- soc2011/gk/ino64-head/sys/compat/svr4/svr4_misc.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/compat/svr4/svr4_misc.c Mon Jul 25 06:53:25 2011 (r224525) @@ -1383,17 +1383,20 @@ struct svr4_sys_statvfs_args *uap; { struct svr4_statvfs sfs; - struct statfs bfs; + struct statfs *bfs; char *path; int error; CHECKALTEXIST(td, uap->path, &path); - error = kern_statfs(td, path, UIO_SYSSPACE, &bfs); + bfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, bfs); free(path, M_TEMP); - if (error) + if (error == 0) + bsd_statfs_to_svr4_statvfs(bfs, &sfs); + free(bfs, M_TEMP); + if (error != 0) return (error); - bsd_statfs_to_svr4_statvfs(&bfs, &sfs); return copyout(&sfs, uap->fs, sizeof(sfs)); } @@ -1404,13 +1407,16 @@ struct svr4_sys_fstatvfs_args *uap; { struct svr4_statvfs sfs; - struct statfs bfs; + struct statfs *bfs; int error; - error = kern_fstatfs(td, uap->fd, &bfs); - if (error) + bfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fstatfs(td, uap->fd, bfs); + if (error == 0) + bsd_statfs_to_svr4_statvfs(bfs, &sfs); + free(bfs, M_TEMP); + if (error != 0) return (error); - bsd_statfs_to_svr4_statvfs(&bfs, &sfs); return copyout(&sfs, uap->fs, sizeof(sfs)); } @@ -1421,17 +1427,20 @@ struct svr4_sys_statvfs64_args *uap; { struct svr4_statvfs64 sfs; - struct statfs bfs; + struct statfs *bfs; char *path; int error; CHECKALTEXIST(td, uap->path, &path); - error = kern_statfs(td, path, UIO_SYSSPACE, &bfs); + bfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, bfs); free(path, M_TEMP); - if (error) + if (error == 0) + bsd_statfs_to_svr4_statvfs64(bfs, &sfs); + free(bfs, M_TEMP); + if (error != 0) return (error); - bsd_statfs_to_svr4_statvfs64(&bfs, &sfs); return copyout(&sfs, uap->fs, sizeof(sfs)); } @@ -1442,13 +1451,16 @@ struct svr4_sys_fstatvfs64_args *uap; { struct svr4_statvfs64 sfs; - struct statfs bfs; + struct statfs *bfs; int error; - error = kern_fstatfs(td, uap->fd, &bfs); - if (error) + bfs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fstatfs(td, uap->fd, bfs); + if (error == 0) + bsd_statfs_to_svr4_statvfs64(bfs, &sfs); + free(bfs, M_TEMP); + if (error != 0) return (error); - bsd_statfs_to_svr4_statvfs64(&bfs, &sfs); return copyout(&sfs, uap->fs, sizeof(sfs)); } Modified: soc2011/gk/ino64-head/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- soc2011/gk/ino64-head/sys/fs/nfs/nfs_commonsubs.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/fs/nfs/nfs_commonsubs.c Mon Jul 25 06:53:25 2011 (r224525) @@ -1929,7 +1929,7 @@ nfsattrbit_t *retbitp = &retbits; u_int32_t freenum, *retnump; u_int64_t uquad; - struct statfs fs; + struct statfs *fs; struct nfsfsinfo fsinf; struct timespec temptime; struct timeval curtime; @@ -1957,11 +1957,13 @@ /* * Get the VFS_STATFS(), since some attributes need them. */ + fs = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); if (NFSISSETSTATFS_ATTRBIT(retbitp)) { - error = VFS_STATFS(mp, &fs); + error = VFS_STATFS(mp, fs); if (error != 0) { if (reterr) { nd->nd_repstat = NFSERR_ACCES; + free(fs, M_TEMP); return (0); } NFSCLRSTATFS_ATTRBIT(retbitp); @@ -1993,6 +1995,7 @@ if (error != 0) { if (reterr) { nd->nd_repstat = NFSERR_ACCES; + free(fs, M_TEMP); return (0); } NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL); @@ -2133,7 +2136,7 @@ /* * Check quota and use min(quota, f_ffree). */ - freenum = fs.f_ffree; + freenum = fs->f_ffree; #ifdef QUOTA /* * ufs_quotactl() insists that the uid argument @@ -2156,13 +2159,13 @@ case NFSATTRBIT_FILESFREE: NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); *tl++ = 0; - *tl = txdr_unsigned(fs.f_ffree); + *tl = txdr_unsigned(fs->f_ffree); retnum += NFSX_HYPER; break; case NFSATTRBIT_FILESTOTAL: NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); *tl++ = 0; - *tl = txdr_unsigned(fs.f_files); + *tl = txdr_unsigned(fs->f_files); retnum += NFSX_HYPER; break; case NFSATTRBIT_FSLOCATIONS: @@ -2238,9 +2241,9 @@ break; case NFSATTRBIT_QUOTAHARD: if (priv_check_cred(cred, PRIV_VFS_EXCEEDQUOTA, 0)) - freenum = fs.f_bfree; + freenum = fs->f_bfree; else - freenum = fs.f_bavail; + freenum = fs->f_bavail; #ifdef QUOTA /* * ufs_quotactl() insists that the uid argument @@ -2256,15 +2259,15 @@ #endif /* QUOTA */ NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); uquad = (u_int64_t)freenum; - NFSQUOTABLKTOBYTE(uquad, fs.f_bsize); + NFSQUOTABLKTOBYTE(uquad, fs->f_bsize); txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; case NFSATTRBIT_QUOTASOFT: if (priv_check_cred(cred, PRIV_VFS_EXCEEDQUOTA, 0)) - freenum = fs.f_bfree; + freenum = fs->f_bfree; else - freenum = fs.f_bavail; + freenum = fs->f_bavail; #ifdef QUOTA /* * ufs_quotactl() insists that the uid argument @@ -2280,7 +2283,7 @@ #endif /* QUOTA */ NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); uquad = (u_int64_t)freenum; - NFSQUOTABLKTOBYTE(uquad, fs.f_bsize); + NFSQUOTABLKTOBYTE(uquad, fs->f_bsize); txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; @@ -2301,7 +2304,7 @@ #endif /* QUOTA */ NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); uquad = (u_int64_t)freenum; - NFSQUOTABLKTOBYTE(uquad, fs.f_bsize); + NFSQUOTABLKTOBYTE(uquad, fs->f_bsize); txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; @@ -2314,24 +2317,24 @@ case NFSATTRBIT_SPACEAVAIL: NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); if (priv_check_cred(cred, PRIV_VFS_BLOCKRESERVE, 0)) - uquad = (u_int64_t)fs.f_bfree; + uquad = (u_int64_t)fs->f_bfree; else - uquad = (u_int64_t)fs.f_bavail; - uquad *= fs.f_bsize; + uquad = (u_int64_t)fs->f_bavail; + uquad *= fs->f_bsize; txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; case NFSATTRBIT_SPACEFREE: NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); - uquad = (u_int64_t)fs.f_bfree; - uquad *= fs.f_bsize; + uquad = (u_int64_t)fs->f_bfree; + uquad *= fs->f_bsize; txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; case NFSATTRBIT_SPACETOTAL: NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER); - uquad = (u_int64_t)fs.f_blocks; - uquad *= fs.f_bsize; + uquad = (u_int64_t)fs->f_blocks; + uquad *= fs->f_bsize; txdr_hyper(uquad, tl); retnum += NFSX_HYPER; break; @@ -2404,6 +2407,7 @@ } if (naclp != NULL) acl_free(naclp); + free(fs, M_TEMP); *retnump = txdr_unsigned(retnum); return (retnum + prefixnum); } Modified: soc2011/gk/ino64-head/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- soc2011/gk/ino64-head/sys/fs/nfsserver/nfs_nfsdserv.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/fs/nfsserver/nfs_nfsdserv.c Mon Jul 25 06:53:25 2011 (r224525) @@ -1924,21 +1924,22 @@ u_int32_t *tl; int getret = 1; struct nfsvattr at; - struct statfs sfs; u_quad_t tval; if (nd->nd_repstat) { nfsrv_postopattr(nd, getret, &at); return (0); } - sf = &sfs; + sf = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); nd->nd_repstat = nfsvno_statfs(vp, sf); getret = nfsvno_getattr(vp, &at, nd->nd_cred, p, 1); vput(vp); if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &at); - if (nd->nd_repstat) + if (nd->nd_repstat) { + free(sf, M_TEMP); return (0); + } if (nd->nd_flag & ND_NFSV2) { NFSM_BUILD(tl, u_int32_t *, NFSX_V2STATFS); *tl++ = txdr_unsigned(NFS_V2MAXDATA); @@ -1965,6 +1966,7 @@ txdr_hyper(tval, tl); tl += 2; *tl = 0; } + free(sf, M_TEMP); return (0); } @@ -3353,19 +3355,20 @@ { int error = 0, ret, fhsize = NFSX_MYFH; struct nfsvattr nva; - struct statfs sf; + struct statfs *sf; struct nfsfsinfo fs; fhandle_t fh; + sf = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred, p, 1); if (!nd->nd_repstat) - nd->nd_repstat = nfsvno_statfs(vp, &sf); + nd->nd_repstat = nfsvno_statfs(vp, sf); if (!nd->nd_repstat) nd->nd_repstat = nfsvno_getfh(vp, &fh, p); if (!nd->nd_repstat) { nfsvno_getfs(&fs, isdgram); error = nfsv4_loadattr(nd, vp, &nva, NULL, &fh, fhsize, NULL, - &sf, NULL, &fs, NULL, 1, &ret, NULL, NULL, p, nd->nd_cred); + sf, NULL, &fs, NULL, 1, &ret, NULL, NULL, p, nd->nd_cred); if (!error) { if (nd->nd_procnum == NFSV4OP_NVERIFY) { if (ret == 0) @@ -3377,6 +3380,7 @@ } } vput(vp); + free(sf, M_TEMP); return (error); } Modified: soc2011/gk/ino64-head/sys/fs/nullfs/null_vfsops.c ============================================================================== --- soc2011/gk/ino64-head/sys/fs/nullfs/null_vfsops.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/fs/nullfs/null_vfsops.c Mon Jul 25 06:53:25 2011 (r224525) @@ -269,28 +269,32 @@ struct statfs *sbp; { int error; - struct statfs mstat; + struct statfs *mstat; NULLFSDEBUG("nullfs_statfs(mp = %p, vp = %p->%p)\n", (void *)mp, (void *)MOUNTTONULLMOUNT(mp)->nullm_rootvp, (void *)NULLVPTOLOWERVP(MOUNTTONULLMOUNT(mp)->nullm_rootvp)); - bzero(&mstat, sizeof(mstat)); + mstat = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK | M_ZERO); - error = VFS_STATFS(MOUNTTONULLMOUNT(mp)->nullm_vfs, &mstat); - if (error) + error = VFS_STATFS(MOUNTTONULLMOUNT(mp)->nullm_vfs, mstat); + if (error) { + free(mstat, M_TEMP); return (error); + } /* now copy across the "interesting" information and fake the rest */ - sbp->f_type = mstat.f_type; - sbp->f_flags = mstat.f_flags; - sbp->f_bsize = mstat.f_bsize; - sbp->f_iosize = mstat.f_iosize; - sbp->f_blocks = mstat.f_blocks; - sbp->f_bfree = mstat.f_bfree; - sbp->f_bavail = mstat.f_bavail; - sbp->f_files = mstat.f_files; - sbp->f_ffree = mstat.f_ffree; + sbp->f_type = mstat->f_type; + sbp->f_flags = mstat->f_flags; + sbp->f_bsize = mstat->f_bsize; + sbp->f_iosize = mstat->f_iosize; + sbp->f_blocks = mstat->f_blocks; + sbp->f_bfree = mstat->f_bfree; + sbp->f_bavail = mstat->f_bavail; + sbp->f_files = mstat->f_files; + sbp->f_ffree = mstat->f_ffree; + + free(mstat, M_TEMP); return (0); } Modified: soc2011/gk/ino64-head/sys/fs/unionfs/union_vfsops.c ============================================================================== --- soc2011/gk/ino64-head/sys/fs/unionfs/union_vfsops.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/fs/unionfs/union_vfsops.c Mon Jul 25 06:53:25 2011 (r224525) @@ -396,7 +396,7 @@ { struct unionfs_mount *ump; int error; - struct statfs mstat; + struct statfs *mstat; uint64_t lbsize; ump = MOUNTTOUNIONFSMOUNT(mp); @@ -404,39 +404,47 @@ UNIONFSDEBUG("unionfs_statfs(mp = %p, lvp = %p, uvp = %p)\n", (void *)mp, (void *)ump->um_lowervp, (void *)ump->um_uppervp); - bzero(&mstat, sizeof(mstat)); + mstat = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK | M_ZERO); - error = VFS_STATFS(ump->um_lowervp->v_mount, &mstat); - if (error) + error = VFS_STATFS(ump->um_lowervp->v_mount, mstat); + if (error) { + free(mstat, M_TEMP); return (error); + } /* now copy across the "interesting" information and fake the rest */ - sbp->f_blocks = mstat.f_blocks; - sbp->f_files = mstat.f_files; + sbp->f_blocks = mstat->f_blocks; + sbp->f_files = mstat->f_files; - lbsize = mstat.f_bsize; + lbsize = mstat->f_bsize; - error = VFS_STATFS(ump->um_uppervp->v_mount, &mstat); - if (error) + error = VFS_STATFS(ump->um_uppervp->v_mount, mstat); + if (error) { + free(mstat, M_TEMP); return (error); + } + /* * The FS type etc is copy from upper vfs. * (write able vfs have priority) */ - sbp->f_type = mstat.f_type; - sbp->f_flags = mstat.f_flags; - sbp->f_bsize = mstat.f_bsize; - sbp->f_iosize = mstat.f_iosize; - - if (mstat.f_bsize != lbsize) - sbp->f_blocks = ((off_t)sbp->f_blocks * lbsize) / mstat.f_bsize; - - sbp->f_blocks += mstat.f_blocks; - sbp->f_bfree = mstat.f_bfree; - sbp->f_bavail = mstat.f_bavail; - sbp->f_files += mstat.f_files; - sbp->f_ffree = mstat.f_ffree; + sbp->f_type = mstat->f_type; + sbp->f_flags = mstat->f_flags; + sbp->f_bsize = mstat->f_bsize; + sbp->f_iosize = mstat->f_iosize; + + if (mstat->f_bsize != lbsize) + sbp->f_blocks = ((off_t)sbp->f_blocks * lbsize) / + mstat->f_bsize; + + sbp->f_blocks += mstat->f_blocks; + sbp->f_bfree = mstat->f_bfree; + sbp->f_bavail = mstat->f_bavail; + sbp->f_files += mstat->f_files; + sbp->f_ffree = mstat->f_ffree; + + free(mstat, M_TEMP); return (0); } Modified: soc2011/gk/ino64-head/sys/i386/ibcs2/ibcs2_stat.c ============================================================================== --- soc2011/gk/ino64-head/sys/i386/ibcs2/ibcs2_stat.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/i386/ibcs2/ibcs2_stat.c Mon Jul 25 06:53:25 2011 (r224525) @@ -107,16 +107,18 @@ struct thread *td; struct ibcs2_statfs_args *uap; { - struct statfs sf; + struct statfs *sf; char *path; int error; CHECKALTEXIST(td, uap->path, &path); - error = kern_statfs(td, path, UIO_SYSSPACE, &sf); + sf = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, sf); free(path, M_TEMP); - if (error) - return (error); - return cvt_statfs(&sf, (caddr_t)uap->buf, uap->len); + if (error == 0) + error = cvt_statfs(sf, (caddr_t)uap->buf, uap->len); + free(sf, M_TEMP); + return (error); } int @@ -124,13 +126,15 @@ struct thread *td; struct ibcs2_fstatfs_args *uap; { - struct statfs sf; + struct statfs *sf; int error; - error = kern_fstatfs(td, uap->fd, &sf); - if (error) - return (error); - return cvt_statfs(&sf, (caddr_t)uap->buf, uap->len); + sf = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + error = kern_fstatfs(td, uap->fd, sf); + if (error == 0) + error = cvt_statfs(sf, (caddr_t)uap->buf, uap->len); + free(sf, M_TEMP); + return (error); } int Modified: soc2011/gk/ino64-head/sys/kern/kern_acct.c ============================================================================== --- soc2011/gk/ino64-head/sys/kern/kern_acct.c Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/kern/kern_acct.c Mon Jul 25 06:53:25 2011 (r224525) @@ -553,7 +553,7 @@ static void acctwatch(void) { - struct statfs sb; + struct statfs *sp; int vfslocked; sx_assert(&acct_sx, SX_XLOCKED); @@ -584,24 +584,27 @@ * Stopping here is better than continuing, maybe it will be VBAD * next time around. */ - if (VFS_STATFS(acct_vp->v_mount, &sb) < 0) { + sp = malloc(sizeof(struct statfs), M_TEMP, M_WAITOK); + if (VFS_STATFS(acct_vp->v_mount, sp) < 0) { VFS_UNLOCK_GIANT(vfslocked); + free(sp, M_TEMP); return; } VFS_UNLOCK_GIANT(vfslocked); if (acct_suspended) { - if (sb.f_bavail > (int64_t)(acctresume * sb.f_blocks / + if (sp->f_bavail > (int64_t)(acctresume * sp->f_blocks / 100)) { acct_suspended = 0; log(LOG_NOTICE, "Accounting resumed\n"); } } else { - if (sb.f_bavail <= (int64_t)(acctsuspend * sb.f_blocks / + if (sp->f_bavail <= (int64_t)(acctsuspend * sp->f_blocks / 100)) { acct_suspended = 1; log(LOG_NOTICE, "Accounting suspended\n"); } } + free(sp, M_TEMP); } /* Modified: soc2011/gk/ino64-head/sys/kern/syscalls.master ============================================================================== --- soc2011/gk/ino64-head/sys/kern/syscalls.master Mon Jul 25 01:42:51 2011 (r224524) +++ soc2011/gk/ino64-head/sys/kern/syscalls.master Mon Jul 25 06:53:25 2011 (r224525) @@ -706,13 +706,14 @@ off_t *sbytes, int flags); } 394 AUE_NULL STD { int mac_syscall(const char *policy, \ int call, void *arg); } -395 AUE_GETFSSTAT STD { int getfsstat(struct statfs *buf, \ +395 AUE_GETFSSTAT COMPAT8 { int getfsstat(struct freebsd8_statfs *buf, \ long bufsize, int flags); } -396 AUE_STATFS STD { int statfs(char *path, \ - struct statfs *buf); } -397 AUE_FSTATFS STD { int fstatfs(int fd, struct statfs *buf); } -398 AUE_FHSTATFS STD { int fhstatfs(const struct fhandle *u_fhp, \ - struct statfs *buf); } +396 AUE_STATFS COMPAT8 { int statfs(char *path, \ + struct freebsd8_statfs *buf); } +397 AUE_FSTATFS COMPAT8 { int fstatfs(int fd, \ + struct freebsd8_statfs *buf); } +398 AUE_FHSTATFS COMPAT8 { int fhstatfs(const struct fhandle *u_fhp, \ + struct freebsd8_statfs *buf); } 399 AUE_NULL UNIMPL nosys *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110725065325.832111065674>