Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
13ba33e8
Commit
13ba33e8
authored
Aug 18, 2014
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch /dev/zero and /dev/full to ->read_iter()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
a1f6dbac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
43 deletions
+13
-43
drivers/char/mem.c
drivers/char/mem.c
+13
-43
No files found.
drivers/char/mem.c
View file @
13ba33e8
...
...
@@ -622,53 +622,23 @@ static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
return
splice_from_pipe
(
pipe
,
out
,
ppos
,
len
,
flags
,
pipe_to_null
);
}
static
ssize_t
read_zero
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
static
ssize_t
read_iter_zero
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
iter
)
{
size_t
written
;
if
(
!
count
)
return
0
;
if
(
!
access_ok
(
VERIFY_WRITE
,
buf
,
count
))
return
-
EFAULT
;
written
=
0
;
while
(
count
)
{
unsigned
long
unwritten
;
size_t
chunk
=
count
;
size_t
written
=
0
;
while
(
iov_iter_count
(
iter
))
{
size_t
chunk
=
iov_iter_count
(
iter
),
n
;
if
(
chunk
>
PAGE_SIZE
)
chunk
=
PAGE_SIZE
;
/* Just for latency reasons */
unwritten
=
__clear_user
(
buf
,
chunk
);
written
+=
chunk
-
unwritten
;
if
(
unwritten
)
break
;
n
=
iov_iter_zero
(
chunk
,
iter
);
if
(
!
n
&&
iov_iter_count
(
iter
))
return
written
?
written
:
-
EFAULT
;
written
+=
n
;
if
(
signal_pending
(
current
))
return
written
?
written
:
-
ERESTARTSYS
;
buf
+=
chunk
;
count
-=
chunk
;
cond_resched
();
}
return
written
?
written
:
-
EFAULT
;
}
static
ssize_t
aio_read_zero
(
struct
kiocb
*
iocb
,
const
struct
iovec
*
iov
,
unsigned
long
nr_segs
,
loff_t
pos
)
{
size_t
written
=
0
;
unsigned
long
i
;
ssize_t
ret
;
for
(
i
=
0
;
i
<
nr_segs
;
i
++
)
{
ret
=
read_zero
(
iocb
->
ki_filp
,
iov
[
i
].
iov_base
,
iov
[
i
].
iov_len
,
&
pos
);
if
(
ret
<
0
)
break
;
written
+=
ret
;
}
return
written
?
written
:
-
EFAULT
;
return
written
;
}
static
int
mmap_zero
(
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
...
...
@@ -738,7 +708,6 @@ static int open_port(struct inode *inode, struct file *filp)
#define zero_lseek null_lseek
#define full_lseek null_lseek
#define write_zero write_null
#define read_full read_zero
#define aio_write_zero aio_write_null
#define open_mem open_port
#define open_kmem open_mem
...
...
@@ -783,9 +752,9 @@ static const struct file_operations port_fops = {
static
const
struct
file_operations
zero_fops
=
{
.
llseek
=
zero_lseek
,
.
read
=
read_zero
,
.
read
=
new_sync_read
,
.
write
=
write_zero
,
.
aio_read
=
aio_read
_zero
,
.
read_iter
=
read_iter
_zero
,
.
aio_write
=
aio_write_zero
,
.
mmap
=
mmap_zero
,
};
...
...
@@ -802,7 +771,8 @@ static struct backing_dev_info zero_bdi = {
static
const
struct
file_operations
full_fops
=
{
.
llseek
=
full_lseek
,
.
read
=
read_full
,
.
read
=
new_sync_read
,
.
read_iter
=
read_iter_zero
,
.
write
=
write_full
,
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment