30
28
#include <linux/audit.h>
31
29
#include <linux/falloc.h>
32
30
#include <linux/fs_struct.h>
34
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
40
if (dentry->d_sb->s_op->statfs) {
41
memset(buf, 0, sizeof(*buf));
42
retval = security_sb_statfs(dentry);
45
retval = dentry->d_sb->s_op->statfs(dentry, buf);
46
if (retval == 0 && buf->f_frsize == 0)
47
buf->f_frsize = buf->f_bsize;
53
EXPORT_SYMBOL(vfs_statfs);
55
static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
60
retval = vfs_statfs(dentry, &st);
64
if (sizeof(*buf) == sizeof(st))
65
memcpy(buf, &st, sizeof(st));
67
if (sizeof buf->f_blocks == 4) {
68
if ((st.f_blocks | st.f_bfree | st.f_bavail |
69
st.f_bsize | st.f_frsize) &
70
0xffffffff00000000ULL)
73
* f_files and f_ffree may be -1; it's okay to stuff
76
if (st.f_files != -1 &&
77
(st.f_files & 0xffffffff00000000ULL))
79
if (st.f_ffree != -1 &&
80
(st.f_ffree & 0xffffffff00000000ULL))
84
buf->f_type = st.f_type;
85
buf->f_bsize = st.f_bsize;
86
buf->f_blocks = st.f_blocks;
87
buf->f_bfree = st.f_bfree;
88
buf->f_bavail = st.f_bavail;
89
buf->f_files = st.f_files;
90
buf->f_ffree = st.f_ffree;
91
buf->f_fsid = st.f_fsid;
92
buf->f_namelen = st.f_namelen;
93
buf->f_frsize = st.f_frsize;
94
memset(buf->f_spare, 0, sizeof(buf->f_spare));
99
static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf)
104
retval = vfs_statfs(dentry, &st);
108
if (sizeof(*buf) == sizeof(st))
109
memcpy(buf, &st, sizeof(st));
111
buf->f_type = st.f_type;
112
buf->f_bsize = st.f_bsize;
113
buf->f_blocks = st.f_blocks;
114
buf->f_bfree = st.f_bfree;
115
buf->f_bavail = st.f_bavail;
116
buf->f_files = st.f_files;
117
buf->f_ffree = st.f_ffree;
118
buf->f_fsid = st.f_fsid;
119
buf->f_namelen = st.f_namelen;
120
buf->f_frsize = st.f_frsize;
121
memset(buf->f_spare, 0, sizeof(buf->f_spare));
126
SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, buf)
131
error = user_path(pathname, &path);
134
error = vfs_statfs_native(path.dentry, &tmp);
135
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
142
SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf)
147
if (sz != sizeof(*buf))
149
error = user_path(pathname, &path);
152
error = vfs_statfs64(path.dentry, &tmp);
153
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
160
SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf)
170
error = vfs_statfs_native(file->f_path.dentry, &tmp);
171
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
178
SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user *, buf)
184
if (sz != sizeof(*buf))
191
error = vfs_statfs64(file->f_path.dentry, &tmp);
192
if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
31
#include <linux/ima.h>
32
#include <linux/dnotify.h>
199
36
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
200
37
struct file *filp)
933
792
* Note that this function destroys the original nameidata
935
struct file *nameidata_to_filp(struct nameidata *nd, int flags)
794
struct file *nameidata_to_filp(struct nameidata *nd)
937
796
const struct cred *cred = current_cred();
938
797
struct file *filp;
940
799
/* Pick up the filp from the open intent */
941
800
filp = nd->intent.open.file;
801
nd->intent.open.file = NULL;
942
803
/* Has the filesystem initialised the file for us? */
943
if (filp->f_path.dentry == NULL)
944
filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
804
if (filp->f_path.dentry == NULL) {
806
filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,