b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) // SPDX-License-Identifier: GPL-2.0
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 2) #include <linux/syscalls.h>
630d9c47274aa (Paul Gortmaker 2011-11-16 23:57:37 -0500 3) #include <linux/export.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 4) #include <linux/fs.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 5) #include <linux/file.h>
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 6) #include <linux/mount.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 7) #include <linux/namei.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 8) #include <linux/statfs.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 9) #include <linux/security.h>
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 10) #include <linux/uaccess.h>
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 11) #include <linux/compat.h>
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 12) #include "internal.h"
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 13)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 14) static int flags_by_mnt(int mnt_flags)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 15) {
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 16) int flags = 0;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 17)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 18) if (mnt_flags & MNT_READONLY)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 19) flags |= ST_RDONLY;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 20) if (mnt_flags & MNT_NOSUID)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 21) flags |= ST_NOSUID;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 22) if (mnt_flags & MNT_NODEV)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 23) flags |= ST_NODEV;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 24) if (mnt_flags & MNT_NOEXEC)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 25) flags |= ST_NOEXEC;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 26) if (mnt_flags & MNT_NOATIME)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 27) flags |= ST_NOATIME;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 28) if (mnt_flags & MNT_NODIRATIME)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 29) flags |= ST_NODIRATIME;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 30) if (mnt_flags & MNT_RELATIME)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 31) flags |= ST_RELATIME;
dab741e0e02bd (Mattias Nissler 2020-08-27 11:09:46 -0600 32) if (mnt_flags & MNT_NOSYMFOLLOW)
dab741e0e02bd (Mattias Nissler 2020-08-27 11:09:46 -0600 33) flags |= ST_NOSYMFOLLOW;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 34) return flags;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 35) }
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 36)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 37) static int flags_by_sb(int s_flags)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 38) {
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 39) int flags = 0;
1751e8a6cb935 (Linus Torvalds 2017-11-27 13:05:09 -0800 40) if (s_flags & SB_SYNCHRONOUS)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 41) flags |= ST_SYNCHRONOUS;
1751e8a6cb935 (Linus Torvalds 2017-11-27 13:05:09 -0800 42) if (s_flags & SB_MANDLOCK)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 43) flags |= ST_MANDLOCK;
1751e8a6cb935 (Linus Torvalds 2017-11-27 13:05:09 -0800 44) if (s_flags & SB_RDONLY)
a8e2b6367794e (Carlos Maiolino 2017-06-29 11:25:40 +0200 45) flags |= ST_RDONLY;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 46) return flags;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 47) }
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 48)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 49) static int calculate_f_flags(struct vfsmount *mnt)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 50) {
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 51) return ST_VALID | flags_by_mnt(mnt->mnt_flags) |
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 52) flags_by_sb(mnt->mnt_sb->s_flags);
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 53) }
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 54)
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 55) static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 56) {
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 57) int retval;
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 58)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 59) if (!dentry->d_sb->s_op->statfs)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 60) return -ENOSYS;
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 61)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 62) memset(buf, 0, sizeof(*buf));
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 63) retval = security_sb_statfs(dentry);
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 64) if (retval)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 65) return retval;
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 66) retval = dentry->d_sb->s_op->statfs(dentry, buf);
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 67) if (retval == 0 && buf->f_frsize == 0)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 68) buf->f_frsize = buf->f_bsize;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 69) return retval;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 70) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 71)
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 72) int vfs_get_fsid(struct dentry *dentry, __kernel_fsid_t *fsid)
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 73) {
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 74) struct kstatfs st;
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 75) int error;
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 76)
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 77) error = statfs_by_dentry(dentry, &st);
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 78) if (error)
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 79) return error;
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 80)
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 81) *fsid = st.f_fsid;
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 82) return 0;
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 83) }
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 84) EXPORT_SYMBOL(vfs_get_fsid);
ec86ff5689ff9 (Amir Goldstein 2019-01-10 19:04:38 +0200 85)
f0bb5aaf2c512 (Al Viro 2016-11-20 20:27:12 -0500 86) int vfs_statfs(const struct path *path, struct kstatfs *buf)
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 87) {
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 88) int error;
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 89)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 90) error = statfs_by_dentry(path->dentry, buf);
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 91) if (!error)
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 92) buf->f_flags = calculate_f_flags(path->mnt);
365b18189789b (Christoph Hellwig 2010-07-07 18:53:25 +0200 93) return error;
ebabe9a9001af (Christoph Hellwig 2010-07-07 18:53:11 +0200 94) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 95) EXPORT_SYMBOL(vfs_statfs);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 96)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 97) int user_statfs(const char __user *pathname, struct kstatfs *st)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 98) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 99) struct path path;
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 100) int error;
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 101) unsigned int lookup_flags = LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT;
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 102) retry:
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 103) error = user_path_at(AT_FDCWD, pathname, lookup_flags, &path);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 104) if (!error) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 105) error = vfs_statfs(&path, st);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 106) path_put(&path);
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 107) if (retry_estale(error, lookup_flags)) {
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 108) lookup_flags |= LOOKUP_REVAL;
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 109) goto retry;
96948fc6069b6 (Jeff Layton 2012-12-11 12:10:14 -0500 110) }
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 111) }
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 112) return error;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 113) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 114)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 115) int fd_statfs(int fd, struct kstatfs *st)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 116) {
9d05746e7b16d (Linus Torvalds 2013-09-30 08:35:10 -0700 117) struct fd f = fdget_raw(fd);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 118) int error = -EBADF;
2903ff019b346 (Al Viro 2012-08-28 12:52:22 -0400 119) if (f.file) {
2903ff019b346 (Al Viro 2012-08-28 12:52:22 -0400 120) error = vfs_statfs(&f.file->f_path, st);
2903ff019b346 (Al Viro 2012-08-28 12:52:22 -0400 121) fdput(f);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 122) }
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 123) return error;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 124) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 125)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 126) static int do_statfs_native(struct kstatfs *st, struct statfs __user *p)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 127) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 128) struct statfs buf;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 129)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 130) if (sizeof(buf) == sizeof(*st))
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 131) memcpy(&buf, st, sizeof(*st));
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 132) else {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 133) if (sizeof buf.f_blocks == 4) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 134) if ((st->f_blocks | st->f_bfree | st->f_bavail |
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 135) st->f_bsize | st->f_frsize) &
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 136) 0xffffffff00000000ULL)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 137) return -EOVERFLOW;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 138) /*
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 139) * f_files and f_ffree may be -1; it's okay to stuff
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 140) * that into 32 bits
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 141) */
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 142) if (st->f_files != -1 &&
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 143) (st->f_files & 0xffffffff00000000ULL))
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 144) return -EOVERFLOW;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 145) if (st->f_ffree != -1 &&
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 146) (st->f_ffree & 0xffffffff00000000ULL))
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 147) return -EOVERFLOW;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 148) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 149)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 150) buf.f_type = st->f_type;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 151) buf.f_bsize = st->f_bsize;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 152) buf.f_blocks = st->f_blocks;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 153) buf.f_bfree = st->f_bfree;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 154) buf.f_bavail = st->f_bavail;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 155) buf.f_files = st->f_files;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 156) buf.f_ffree = st->f_ffree;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 157) buf.f_fsid = st->f_fsid;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 158) buf.f_namelen = st->f_namelen;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 159) buf.f_frsize = st->f_frsize;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 160) buf.f_flags = st->f_flags;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 161) memset(buf.f_spare, 0, sizeof(buf.f_spare));
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 162) }
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 163) if (copy_to_user(p, &buf, sizeof(buf)))
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 164) return -EFAULT;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 165) return 0;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 166) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 167)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 168) static int do_statfs64(struct kstatfs *st, struct statfs64 __user *p)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 169) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 170) struct statfs64 buf;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 171) if (sizeof(buf) == sizeof(*st))
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 172) memcpy(&buf, st, sizeof(*st));
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 173) else {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 174) buf.f_type = st->f_type;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 175) buf.f_bsize = st->f_bsize;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 176) buf.f_blocks = st->f_blocks;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 177) buf.f_bfree = st->f_bfree;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 178) buf.f_bavail = st->f_bavail;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 179) buf.f_files = st->f_files;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 180) buf.f_ffree = st->f_ffree;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 181) buf.f_fsid = st->f_fsid;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 182) buf.f_namelen = st->f_namelen;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 183) buf.f_frsize = st->f_frsize;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 184) buf.f_flags = st->f_flags;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 185) memset(buf.f_spare, 0, sizeof(buf.f_spare));
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 186) }
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 187) if (copy_to_user(p, &buf, sizeof(buf)))
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 188) return -EFAULT;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 189) return 0;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 190) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 191)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 192) SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, buf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 193) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 194) struct kstatfs st;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 195) int error = user_statfs(pathname, &st);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 196) if (!error)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 197) error = do_statfs_native(&st, buf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 198) return error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 199) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 200)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 201) SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 202) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 203) struct kstatfs st;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 204) int error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 205) if (sz != sizeof(*buf))
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 206) return -EINVAL;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 207) error = user_statfs(pathname, &st);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 208) if (!error)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 209) error = do_statfs64(&st, buf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 210) return error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 211) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 212)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 213) SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 214) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 215) struct kstatfs st;
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 216) int error = fd_statfs(fd, &st);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 217) if (!error)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 218) error = do_statfs_native(&st, buf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 219) return error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 220) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 221)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 222) SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user *, buf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 223) {
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 224) struct kstatfs st;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 225) int error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 226)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 227) if (sz != sizeof(*buf))
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 228) return -EINVAL;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 229)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 230) error = fd_statfs(fd, &st);
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 231) if (!error)
c8b91accfa105 (Al Viro 2011-03-12 10:41:39 -0500 232) error = do_statfs64(&st, buf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 233) return error;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 234) }
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 235)
53fd88ab61948 (Al Viro 2017-10-14 23:00:54 -0400 236) static int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 237) {
4e7b5671c6a88 (Christoph Hellwig 2020-11-23 13:38:40 +0100 238) struct super_block *s = user_get_super(dev, false);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 239) int err;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 240) if (!s)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 241) return -EINVAL;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 242)
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 243) err = statfs_by_dentry(s->s_root, sbuf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 244) drop_super(s);
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 245) return err;
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 246) }
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 247)
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 248) SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 249) {
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 250) struct ustat tmp;
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 251) struct kstatfs sbuf;
cf31e70d6cf93 (Al Viro 2012-01-02 22:28:36 -0500 252) int err = vfs_ustat(new_decode_dev(dev), &sbuf);
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 253) if (err)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 254) return err;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 255)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 256) memset(&tmp,0,sizeof(struct ustat));
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 257) tmp.f_tfree = sbuf.f_bfree;
96c0a6a72d181 (Heiko Carstens 2021-02-10 21:51:02 +0100 258) if (IS_ENABLED(CONFIG_ARCH_32BIT_USTAT_F_TINODE))
96c0a6a72d181 (Heiko Carstens 2021-02-10 21:51:02 +0100 259) tmp.f_tinode = min_t(u64, sbuf.f_ffree, UINT_MAX);
96c0a6a72d181 (Heiko Carstens 2021-02-10 21:51:02 +0100 260) else
96c0a6a72d181 (Heiko Carstens 2021-02-10 21:51:02 +0100 261) tmp.f_tinode = sbuf.f_ffree;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 262)
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 263) return copy_to_user(ubuf, &tmp, sizeof(struct ustat)) ? -EFAULT : 0;
7ed1ee6118ae7 (Al Viro 2010-03-23 10:37:36 -0400 264) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 265)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 266) #ifdef CONFIG_COMPAT
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 267) static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs *kbuf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 268) {
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 269) struct compat_statfs buf;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 270) if (sizeof ubuf->f_blocks == 4) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 271) if ((kbuf->f_blocks | kbuf->f_bfree | kbuf->f_bavail |
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 272) kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 273) return -EOVERFLOW;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 274) /* f_files and f_ffree may be -1; it's okay
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 275) * to stuff that into 32 bits */
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 276) if (kbuf->f_files != 0xffffffffffffffffULL
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 277) && (kbuf->f_files & 0xffffffff00000000ULL))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 278) return -EOVERFLOW;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 279) if (kbuf->f_ffree != 0xffffffffffffffffULL
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 280) && (kbuf->f_ffree & 0xffffffff00000000ULL))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 281) return -EOVERFLOW;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 282) }
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 283) memset(&buf, 0, sizeof(struct compat_statfs));
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 284) buf.f_type = kbuf->f_type;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 285) buf.f_bsize = kbuf->f_bsize;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 286) buf.f_blocks = kbuf->f_blocks;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 287) buf.f_bfree = kbuf->f_bfree;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 288) buf.f_bavail = kbuf->f_bavail;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 289) buf.f_files = kbuf->f_files;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 290) buf.f_ffree = kbuf->f_ffree;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 291) buf.f_namelen = kbuf->f_namelen;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 292) buf.f_fsid.val[0] = kbuf->f_fsid.val[0];
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 293) buf.f_fsid.val[1] = kbuf->f_fsid.val[1];
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 294) buf.f_frsize = kbuf->f_frsize;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 295) buf.f_flags = kbuf->f_flags;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 296) if (copy_to_user(ubuf, &buf, sizeof(struct compat_statfs)))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 297) return -EFAULT;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 298) return 0;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 299) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 300)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 301) /*
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 302) * The following statfs calls are copies of code from fs/statfs.c and
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 303) * should be checked against those from time to time
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 304) */
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 305) COMPAT_SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct compat_statfs __user *, buf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 306) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 307) struct kstatfs tmp;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 308) int error = user_statfs(pathname, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 309) if (!error)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 310) error = put_compat_statfs(buf, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 311) return error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 312) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 313)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 314) COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *, buf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 315) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 316) struct kstatfs tmp;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 317) int error = fd_statfs(fd, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 318) if (!error)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 319) error = put_compat_statfs(buf, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 320) return error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 321) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 322)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 323) static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 324) {
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 325) struct compat_statfs64 buf;
cc3a7bfe62b94 (Eric Sandeen 2019-10-02 16:17:54 -0500 326)
cc3a7bfe62b94 (Eric Sandeen 2019-10-02 16:17:54 -0500 327) if ((kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL)
cc3a7bfe62b94 (Eric Sandeen 2019-10-02 16:17:54 -0500 328) return -EOVERFLOW;
cc3a7bfe62b94 (Eric Sandeen 2019-10-02 16:17:54 -0500 329)
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 330) memset(&buf, 0, sizeof(struct compat_statfs64));
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 331) buf.f_type = kbuf->f_type;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 332) buf.f_bsize = kbuf->f_bsize;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 333) buf.f_blocks = kbuf->f_blocks;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 334) buf.f_bfree = kbuf->f_bfree;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 335) buf.f_bavail = kbuf->f_bavail;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 336) buf.f_files = kbuf->f_files;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 337) buf.f_ffree = kbuf->f_ffree;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 338) buf.f_namelen = kbuf->f_namelen;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 339) buf.f_fsid.val[0] = kbuf->f_fsid.val[0];
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 340) buf.f_fsid.val[1] = kbuf->f_fsid.val[1];
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 341) buf.f_frsize = kbuf->f_frsize;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 342) buf.f_flags = kbuf->f_flags;
ae2a9762d6f54 (Al Viro 2017-06-03 21:41:51 -0400 343) if (copy_to_user(ubuf, &buf, sizeof(struct compat_statfs64)))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 344) return -EFAULT;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 345) return 0;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 346) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 347)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 348) int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz, struct compat_statfs64 __user * buf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 349) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 350) struct kstatfs tmp;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 351) int error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 352)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 353) if (sz != sizeof(*buf))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 354) return -EINVAL;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 355)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 356) error = user_statfs(pathname, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 357) if (!error)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 358) error = put_compat_statfs64(buf, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 359) return error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 360) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 361)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 362) COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 363) {
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 364) return kcompat_sys_statfs64(pathname, sz, buf);
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 365) }
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 366)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 367) int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user * buf)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 368) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 369) struct kstatfs tmp;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 370) int error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 371)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 372) if (sz != sizeof(*buf))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 373) return -EINVAL;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 374)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 375) error = fd_statfs(fd, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 376) if (!error)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 377) error = put_compat_statfs64(buf, &tmp);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 378) return error;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 379) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 380)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 381) COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf)
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 382) {
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 383) return kcompat_sys_fstatfs64(fd, sz, buf);
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 384) }
9b54bf9d6a5b3 (Mark Rutland 2018-07-11 14:56:51 +0100 385)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 386) /*
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 387) * This is a copy of sys_ustat, just dealing with a structure layout.
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 388) * Given how simple this syscall is that apporach is more maintainable
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 389) * than the various conversion hacks.
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 390) */
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 391) COMPAT_SYSCALL_DEFINE2(ustat, unsigned, dev, struct compat_ustat __user *, u)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 392) {
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 393) struct compat_ustat tmp;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 394) struct kstatfs sbuf;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 395) int err = vfs_ustat(new_decode_dev(dev), &sbuf);
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 396) if (err)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 397) return err;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 398)
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 399) memset(&tmp, 0, sizeof(struct compat_ustat));
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 400) tmp.f_tfree = sbuf.f_bfree;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 401) tmp.f_tinode = sbuf.f_ffree;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 402) if (copy_to_user(u, &tmp, sizeof(struct compat_ustat)))
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 403) return -EFAULT;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 404) return 0;
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 405) }
4ada54ee7a4b7 (Al Viro 2017-04-08 18:08:15 -0400 406) #endif