Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
7ed1ee61
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
153
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ed1ee61
编写于
3月 23, 2010
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Take statfs variants to fs/statfs.c
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
e8c26255
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
197 addition
and
192 deletion
+197
-192
fs/Makefile
fs/Makefile
+1
-1
fs/open.c
fs/open.c
+0
-166
fs/statfs.c
fs/statfs.c
+196
-0
fs/super.c
fs/super.c
+0
-25
未找到文件。
fs/Makefile
浏览文件 @
7ed1ee61
...
...
@@ -11,7 +11,7 @@ obj-y := open.o read_write.o file_table.o super.o \
attr.o bad_inode.o file.o filesystems.o namespace.o
\
seq_file.o xattr.o libfs.o fs-writeback.o
\
pnode.o drop_caches.o splice.o sync.o utimes.o
\
stack.o fs_struct.o
stack.o fs_struct.o
statfs.o
ifeq
($(CONFIG_BLOCK),y)
obj-y
+=
buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
...
...
fs/open.c
浏览文件 @
7ed1ee61
...
...
@@ -17,7 +17,6 @@
#include <linux/securebits.h>
#include <linux/security.h>
#include <linux/mount.h>
#include <linux/vfs.h>
#include <linux/fcntl.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
...
...
@@ -33,171 +32,6 @@
#include "internal.h"
int
vfs_statfs
(
struct
dentry
*
dentry
,
struct
kstatfs
*
buf
)
{
int
retval
=
-
ENODEV
;
if
(
dentry
)
{
retval
=
-
ENOSYS
;
if
(
dentry
->
d_sb
->
s_op
->
statfs
)
{
memset
(
buf
,
0
,
sizeof
(
*
buf
));
retval
=
security_sb_statfs
(
dentry
);
if
(
retval
)
return
retval
;
retval
=
dentry
->
d_sb
->
s_op
->
statfs
(
dentry
,
buf
);
if
(
retval
==
0
&&
buf
->
f_frsize
==
0
)
buf
->
f_frsize
=
buf
->
f_bsize
;
}
}
return
retval
;
}
EXPORT_SYMBOL
(
vfs_statfs
);
static
int
vfs_statfs_native
(
struct
dentry
*
dentry
,
struct
statfs
*
buf
)
{
struct
kstatfs
st
;
int
retval
;
retval
=
vfs_statfs
(
dentry
,
&
st
);
if
(
retval
)
return
retval
;
if
(
sizeof
(
*
buf
)
==
sizeof
(
st
))
memcpy
(
buf
,
&
st
,
sizeof
(
st
));
else
{
if
(
sizeof
buf
->
f_blocks
==
4
)
{
if
((
st
.
f_blocks
|
st
.
f_bfree
|
st
.
f_bavail
|
st
.
f_bsize
|
st
.
f_frsize
)
&
0xffffffff00000000ULL
)
return
-
EOVERFLOW
;
/*
* f_files and f_ffree may be -1; it's okay to stuff
* that into 32 bits
*/
if
(
st
.
f_files
!=
-
1
&&
(
st
.
f_files
&
0xffffffff00000000ULL
))
return
-
EOVERFLOW
;
if
(
st
.
f_ffree
!=
-
1
&&
(
st
.
f_ffree
&
0xffffffff00000000ULL
))
return
-
EOVERFLOW
;
}
buf
->
f_type
=
st
.
f_type
;
buf
->
f_bsize
=
st
.
f_bsize
;
buf
->
f_blocks
=
st
.
f_blocks
;
buf
->
f_bfree
=
st
.
f_bfree
;
buf
->
f_bavail
=
st
.
f_bavail
;
buf
->
f_files
=
st
.
f_files
;
buf
->
f_ffree
=
st
.
f_ffree
;
buf
->
f_fsid
=
st
.
f_fsid
;
buf
->
f_namelen
=
st
.
f_namelen
;
buf
->
f_frsize
=
st
.
f_frsize
;
memset
(
buf
->
f_spare
,
0
,
sizeof
(
buf
->
f_spare
));
}
return
0
;
}
static
int
vfs_statfs64
(
struct
dentry
*
dentry
,
struct
statfs64
*
buf
)
{
struct
kstatfs
st
;
int
retval
;
retval
=
vfs_statfs
(
dentry
,
&
st
);
if
(
retval
)
return
retval
;
if
(
sizeof
(
*
buf
)
==
sizeof
(
st
))
memcpy
(
buf
,
&
st
,
sizeof
(
st
));
else
{
buf
->
f_type
=
st
.
f_type
;
buf
->
f_bsize
=
st
.
f_bsize
;
buf
->
f_blocks
=
st
.
f_blocks
;
buf
->
f_bfree
=
st
.
f_bfree
;
buf
->
f_bavail
=
st
.
f_bavail
;
buf
->
f_files
=
st
.
f_files
;
buf
->
f_ffree
=
st
.
f_ffree
;
buf
->
f_fsid
=
st
.
f_fsid
;
buf
->
f_namelen
=
st
.
f_namelen
;
buf
->
f_frsize
=
st
.
f_frsize
;
memset
(
buf
->
f_spare
,
0
,
sizeof
(
buf
->
f_spare
));
}
return
0
;
}
SYSCALL_DEFINE2
(
statfs
,
const
char
__user
*
,
pathname
,
struct
statfs
__user
*
,
buf
)
{
struct
path
path
;
int
error
;
error
=
user_path
(
pathname
,
&
path
);
if
(
!
error
)
{
struct
statfs
tmp
;
error
=
vfs_statfs_native
(
path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
path_put
(
&
path
);
}
return
error
;
}
SYSCALL_DEFINE3
(
statfs64
,
const
char
__user
*
,
pathname
,
size_t
,
sz
,
struct
statfs64
__user
*
,
buf
)
{
struct
path
path
;
long
error
;
if
(
sz
!=
sizeof
(
*
buf
))
return
-
EINVAL
;
error
=
user_path
(
pathname
,
&
path
);
if
(
!
error
)
{
struct
statfs64
tmp
;
error
=
vfs_statfs64
(
path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
path_put
(
&
path
);
}
return
error
;
}
SYSCALL_DEFINE2
(
fstatfs
,
unsigned
int
,
fd
,
struct
statfs
__user
*
,
buf
)
{
struct
file
*
file
;
struct
statfs
tmp
;
int
error
;
error
=
-
EBADF
;
file
=
fget
(
fd
);
if
(
!
file
)
goto
out
;
error
=
vfs_statfs_native
(
file
->
f_path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
fput
(
file
);
out:
return
error
;
}
SYSCALL_DEFINE3
(
fstatfs64
,
unsigned
int
,
fd
,
size_t
,
sz
,
struct
statfs64
__user
*
,
buf
)
{
struct
file
*
file
;
struct
statfs64
tmp
;
int
error
;
if
(
sz
!=
sizeof
(
*
buf
))
return
-
EINVAL
;
error
=
-
EBADF
;
file
=
fget
(
fd
);
if
(
!
file
)
goto
out
;
error
=
vfs_statfs64
(
file
->
f_path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
fput
(
file
);
out:
return
error
;
}
int
do_truncate
(
struct
dentry
*
dentry
,
loff_t
length
,
unsigned
int
time_attrs
,
struct
file
*
filp
)
{
...
...
fs/statfs.c
0 → 100644
浏览文件 @
7ed1ee61
#include <linux/syscalls.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/namei.h>
#include <linux/statfs.h>
#include <linux/security.h>
#include <linux/uaccess.h>
int
vfs_statfs
(
struct
dentry
*
dentry
,
struct
kstatfs
*
buf
)
{
int
retval
=
-
ENODEV
;
if
(
dentry
)
{
retval
=
-
ENOSYS
;
if
(
dentry
->
d_sb
->
s_op
->
statfs
)
{
memset
(
buf
,
0
,
sizeof
(
*
buf
));
retval
=
security_sb_statfs
(
dentry
);
if
(
retval
)
return
retval
;
retval
=
dentry
->
d_sb
->
s_op
->
statfs
(
dentry
,
buf
);
if
(
retval
==
0
&&
buf
->
f_frsize
==
0
)
buf
->
f_frsize
=
buf
->
f_bsize
;
}
}
return
retval
;
}
EXPORT_SYMBOL
(
vfs_statfs
);
static
int
vfs_statfs_native
(
struct
dentry
*
dentry
,
struct
statfs
*
buf
)
{
struct
kstatfs
st
;
int
retval
;
retval
=
vfs_statfs
(
dentry
,
&
st
);
if
(
retval
)
return
retval
;
if
(
sizeof
(
*
buf
)
==
sizeof
(
st
))
memcpy
(
buf
,
&
st
,
sizeof
(
st
));
else
{
if
(
sizeof
buf
->
f_blocks
==
4
)
{
if
((
st
.
f_blocks
|
st
.
f_bfree
|
st
.
f_bavail
|
st
.
f_bsize
|
st
.
f_frsize
)
&
0xffffffff00000000ULL
)
return
-
EOVERFLOW
;
/*
* f_files and f_ffree may be -1; it's okay to stuff
* that into 32 bits
*/
if
(
st
.
f_files
!=
-
1
&&
(
st
.
f_files
&
0xffffffff00000000ULL
))
return
-
EOVERFLOW
;
if
(
st
.
f_ffree
!=
-
1
&&
(
st
.
f_ffree
&
0xffffffff00000000ULL
))
return
-
EOVERFLOW
;
}
buf
->
f_type
=
st
.
f_type
;
buf
->
f_bsize
=
st
.
f_bsize
;
buf
->
f_blocks
=
st
.
f_blocks
;
buf
->
f_bfree
=
st
.
f_bfree
;
buf
->
f_bavail
=
st
.
f_bavail
;
buf
->
f_files
=
st
.
f_files
;
buf
->
f_ffree
=
st
.
f_ffree
;
buf
->
f_fsid
=
st
.
f_fsid
;
buf
->
f_namelen
=
st
.
f_namelen
;
buf
->
f_frsize
=
st
.
f_frsize
;
memset
(
buf
->
f_spare
,
0
,
sizeof
(
buf
->
f_spare
));
}
return
0
;
}
static
int
vfs_statfs64
(
struct
dentry
*
dentry
,
struct
statfs64
*
buf
)
{
struct
kstatfs
st
;
int
retval
;
retval
=
vfs_statfs
(
dentry
,
&
st
);
if
(
retval
)
return
retval
;
if
(
sizeof
(
*
buf
)
==
sizeof
(
st
))
memcpy
(
buf
,
&
st
,
sizeof
(
st
));
else
{
buf
->
f_type
=
st
.
f_type
;
buf
->
f_bsize
=
st
.
f_bsize
;
buf
->
f_blocks
=
st
.
f_blocks
;
buf
->
f_bfree
=
st
.
f_bfree
;
buf
->
f_bavail
=
st
.
f_bavail
;
buf
->
f_files
=
st
.
f_files
;
buf
->
f_ffree
=
st
.
f_ffree
;
buf
->
f_fsid
=
st
.
f_fsid
;
buf
->
f_namelen
=
st
.
f_namelen
;
buf
->
f_frsize
=
st
.
f_frsize
;
memset
(
buf
->
f_spare
,
0
,
sizeof
(
buf
->
f_spare
));
}
return
0
;
}
SYSCALL_DEFINE2
(
statfs
,
const
char
__user
*
,
pathname
,
struct
statfs
__user
*
,
buf
)
{
struct
path
path
;
int
error
;
error
=
user_path
(
pathname
,
&
path
);
if
(
!
error
)
{
struct
statfs
tmp
;
error
=
vfs_statfs_native
(
path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
path_put
(
&
path
);
}
return
error
;
}
SYSCALL_DEFINE3
(
statfs64
,
const
char
__user
*
,
pathname
,
size_t
,
sz
,
struct
statfs64
__user
*
,
buf
)
{
struct
path
path
;
long
error
;
if
(
sz
!=
sizeof
(
*
buf
))
return
-
EINVAL
;
error
=
user_path
(
pathname
,
&
path
);
if
(
!
error
)
{
struct
statfs64
tmp
;
error
=
vfs_statfs64
(
path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
path_put
(
&
path
);
}
return
error
;
}
SYSCALL_DEFINE2
(
fstatfs
,
unsigned
int
,
fd
,
struct
statfs
__user
*
,
buf
)
{
struct
file
*
file
;
struct
statfs
tmp
;
int
error
;
error
=
-
EBADF
;
file
=
fget
(
fd
);
if
(
!
file
)
goto
out
;
error
=
vfs_statfs_native
(
file
->
f_path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
fput
(
file
);
out:
return
error
;
}
SYSCALL_DEFINE3
(
fstatfs64
,
unsigned
int
,
fd
,
size_t
,
sz
,
struct
statfs64
__user
*
,
buf
)
{
struct
file
*
file
;
struct
statfs64
tmp
;
int
error
;
if
(
sz
!=
sizeof
(
*
buf
))
return
-
EINVAL
;
error
=
-
EBADF
;
file
=
fget
(
fd
);
if
(
!
file
)
goto
out
;
error
=
vfs_statfs64
(
file
->
f_path
.
dentry
,
&
tmp
);
if
(
!
error
&&
copy_to_user
(
buf
,
&
tmp
,
sizeof
(
tmp
)))
error
=
-
EFAULT
;
fput
(
file
);
out:
return
error
;
}
SYSCALL_DEFINE2
(
ustat
,
unsigned
,
dev
,
struct
ustat
__user
*
,
ubuf
)
{
struct
super_block
*
s
;
struct
ustat
tmp
;
struct
kstatfs
sbuf
;
int
err
;
s
=
user_get_super
(
new_decode_dev
(
dev
));
if
(
!
s
)
return
-
EINVAL
;
err
=
vfs_statfs
(
s
->
s_root
,
&
sbuf
);
drop_super
(
s
);
if
(
err
)
return
err
;
memset
(
&
tmp
,
0
,
sizeof
(
struct
ustat
));
tmp
.
f_tfree
=
sbuf
.
f_bfree
;
tmp
.
f_tinode
=
sbuf
.
f_ffree
;
return
copy_to_user
(
ubuf
,
&
tmp
,
sizeof
(
struct
ustat
))
?
-
EFAULT
:
0
;
}
fs/super.c
浏览文件 @
7ed1ee61
...
...
@@ -31,7 +31,6 @@
#include <linux/mount.h>
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/vfs.h>
#include <linux/writeback.h>
/* for the emergency remount stuff */
#include <linux/idr.h>
#include <linux/kobject.h>
...
...
@@ -519,30 +518,6 @@ struct super_block *user_get_super(dev_t dev)
return
NULL
;
}
SYSCALL_DEFINE2
(
ustat
,
unsigned
,
dev
,
struct
ustat
__user
*
,
ubuf
)
{
struct
super_block
*
s
;
struct
ustat
tmp
;
struct
kstatfs
sbuf
;
int
err
=
-
EINVAL
;
s
=
user_get_super
(
new_decode_dev
(
dev
));
if
(
s
==
NULL
)
goto
out
;
err
=
vfs_statfs
(
s
->
s_root
,
&
sbuf
);
drop_super
(
s
);
if
(
err
)
goto
out
;
memset
(
&
tmp
,
0
,
sizeof
(
struct
ustat
));
tmp
.
f_tfree
=
sbuf
.
f_bfree
;
tmp
.
f_tinode
=
sbuf
.
f_ffree
;
err
=
copy_to_user
(
ubuf
,
&
tmp
,
sizeof
(
struct
ustat
))
?
-
EFAULT
:
0
;
out:
return
err
;
}
/**
* do_remount_sb - asks filesystem to change mount options.
* @sb: superblock in question
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录