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
ac565de3
Commit
ac565de3
authored
Apr 08, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stat: move compat syscalls from compat.c
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
80f0cce6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
83 deletions
+86
-83
fs/compat.c
fs/compat.c
+0
-83
fs/stat.c
fs/stat.c
+86
-0
No files found.
fs/compat.c
View file @
ac565de3
...
...
@@ -54,89 +54,6 @@
#include <asm/ioctls.h>
#include "internal.h"
static
int
cp_compat_stat
(
struct
kstat
*
stat
,
struct
compat_stat
__user
*
ubuf
)
{
struct
compat_stat
tmp
;
if
(
!
old_valid_dev
(
stat
->
dev
)
||
!
old_valid_dev
(
stat
->
rdev
))
return
-
EOVERFLOW
;
memset
(
&
tmp
,
0
,
sizeof
(
tmp
));
tmp
.
st_dev
=
old_encode_dev
(
stat
->
dev
);
tmp
.
st_ino
=
stat
->
ino
;
if
(
sizeof
(
tmp
.
st_ino
)
<
sizeof
(
stat
->
ino
)
&&
tmp
.
st_ino
!=
stat
->
ino
)
return
-
EOVERFLOW
;
tmp
.
st_mode
=
stat
->
mode
;
tmp
.
st_nlink
=
stat
->
nlink
;
if
(
tmp
.
st_nlink
!=
stat
->
nlink
)
return
-
EOVERFLOW
;
SET_UID
(
tmp
.
st_uid
,
from_kuid_munged
(
current_user_ns
(),
stat
->
uid
));
SET_GID
(
tmp
.
st_gid
,
from_kgid_munged
(
current_user_ns
(),
stat
->
gid
));
tmp
.
st_rdev
=
old_encode_dev
(
stat
->
rdev
);
if
((
u64
)
stat
->
size
>
MAX_NON_LFS
)
return
-
EOVERFLOW
;
tmp
.
st_size
=
stat
->
size
;
tmp
.
st_atime
=
stat
->
atime
.
tv_sec
;
tmp
.
st_atime_nsec
=
stat
->
atime
.
tv_nsec
;
tmp
.
st_mtime
=
stat
->
mtime
.
tv_sec
;
tmp
.
st_mtime_nsec
=
stat
->
mtime
.
tv_nsec
;
tmp
.
st_ctime
=
stat
->
ctime
.
tv_sec
;
tmp
.
st_ctime_nsec
=
stat
->
ctime
.
tv_nsec
;
tmp
.
st_blocks
=
stat
->
blocks
;
tmp
.
st_blksize
=
stat
->
blksize
;
return
copy_to_user
(
ubuf
,
&
tmp
,
sizeof
(
tmp
))
?
-
EFAULT
:
0
;
}
COMPAT_SYSCALL_DEFINE2
(
newstat
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_stat
(
filename
,
&
stat
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
COMPAT_SYSCALL_DEFINE2
(
newlstat
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_lstat
(
filename
,
&
stat
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
#ifndef __ARCH_WANT_STAT64
COMPAT_SYSCALL_DEFINE4
(
newfstatat
,
unsigned
int
,
dfd
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
,
int
,
flag
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_fstatat
(
dfd
,
filename
,
&
stat
,
flag
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
#endif
COMPAT_SYSCALL_DEFINE2
(
newfstat
,
unsigned
int
,
fd
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
=
vfs_fstat
(
fd
,
&
stat
);
if
(
!
error
)
error
=
cp_compat_stat
(
&
stat
,
statbuf
);
return
error
;
}
/* A write operation does a read from user space and vice versa */
#define vrfy_dir(type) ((type) == READ ? VERIFY_WRITE : VERIFY_READ)
...
...
fs/stat.c
View file @
ac565de3
...
...
@@ -15,6 +15,7 @@
#include <linux/cred.h>
#include <linux/syscalls.h>
#include <linux/pagemap.h>
#include <linux/compat.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
...
...
@@ -584,6 +585,91 @@ SYSCALL_DEFINE5(statx,
return
statx_set_result
(
&
stat
,
buffer
);
}
#ifdef CONFIG_COMPAT
static
int
cp_compat_stat
(
struct
kstat
*
stat
,
struct
compat_stat
__user
*
ubuf
)
{
struct
compat_stat
tmp
;
if
(
!
old_valid_dev
(
stat
->
dev
)
||
!
old_valid_dev
(
stat
->
rdev
))
return
-
EOVERFLOW
;
memset
(
&
tmp
,
0
,
sizeof
(
tmp
));
tmp
.
st_dev
=
old_encode_dev
(
stat
->
dev
);
tmp
.
st_ino
=
stat
->
ino
;
if
(
sizeof
(
tmp
.
st_ino
)
<
sizeof
(
stat
->
ino
)
&&
tmp
.
st_ino
!=
stat
->
ino
)
return
-
EOVERFLOW
;
tmp
.
st_mode
=
stat
->
mode
;
tmp
.
st_nlink
=
stat
->
nlink
;
if
(
tmp
.
st_nlink
!=
stat
->
nlink
)
return
-
EOVERFLOW
;
SET_UID
(
tmp
.
st_uid
,
from_kuid_munged
(
current_user_ns
(),
stat
->
uid
));
SET_GID
(
tmp
.
st_gid
,
from_kgid_munged
(
current_user_ns
(),
stat
->
gid
));
tmp
.
st_rdev
=
old_encode_dev
(
stat
->
rdev
);
if
((
u64
)
stat
->
size
>
MAX_NON_LFS
)
return
-
EOVERFLOW
;
tmp
.
st_size
=
stat
->
size
;
tmp
.
st_atime
=
stat
->
atime
.
tv_sec
;
tmp
.
st_atime_nsec
=
stat
->
atime
.
tv_nsec
;
tmp
.
st_mtime
=
stat
->
mtime
.
tv_sec
;
tmp
.
st_mtime_nsec
=
stat
->
mtime
.
tv_nsec
;
tmp
.
st_ctime
=
stat
->
ctime
.
tv_sec
;
tmp
.
st_ctime_nsec
=
stat
->
ctime
.
tv_nsec
;
tmp
.
st_blocks
=
stat
->
blocks
;
tmp
.
st_blksize
=
stat
->
blksize
;
return
copy_to_user
(
ubuf
,
&
tmp
,
sizeof
(
tmp
))
?
-
EFAULT
:
0
;
}
COMPAT_SYSCALL_DEFINE2
(
newstat
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_stat
(
filename
,
&
stat
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
COMPAT_SYSCALL_DEFINE2
(
newlstat
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_lstat
(
filename
,
&
stat
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
#ifndef __ARCH_WANT_STAT64
COMPAT_SYSCALL_DEFINE4
(
newfstatat
,
unsigned
int
,
dfd
,
const
char
__user
*
,
filename
,
struct
compat_stat
__user
*
,
statbuf
,
int
,
flag
)
{
struct
kstat
stat
;
int
error
;
error
=
vfs_fstatat
(
dfd
,
filename
,
&
stat
,
flag
);
if
(
error
)
return
error
;
return
cp_compat_stat
(
&
stat
,
statbuf
);
}
#endif
COMPAT_SYSCALL_DEFINE2
(
newfstat
,
unsigned
int
,
fd
,
struct
compat_stat
__user
*
,
statbuf
)
{
struct
kstat
stat
;
int
error
=
vfs_fstat
(
fd
,
&
stat
);
if
(
!
error
)
error
=
cp_compat_stat
(
&
stat
,
statbuf
);
return
error
;
}
#endif
/* Caller is here responsible for sufficient locking (ie. inode->i_lock) */
void
__inode_add_bytes
(
struct
inode
*
inode
,
loff_t
bytes
)
{
...
...
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