From 8143b9bf1d4ab32e1b5dc8461917f38d70292c1c Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Tue, 20 Aug 2013 01:28:23 +0200 Subject: [PATCH] Implement support for [f]statvfs1(2) The [f]statvfs(3) calls now use [f]statvfs1(2). Change-Id: I949c177fc14abf976e45165c342f897f4ec988ee --- distrib/sets/lists/minix/mi | 2 + include/minix/callnr.h | 4 +- include/minix/com.h | 18 +++-- lib/libc/include/namespace.h | 2 + lib/libc/sys-minix/fstatvfs.c | 15 +++- lib/libc/sys-minix/statvfs.c | 17 +++-- lib/libc/sys/Makefile.inc | 4 + man/man2/Makefile | 3 +- man/man2/statvfs.2 | 133 ---------------------------------- servers/vfs/stadir.c | 28 +++---- sys/sys/statvfs.h | 3 + 11 files changed, 62 insertions(+), 167 deletions(-) delete mode 100644 man/man2/statvfs.2 diff --git a/distrib/sets/lists/minix/mi b/distrib/sets/lists/minix/mi index 3ab7dc0ec..3bbf4e6b6 100644 --- a/distrib/sets/lists/minix/mi +++ b/distrib/sets/lists/minix/mi @@ -2216,6 +2216,7 @@ ./usr/man/man2/FD_SET.2 minix-sys ./usr/man/man2/fork.2 minix-sys ./usr/man/man2/fstatvfs.2 minix-sys +./usr/man/man2/fstatvfs1.2 minix-sys ./usr/man/man2/getgid.2 minix-sys ./usr/man/man2/getitimer.2 minix-sys ./usr/man/man2/getnucred.2 minix-sys @@ -2268,6 +2269,7 @@ ./usr/man/man2/socket.2 minix-sys ./usr/man/man2/socketpair.2 minix-sys ./usr/man/man2/statvfs.2 minix-sys +./usr/man/man2/statvfs1.2 minix-sys ./usr/man/man2/svrctl.2 minix-sys ./usr/man/man2/symlink.2 minix-sys ./usr/man/man2/sync.2 minix-sys diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 69685decb..3fc3973ff 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -75,8 +75,8 @@ #define GETDENTS_321 80 /* to VFS */ #define LLSEEK 81 /* to VFS */ #define GETVFSSTAT 82 /* to VFS */ -#define STATVFS 83 /* to VFS */ -#define FSTATVFS 84 /* to VFS */ +#define STATVFS1 83 /* to VFS */ +#define FSTATVFS1 84 /* to VFS */ #define SELECT 85 /* to VFS */ #define FCHDIR 86 /* to VFS */ #define FSYNC 87 /* to VFS */ diff --git a/include/minix/com.h b/include/minix/com.h index 8ad57eea1..47c93bccd 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -907,14 +907,16 @@ #define VFS_GETVFSSTAT_SIZE m1_i1 #define VFS_GETVFSSTAT_FLAGS m1_i2 -/* Field names for the fstatvfs call */ -#define FSTATVFS_FD m1_i1 -#define FSTATVFS_BUF m1_p1 - -/* Field names for the statvfs call */ -#define STATVFS_LEN m1_i1 -#define STATVFS_NAME m1_p1 -#define STATVFS_BUF m1_p2 +/* Field names for the fstatvfs1(2) call. */ +#define VFS_FSTATVFS1_FD m1_i1 +#define VFS_FSTATVFS1_BUF m1_p1 +#define VFS_FSTATVFS1_FLAGS m1_i2 + +/* Field names for the statvfs1(2) call. */ +#define VFS_STATVFS1_LEN m1_i1 +#define VFS_STATVFS1_NAME m1_p1 +#define VFS_STATVFS1_BUF m1_p2 +#define VFS_STATVFS1_FLAGS m1_i2 /* Field names for the mount(2) call. */ #define VFS_MOUNT_FLAGS m11_i1 diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index 3a1f9faac..930a8acf2 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -284,6 +284,7 @@ #define freeaddrinfo _freeaddrinfo #define freeifaddrs _freeifaddrs #define fstatvfs _fstatvfs +#define fstatvfs1 _fstatvfs1 #define ftok _ftok #define ftruncate _ftruncate #define fts_children _fts_children @@ -600,6 +601,7 @@ #define srand48 _srand48 #define srandom _srandom #define statvfs(a, b) _statvfs(a, b) +#define statvfs1 _statvfs1 #define strcasecmp _strcasecmp #define strdup _strdup #define stresep _stresep diff --git a/lib/libc/sys-minix/fstatvfs.c b/lib/libc/sys-minix/fstatvfs.c index 63e4d39e5..c4bbb9e15 100644 --- a/lib/libc/sys-minix/fstatvfs.c +++ b/lib/libc/sys-minix/fstatvfs.c @@ -5,14 +5,21 @@ #include #ifdef __weak_alias +__weak_alias(fstatvfs1, _fstatvfs1) __weak_alias(fstatvfs, _fstatvfs) #endif -int fstatvfs(int fd, struct statvfs *buffer) +int fstatvfs1(int fd, struct statvfs *buffer, int flags) { message m; - m.FSTATVFS_FD = fd; - m.FSTATVFS_BUF = (char *) buffer; - return(_syscall(VFS_PROC_NR, FSTATVFS, &m)); + m.VFS_FSTATVFS1_FD = fd; + m.VFS_FSTATVFS1_BUF = (char *) buffer; + m.VFS_FSTATVFS1_FLAGS = flags; + return(_syscall(VFS_PROC_NR, FSTATVFS1, &m)); +} + +int fstatvfs(int fd, struct statvfs *buffer) +{ + return fstatvfs1(fd, buffer, ST_WAIT); } diff --git a/lib/libc/sys-minix/statvfs.c b/lib/libc/sys-minix/statvfs.c index 1de8ab77a..54c046c54 100644 --- a/lib/libc/sys-minix/statvfs.c +++ b/lib/libc/sys-minix/statvfs.c @@ -6,15 +6,22 @@ #include #ifdef __weak_alias +__weak_alias(statvfs1, _statvfs1) __weak_alias(statvfs, _statvfs) #endif -int statvfs(const char *name, struct statvfs *buffer) +int statvfs1(const char *name, struct statvfs *buffer, int flags) { message m; - m.STATVFS_LEN = strlen(name) + 1; - m.STATVFS_NAME = (char *) __UNCONST(name); - m.STATVFS_BUF = (char *) buffer; - return(_syscall(VFS_PROC_NR, STATVFS, &m)); + m.VFS_STATVFS1_LEN = strlen(name) + 1; + m.VFS_STATVFS1_NAME = (char *) __UNCONST(name); + m.VFS_STATVFS1_BUF = (char *) buffer; + m.VFS_STATVFS1_FLAGS = flags; + return(_syscall(VFS_PROC_NR, STATVFS1, &m)); +} + +int statvfs(const char *name, struct statvfs *buffer) +{ + return statvfs1(name, buffer, ST_WAIT); } diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 239ff1aea..9e5554b4c 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -272,6 +272,7 @@ MLINKS+=chmod.2 fchmod.2 chmod.2 lchmod.2 MLINKS+=chown.2 fchown.2 chown.2 lchown.2 MLINKS+=chroot.2 fchroot.2 .else +MAN+= statvfs.2 MLINKS+=clock_settime.2 clock_gettime.2 MLINKS+=clock_settime.2 clock_getres.2 .endif # !defined(__MINIX) @@ -339,6 +340,9 @@ MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 MLINKS+=write.2 writev.2 write.2 pwrite.2 write.2 pwritev.2 .else MLINKS+=pipe.2 pipe2.2 +MLINKS+=statvfs.2 fstatvfs.2 +MLINKS+=statvfs.2 statvfs1.2 +MLINKS+=statvfs.2 fstatvfs1.2 .endif # !defined(__MINIX) .if !defined(__MINIX) MLINKS+=accept.2 paccept.2 diff --git a/man/man2/Makefile b/man/man2/Makefile index edbfe5852..40c3ecf7f 100644 --- a/man/man2/Makefile +++ b/man/man2/Makefile @@ -8,7 +8,7 @@ MAN= accept.2 access.2 alarm.2 bind.2 brk.2 chdir.2 chmod.2 chown.2 \ rmdir.2 select.2 send.2 sendmsg.2 sendto.2 setsid.2 \ setsockopt.2 setuid.2 shutdown.2 sigaction.2 sigpending.2 \ sigprocmask.2 sigsuspend.2 socket.2 socketpair.2 \ - statvfs.2 svrctl.2 symlink.2 sync.2 time.2 times.2 truncate.2 \ + svrctl.2 symlink.2 sync.2 time.2 times.2 truncate.2 \ umask.2 uname.2 unlink.2 utime.2 wait.2 write.2 MLINKS += select.2 FD_CLR.2 @@ -16,7 +16,6 @@ MLINKS += select.2 FD_ISSET.2 MLINKS += select.2 FD_SET.2 MLINKS += setuid.2 seteuid.2 MLINKS += setuid.2 setgid.2 -MLINKS += statvfs.2 fstatvfs.2 .include .include diff --git a/man/man2/statvfs.2 b/man/man2/statvfs.2 deleted file mode 100644 index 505ead513..000000000 --- a/man/man2/statvfs.2 +++ /dev/null @@ -1,133 +0,0 @@ -.\" $NetBSD: statvfs.2,v 1.4 2005/11/04 06:09:20 gendalia Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)statfs.2 8.5 (Berkeley) 5/24/95 -.\" -.Dd April 14, 2004 -.Dt STATVFS 2 -.Os -.Sh NAME -.Nm statvfs , -.Nm fstatvfs , -.Nd get file system statistics -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/statvfs.h -.Ft int -.Fn statvfs "const char *path" "struct statvfs *buf" -.Ft int -.Fn fstatvfs "int fd" "struct statvfs *buf" -.Sh DESCRIPTION -.Fn statvfs -returns information about a mounted file system. -.Fa path -is the path name of any file within the mounted file system. -.Fa buf -is a pointer to a -.Nm statvfs -structure defined in -.Xr statvfs 5 . -.Pp -.Fn fstatvfs -returns the same information about an open file referenced by descriptor -.Fa fd . -.Pp -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn statvfs -fails if one or more of the following are true: -.Bl -tag -width Er -.It Bq Er ENOTDIR -A component of the path prefix of -.Fa path -is not a directory. -.It Bq Er ENAMETOOLONG -The length of a component of -.Fa path -exceeds -.Dv NAME_MAX -characters, or the length of -.Fa path -exceeds -.Dv PATH_MAX -characters. -.It Bq Er ENOENT -The file referred to by -.Fa path -does not exist. -.It Bq Er EACCES -Search permission is denied for a component of the path prefix of -.Fa path . -.It Bq Er ELOOP -Too many symbolic links were encountered in translating -.Fa path . -.It Bq Er EFAULT -.Fa buf -or -.Fa path -points to an invalid address. -.It Bq Er EIO -An -.Tn I/O -error occurred while reading from or writing to the file system. -.El -.Pp -.Fn fstatvfs -fails if one or more of the following are true: -.Bl -tag -width Er -.It Bq Er EBADF -.Fa fd -is not a valid open file descriptor. -.It Bq Er EFAULT -.Fa buf -points to an invalid address. -.It Bq Er EIO -An -.Tn I/O -error occurred while reading from or writing to the file system. -.El -.Sh SEE ALSO -.Xr statvfs 5 -.Sh HISTORY -The -.Fn statvfs , -and -.Fn fstatvfs , -functions first appeared in -.Nx 3.0 -to replace -the -.Fn statfs -family of functions which first appeared in -.Bx 4.4 . diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index ab718c7dd..85c0d6b36 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -7,8 +7,8 @@ * do_lstat: perform the LSTAT system call * do_stat: perform the STAT system call * do_fstat: perform the FSTAT system call - * do_statvfs: perform the STATVFS system call - * do_fstatvfs: perform the FSTATVFS system call + * do_statvfs: perform the STATVFS1 system call + * do_fstatvfs: perform the FSTATVFS1 system call * do_getvfsstat: perform the GETVFSSTAT system call */ @@ -310,8 +310,8 @@ static int fill_statvfs(struct vmnt *vmp, endpoint_t endpt, vir_bytes buf_addr, *===========================================================================*/ int do_statvfs(message *UNUSED(m_out)) { -/* Perform the statvfs(name, buf) system call. */ - int r; +/* Perform the statvfs1(name, buf, flags) system call. */ + int r, flags; struct vnode *vp; struct vmnt *vmp; char fullpath[PATH_MAX]; @@ -319,9 +319,10 @@ int do_statvfs(message *UNUSED(m_out)) vir_bytes vname1, statbuf; size_t vname1_length; - vname1 = (vir_bytes) job_m_in.name1; - vname1_length = (size_t) job_m_in.name1_length; - statbuf = (vir_bytes) job_m_in.name2; + vname1 = (vir_bytes) job_m_in.VFS_STATVFS1_NAME; + vname1_length = (size_t) job_m_in.VFS_STATVFS1_LEN; + statbuf = (vir_bytes) job_m_in.VFS_STATVFS1_BUF; + flags = job_m_in.VFS_STATVFS1_FLAGS; lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp); resolve.l_vmnt_lock = VMNT_READ; @@ -329,7 +330,7 @@ int do_statvfs(message *UNUSED(m_out)) if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); - r = fill_statvfs(vp->v_vmnt, who_e, statbuf, ST_WAIT); + r = fill_statvfs(vp->v_vmnt, who_e, statbuf, flags); unlock_vnode(vp); unlock_vmnt(vmp); @@ -343,17 +344,18 @@ int do_statvfs(message *UNUSED(m_out)) *===========================================================================*/ int do_fstatvfs(message *UNUSED(m_out)) { -/* Perform the fstatvfs(fd, buf) system call. */ +/* Perform the fstatvfs1(fd, buf, flags) system call. */ register struct filp *rfilp; - int r, rfd; + int r, rfd, flags; vir_bytes statbuf; - rfd = job_m_in.fd; - statbuf = (vir_bytes) job_m_in.name2; + rfd = job_m_in.VFS_FSTATVFS1_FD; + statbuf = (vir_bytes) job_m_in.VFS_FSTATVFS1_BUF; + flags = job_m_in.VFS_FSTATVFS1_FLAGS; /* Is the file descriptor valid? */ if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code); - r = fill_statvfs(rfilp->filp_vno->v_vmnt, who_e, statbuf, ST_WAIT); + r = fill_statvfs(rfilp->filp_vno->v_vmnt, who_e, statbuf, flags); unlock_filp(rfilp); diff --git a/sys/sys/statvfs.h b/sys/sys/statvfs.h index 8809c6409..5a17b255d 100644 --- a/sys/sys/statvfs.h +++ b/sys/sys/statvfs.h @@ -118,6 +118,9 @@ __BEGIN_DECLS int statvfs(const char *__restrict, struct statvfs *__restrict); int fstatvfs(int, struct statvfs *); int getvfsstat(struct statvfs *, size_t, int); + +int statvfs1(const char *__restrict, struct statvfs *__restrict, int); +int fstatvfs1(int, struct statvfs *, int); __END_DECLS #endif /* !_SYS_STATVFS_H_ */ -- 2.44.0