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
e91a9a7d
Commit
e91a9a7d
authored
Apr 09, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up types and remove unnecessary casts from fs/readdir.c.
Add user pointer annotations.
parent
5edf8b9a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
fs/readdir.c
fs/readdir.c
+17
-18
No files found.
fs/readdir.c
View file @
e91a9a7d
...
@@ -58,7 +58,7 @@ struct old_linux_dirent {
...
@@ -58,7 +58,7 @@ struct old_linux_dirent {
};
};
struct
readdir_callback
{
struct
readdir_callback
{
struct
old_linux_dirent
*
dirent
;
struct
old_linux_dirent
__user
*
dirent
;
int
count
;
int
count
;
};
};
...
@@ -66,7 +66,7 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
...
@@ -66,7 +66,7 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
ino_t
ino
,
unsigned
int
d_type
)
ino_t
ino
,
unsigned
int
d_type
)
{
{
struct
readdir_callback
*
buf
=
(
struct
readdir_callback
*
)
__buf
;
struct
readdir_callback
*
buf
=
(
struct
readdir_callback
*
)
__buf
;
struct
old_linux_dirent
*
dirent
;
struct
old_linux_dirent
__user
*
dirent
;
if
(
buf
->
count
)
if
(
buf
->
count
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -85,7 +85,7 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
...
@@ -85,7 +85,7 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
return
0
;
return
0
;
}
}
asmlinkage
long
old_readdir
(
unsigned
int
fd
,
void
*
dirent
,
unsigned
int
count
)
asmlinkage
long
old_readdir
(
unsigned
int
fd
,
struct
old_linux_dirent
__user
*
dirent
,
unsigned
int
count
)
{
{
int
error
;
int
error
;
struct
file
*
file
;
struct
file
*
file
;
...
@@ -122,8 +122,8 @@ struct linux_dirent {
...
@@ -122,8 +122,8 @@ struct linux_dirent {
};
};
struct
getdents_callback
{
struct
getdents_callback
{
struct
linux_dirent
*
current_dir
;
struct
linux_dirent
__user
*
current_dir
;
struct
linux_dirent
*
previous
;
struct
linux_dirent
__user
*
previous
;
int
count
;
int
count
;
int
error
;
int
error
;
};
};
...
@@ -131,7 +131,7 @@ struct getdents_callback {
...
@@ -131,7 +131,7 @@ struct getdents_callback {
static
int
filldir
(
void
*
__buf
,
const
char
*
name
,
int
namlen
,
loff_t
offset
,
static
int
filldir
(
void
*
__buf
,
const
char
*
name
,
int
namlen
,
loff_t
offset
,
ino_t
ino
,
unsigned
int
d_type
)
ino_t
ino
,
unsigned
int
d_type
)
{
{
struct
linux_dirent
*
dirent
;
struct
linux_dirent
__user
*
dirent
;
struct
getdents_callback
*
buf
=
(
struct
getdents_callback
*
)
__buf
;
struct
getdents_callback
*
buf
=
(
struct
getdents_callback
*
)
__buf
;
int
reclen
=
ROUND_UP
(
NAME_OFFSET
(
dirent
)
+
namlen
+
1
);
int
reclen
=
ROUND_UP
(
NAME_OFFSET
(
dirent
)
+
namlen
+
1
);
...
@@ -161,10 +161,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
...
@@ -161,10 +161,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
return
-
EFAULT
;
return
-
EFAULT
;
}
}
asmlinkage
long
sys_getdents
(
unsigned
int
fd
,
void
*
dirent
,
unsigned
int
count
)
asmlinkage
long
sys_getdents
(
unsigned
int
fd
,
struct
linux_dirent
__user
*
dirent
,
unsigned
int
count
)
{
{
struct
file
*
file
;
struct
file
*
file
;
struct
linux_dirent
*
lastdirent
;
struct
linux_dirent
__user
*
lastdirent
;
struct
getdents_callback
buf
;
struct
getdents_callback
buf
;
int
error
;
int
error
;
...
@@ -177,7 +177,7 @@ asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count)
...
@@ -177,7 +177,7 @@ asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count)
if
(
!
file
)
if
(
!
file
)
goto
out
;
goto
out
;
buf
.
current_dir
=
(
struct
linux_dirent
*
)
dirent
;
buf
.
current_dir
=
dirent
;
buf
.
previous
=
NULL
;
buf
.
previous
=
NULL
;
buf
.
count
=
count
;
buf
.
count
=
count
;
buf
.
error
=
0
;
buf
.
error
=
0
;
...
@@ -203,8 +203,8 @@ asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count)
...
@@ -203,8 +203,8 @@ asmlinkage long sys_getdents(unsigned int fd, void * dirent, unsigned int count)
#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
struct
getdents_callback64
{
struct
getdents_callback64
{
struct
linux_dirent64
*
current_dir
;
struct
linux_dirent64
__user
*
current_dir
;
struct
linux_dirent64
*
previous
;
struct
linux_dirent64
__user
*
previous
;
int
count
;
int
count
;
int
error
;
int
error
;
};
};
...
@@ -212,7 +212,7 @@ struct getdents_callback64 {
...
@@ -212,7 +212,7 @@ struct getdents_callback64 {
static
int
filldir64
(
void
*
__buf
,
const
char
*
name
,
int
namlen
,
loff_t
offset
,
static
int
filldir64
(
void
*
__buf
,
const
char
*
name
,
int
namlen
,
loff_t
offset
,
ino_t
ino
,
unsigned
int
d_type
)
ino_t
ino
,
unsigned
int
d_type
)
{
{
struct
linux_dirent64
*
dirent
;
struct
linux_dirent64
__user
*
dirent
;
struct
getdents_callback64
*
buf
=
(
struct
getdents_callback64
*
)
__buf
;
struct
getdents_callback64
*
buf
=
(
struct
getdents_callback64
*
)
__buf
;
int
reclen
=
ROUND_UP64
(
NAME_OFFSET
(
dirent
)
+
namlen
+
1
);
int
reclen
=
ROUND_UP64
(
NAME_OFFSET
(
dirent
)
+
namlen
+
1
);
...
@@ -246,10 +246,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
...
@@ -246,10 +246,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
return
-
EFAULT
;
return
-
EFAULT
;
}
}
asmlinkage
long
sys_getdents64
(
unsigned
int
fd
,
void
*
dirent
,
unsigned
int
count
)
asmlinkage
long
sys_getdents64
(
unsigned
int
fd
,
struct
linux_dirent64
__user
*
dirent
,
unsigned
int
count
)
{
{
struct
file
*
file
;
struct
file
*
file
;
struct
linux_dirent64
*
lastdirent
;
struct
linux_dirent64
__user
*
lastdirent
;
struct
getdents_callback64
buf
;
struct
getdents_callback64
buf
;
int
error
;
int
error
;
...
@@ -262,7 +262,7 @@ asmlinkage long sys_getdents64(unsigned int fd, void * dirent, unsigned int coun
...
@@ -262,7 +262,7 @@ asmlinkage long sys_getdents64(unsigned int fd, void * dirent, unsigned int coun
if
(
!
file
)
if
(
!
file
)
goto
out
;
goto
out
;
buf
.
current_dir
=
(
struct
linux_dirent64
*
)
dirent
;
buf
.
current_dir
=
dirent
;
buf
.
previous
=
NULL
;
buf
.
previous
=
NULL
;
buf
.
count
=
count
;
buf
.
count
=
count
;
buf
.
error
=
0
;
buf
.
error
=
0
;
...
@@ -273,9 +273,8 @@ asmlinkage long sys_getdents64(unsigned int fd, void * dirent, unsigned int coun
...
@@ -273,9 +273,8 @@ asmlinkage long sys_getdents64(unsigned int fd, void * dirent, unsigned int coun
error
=
buf
.
error
;
error
=
buf
.
error
;
lastdirent
=
buf
.
previous
;
lastdirent
=
buf
.
previous
;
if
(
lastdirent
)
{
if
(
lastdirent
)
{
struct
linux_dirent64
d
;
typeof
(
lastdirent
->
d_off
)
d_off
=
file
->
f_pos
;
d
.
d_off
=
file
->
f_pos
;
__put_user
(
d_off
,
&
lastdirent
->
d_off
);
__put_user
(
d
.
d_off
,
&
lastdirent
->
d_off
);
error
=
count
-
buf
.
count
;
error
=
count
-
buf
.
count
;
}
}
...
...
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