Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
7bb307e8
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
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,发现更多精彩内容 >>
提交
7bb307e8
编写于
2月 23, 2013
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
export kernel_write(), convert open-coded instances
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
94e07a75
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
24 addition
and
61 deletion
+24
-61
drivers/mtd/nand/nandsim.c
drivers/mtd/nand/nandsim.c
+12
-22
fs/ecryptfs/read_write.c
fs/ecryptfs/read_write.c
+1
-5
fs/splice.c
fs/splice.c
+3
-2
include/linux/fs.h
include/linux/fs.h
+1
-0
kernel/sysctl_binary.c
kernel/sysctl_binary.c
+7
-32
未找到文件。
drivers/mtd/nand/nandsim.c
浏览文件 @
7bb307e8
...
...
@@ -1408,40 +1408,32 @@ static void clear_memalloc(int memalloc)
current
->
flags
&=
~
PF_MEMALLOC
;
}
static
ssize_t
read_file
(
struct
nandsim
*
ns
,
struct
file
*
file
,
void
*
buf
,
size_t
count
,
loff_t
*
pos
)
static
ssize_t
read_file
(
struct
nandsim
*
ns
,
struct
file
*
file
,
void
*
buf
,
size_t
count
,
loff_t
pos
)
{
mm_segment_t
old_fs
;
ssize_t
tx
;
int
err
,
memalloc
;
err
=
get_pages
(
ns
,
file
,
count
,
*
pos
);
err
=
get_pages
(
ns
,
file
,
count
,
pos
);
if
(
err
)
return
err
;
old_fs
=
get_fs
();
set_fs
(
get_ds
());
memalloc
=
set_memalloc
();
tx
=
vfs_read
(
file
,
(
char
__user
*
)
buf
,
count
,
pos
);
tx
=
kernel_read
(
file
,
pos
,
buf
,
count
);
clear_memalloc
(
memalloc
);
set_fs
(
old_fs
);
put_pages
(
ns
);
return
tx
;
}
static
ssize_t
write_file
(
struct
nandsim
*
ns
,
struct
file
*
file
,
void
*
buf
,
size_t
count
,
loff_t
*
pos
)
static
ssize_t
write_file
(
struct
nandsim
*
ns
,
struct
file
*
file
,
void
*
buf
,
size_t
count
,
loff_t
pos
)
{
mm_segment_t
old_fs
;
ssize_t
tx
;
int
err
,
memalloc
;
err
=
get_pages
(
ns
,
file
,
count
,
*
pos
);
err
=
get_pages
(
ns
,
file
,
count
,
pos
);
if
(
err
)
return
err
;
old_fs
=
get_fs
();
set_fs
(
get_ds
());
memalloc
=
set_memalloc
();
tx
=
vfs_write
(
file
,
(
char
__user
*
)
buf
,
count
,
pos
);
tx
=
kernel_write
(
file
,
buf
,
count
,
pos
);
clear_memalloc
(
memalloc
);
set_fs
(
old_fs
);
put_pages
(
ns
);
return
tx
;
}
...
...
@@ -1511,7 +1503,7 @@ static void read_page(struct nandsim *ns, int num)
if
(
do_read_error
(
ns
,
num
))
return
;
pos
=
(
loff_t
)
ns
->
regs
.
row
*
ns
->
geom
.
pgszoob
+
ns
->
regs
.
column
+
ns
->
regs
.
off
;
tx
=
read_file
(
ns
,
ns
->
cfile
,
ns
->
buf
.
byte
,
num
,
&
pos
);
tx
=
read_file
(
ns
,
ns
->
cfile
,
ns
->
buf
.
byte
,
num
,
pos
);
if
(
tx
!=
num
)
{
NS_ERR
(
"read_page: read error for page %d ret %ld
\n
"
,
ns
->
regs
.
row
,
(
long
)
tx
);
return
;
...
...
@@ -1573,7 +1565,7 @@ static int prog_page(struct nandsim *ns, int num)
u_char
*
pg_off
;
if
(
ns
->
cfile
)
{
loff_t
off
,
pos
;
loff_t
off
;
ssize_t
tx
;
int
all
;
...
...
@@ -1585,8 +1577,7 @@ static int prog_page(struct nandsim *ns, int num)
memset
(
ns
->
file_buf
,
0xff
,
ns
->
geom
.
pgszoob
);
}
else
{
all
=
0
;
pos
=
off
;
tx
=
read_file
(
ns
,
ns
->
cfile
,
pg_off
,
num
,
&
pos
);
tx
=
read_file
(
ns
,
ns
->
cfile
,
pg_off
,
num
,
off
);
if
(
tx
!=
num
)
{
NS_ERR
(
"prog_page: read error for page %d ret %ld
\n
"
,
ns
->
regs
.
row
,
(
long
)
tx
);
return
-
1
;
...
...
@@ -1595,16 +1586,15 @@ static int prog_page(struct nandsim *ns, int num)
for
(
i
=
0
;
i
<
num
;
i
++
)
pg_off
[
i
]
&=
ns
->
buf
.
byte
[
i
];
if
(
all
)
{
pos
=
(
loff_t
)
ns
->
regs
.
row
*
ns
->
geom
.
pgszoob
;
tx
=
write_file
(
ns
,
ns
->
cfile
,
ns
->
file_buf
,
ns
->
geom
.
pgszoob
,
&
pos
);
loff_t
pos
=
(
loff_t
)
ns
->
regs
.
row
*
ns
->
geom
.
pgszoob
;
tx
=
write_file
(
ns
,
ns
->
cfile
,
ns
->
file_buf
,
ns
->
geom
.
pgszoob
,
pos
);
if
(
tx
!=
ns
->
geom
.
pgszoob
)
{
NS_ERR
(
"prog_page: write error for page %d ret %ld
\n
"
,
ns
->
regs
.
row
,
(
long
)
tx
);
return
-
1
;
}
ns
->
pages_written
[
ns
->
regs
.
row
]
=
1
;
}
else
{
pos
=
off
;
tx
=
write_file
(
ns
,
ns
->
cfile
,
pg_off
,
num
,
&
pos
);
tx
=
write_file
(
ns
,
ns
->
cfile
,
pg_off
,
num
,
off
);
if
(
tx
!=
num
)
{
NS_ERR
(
"prog_page: write error for page %d ret %ld
\n
"
,
ns
->
regs
.
row
,
(
long
)
tx
);
return
-
1
;
...
...
fs/ecryptfs/read_write.c
浏览文件 @
7bb307e8
...
...
@@ -40,16 +40,12 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
loff_t
offset
,
size_t
size
)
{
struct
file
*
lower_file
;
mm_segment_t
fs_save
;
ssize_t
rc
;
lower_file
=
ecryptfs_inode_to_private
(
ecryptfs_inode
)
->
lower_file
;
if
(
!
lower_file
)
return
-
EIO
;
fs_save
=
get_fs
();
set_fs
(
get_ds
());
rc
=
vfs_write
(
lower_file
,
data
,
size
,
&
offset
);
set_fs
(
fs_save
);
rc
=
kernel_write
(
lower_file
,
data
,
size
,
offset
);
mark_inode_dirty_sync
(
ecryptfs_inode
);
return
rc
;
}
...
...
fs/splice.c
浏览文件 @
7bb307e8
...
...
@@ -569,7 +569,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
return
res
;
}
s
tatic
s
size_t
kernel_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
ssize_t
kernel_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
pos
)
{
mm_segment_t
old_fs
;
...
...
@@ -578,11 +578,12 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
old_fs
=
get_fs
();
set_fs
(
get_ds
());
/* The cast to a user pointer is valid due to the set_fs() */
res
=
vfs_write
(
file
,
(
const
char
__user
*
)
buf
,
count
,
&
pos
);
res
=
vfs_write
(
file
,
(
__force
const
char
__user
*
)
buf
,
count
,
&
pos
);
set_fs
(
old_fs
);
return
res
;
}
EXPORT_SYMBOL
(
kernel_write
);
ssize_t
default_file_splice_read
(
struct
file
*
in
,
loff_t
*
ppos
,
struct
pipe_inode_info
*
pipe
,
size_t
len
,
...
...
include/linux/fs.h
浏览文件 @
7bb307e8
...
...
@@ -2277,6 +2277,7 @@ static inline void i_readcount_inc(struct inode *inode)
extern
int
do_pipe_flags
(
int
*
,
int
);
extern
int
kernel_read
(
struct
file
*
,
loff_t
,
char
*
,
unsigned
long
);
extern
ssize_t
kernel_write
(
struct
file
*
,
const
char
*
,
size_t
,
loff_t
);
extern
struct
file
*
open_exec
(
const
char
*
);
/* fs/dcache.c -- generic fs support functions */
...
...
kernel/sysctl_binary.c
浏览文件 @
7bb307e8
...
...
@@ -971,7 +971,6 @@ static ssize_t bin_string(struct file *file,
static
ssize_t
bin_intvec
(
struct
file
*
file
,
void
__user
*
oldval
,
size_t
oldlen
,
void
__user
*
newval
,
size_t
newlen
)
{
mm_segment_t
old_fs
=
get_fs
();
ssize_t
copied
=
0
;
char
*
buffer
;
ssize_t
result
;
...
...
@@ -984,13 +983,10 @@ static ssize_t bin_intvec(struct file *file,
if
(
oldval
&&
oldlen
)
{
unsigned
__user
*
vec
=
oldval
;
size_t
length
=
oldlen
/
sizeof
(
*
vec
);
loff_t
pos
=
0
;
char
*
str
,
*
end
;
int
i
;
set_fs
(
KERNEL_DS
);
result
=
vfs_read
(
file
,
buffer
,
BUFSZ
-
1
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_read
(
file
,
0
,
buffer
,
BUFSZ
-
1
);
if
(
result
<
0
)
goto
out_kfree
;
...
...
@@ -1017,7 +1013,6 @@ static ssize_t bin_intvec(struct file *file,
if
(
newval
&&
newlen
)
{
unsigned
__user
*
vec
=
newval
;
size_t
length
=
newlen
/
sizeof
(
*
vec
);
loff_t
pos
=
0
;
char
*
str
,
*
end
;
int
i
;
...
...
@@ -1033,9 +1028,7 @@ static ssize_t bin_intvec(struct file *file,
str
+=
snprintf
(
str
,
end
-
str
,
"%lu
\t
"
,
value
);
}
set_fs
(
KERNEL_DS
);
result
=
vfs_write
(
file
,
buffer
,
str
-
buffer
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_write
(
file
,
buffer
,
str
-
buffer
,
0
);
if
(
result
<
0
)
goto
out_kfree
;
}
...
...
@@ -1049,7 +1042,6 @@ static ssize_t bin_intvec(struct file *file,
static
ssize_t
bin_ulongvec
(
struct
file
*
file
,
void
__user
*
oldval
,
size_t
oldlen
,
void
__user
*
newval
,
size_t
newlen
)
{
mm_segment_t
old_fs
=
get_fs
();
ssize_t
copied
=
0
;
char
*
buffer
;
ssize_t
result
;
...
...
@@ -1062,13 +1054,10 @@ static ssize_t bin_ulongvec(struct file *file,
if
(
oldval
&&
oldlen
)
{
unsigned
long
__user
*
vec
=
oldval
;
size_t
length
=
oldlen
/
sizeof
(
*
vec
);
loff_t
pos
=
0
;
char
*
str
,
*
end
;
int
i
;
set_fs
(
KERNEL_DS
);
result
=
vfs_read
(
file
,
buffer
,
BUFSZ
-
1
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_read
(
file
,
0
,
buffer
,
BUFSZ
-
1
);
if
(
result
<
0
)
goto
out_kfree
;
...
...
@@ -1095,7 +1084,6 @@ static ssize_t bin_ulongvec(struct file *file,
if
(
newval
&&
newlen
)
{
unsigned
long
__user
*
vec
=
newval
;
size_t
length
=
newlen
/
sizeof
(
*
vec
);
loff_t
pos
=
0
;
char
*
str
,
*
end
;
int
i
;
...
...
@@ -1111,9 +1099,7 @@ static ssize_t bin_ulongvec(struct file *file,
str
+=
snprintf
(
str
,
end
-
str
,
"%lu
\t
"
,
value
);
}
set_fs
(
KERNEL_DS
);
result
=
vfs_write
(
file
,
buffer
,
str
-
buffer
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_write
(
file
,
buffer
,
str
-
buffer
,
0
);
if
(
result
<
0
)
goto
out_kfree
;
}
...
...
@@ -1127,19 +1113,15 @@ static ssize_t bin_ulongvec(struct file *file,
static
ssize_t
bin_uuid
(
struct
file
*
file
,
void
__user
*
oldval
,
size_t
oldlen
,
void
__user
*
newval
,
size_t
newlen
)
{
mm_segment_t
old_fs
=
get_fs
();
ssize_t
result
,
copied
=
0
;
/* Only supports reads */
if
(
oldval
&&
oldlen
)
{
loff_t
pos
=
0
;
char
buf
[
40
],
*
str
=
buf
;
unsigned
char
uuid
[
16
];
int
i
;
set_fs
(
KERNEL_DS
);
result
=
vfs_read
(
file
,
buf
,
sizeof
(
buf
)
-
1
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_read
(
file
,
0
,
buf
,
sizeof
(
buf
)
-
1
);
if
(
result
<
0
)
goto
out
;
...
...
@@ -1175,18 +1157,14 @@ static ssize_t bin_uuid(struct file *file,
static
ssize_t
bin_dn_node_address
(
struct
file
*
file
,
void
__user
*
oldval
,
size_t
oldlen
,
void
__user
*
newval
,
size_t
newlen
)
{
mm_segment_t
old_fs
=
get_fs
();
ssize_t
result
,
copied
=
0
;
if
(
oldval
&&
oldlen
)
{
loff_t
pos
=
0
;
char
buf
[
15
],
*
nodep
;
unsigned
long
area
,
node
;
__le16
dnaddr
;
set_fs
(
KERNEL_DS
);
result
=
vfs_read
(
file
,
buf
,
sizeof
(
buf
)
-
1
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_read
(
file
,
0
,
buf
,
sizeof
(
buf
)
-
1
);
if
(
result
<
0
)
goto
out
;
...
...
@@ -1215,7 +1193,6 @@ static ssize_t bin_dn_node_address(struct file *file,
}
if
(
newval
&&
newlen
)
{
loff_t
pos
=
0
;
__le16
dnaddr
;
char
buf
[
15
];
int
len
;
...
...
@@ -1232,9 +1209,7 @@ static ssize_t bin_dn_node_address(struct file *file,
le16_to_cpu
(
dnaddr
)
>>
10
,
le16_to_cpu
(
dnaddr
)
&
0x3ff
);
set_fs
(
KERNEL_DS
);
result
=
vfs_write
(
file
,
buf
,
len
,
&
pos
);
set_fs
(
old_fs
);
result
=
kernel_write
(
file
,
buf
,
len
,
0
);
if
(
result
<
0
)
goto
out
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录