mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
compat: move cp_compat_stat to common code
struct stat / compat_stat is the same on all architectures, so cp_compat_stat should be, too. Turns out it is, except that various architectures have slightly and some high2lowuid/high2lowgid or the direct assignment instead of the SET_UID/SET_GID that expands to the correct one anyway. This patch replaces the arch-specific cp_compat_stat implementations with a common one based on the x86-64 one. Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: David S. Miller <[email protected]> [ sparc bits ] Acked-by: Kyle McMartin <[email protected]> [ parisc bits ] Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
f7ad160b49
commit
f7a5000f7a
9 changed files with 39 additions and 259 deletions
39
fs/compat.c
39
fs/compat.c
|
|
@ -137,6 +137,45 @@ asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval _
|
|||
return compat_sys_futimesat(AT_FDCWD, filename, t);
|
||||
}
|
||||
|
||||
static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
|
||||
{
|
||||
compat_ino_t ino = stat->ino;
|
||||
typeof(ubuf->st_uid) uid = 0;
|
||||
typeof(ubuf->st_gid) gid = 0;
|
||||
int err;
|
||||
|
||||
SET_UID(uid, stat->uid);
|
||||
SET_GID(gid, stat->gid);
|
||||
|
||||
if ((u64) stat->size > MAX_NON_LFS ||
|
||||
!old_valid_dev(stat->dev) ||
|
||||
!old_valid_dev(stat->rdev))
|
||||
return -EOVERFLOW;
|
||||
if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
|
||||
return -EOVERFLOW;
|
||||
|
||||
if (clear_user(ubuf, sizeof(*ubuf)))
|
||||
return -EFAULT;
|
||||
|
||||
err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
|
||||
err |= __put_user(ino, &ubuf->st_ino);
|
||||
err |= __put_user(stat->mode, &ubuf->st_mode);
|
||||
err |= __put_user(stat->nlink, &ubuf->st_nlink);
|
||||
err |= __put_user(uid, &ubuf->st_uid);
|
||||
err |= __put_user(gid, &ubuf->st_gid);
|
||||
err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
|
||||
err |= __put_user(stat->size, &ubuf->st_size);
|
||||
err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
|
||||
err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
|
||||
err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
|
||||
err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
|
||||
err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
|
||||
err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
|
||||
err |= __put_user(stat->blksize, &ubuf->st_blksize);
|
||||
err |= __put_user(stat->blocks, &ubuf->st_blocks);
|
||||
return err;
|
||||
}
|
||||
|
||||
asmlinkage long compat_sys_newstat(char __user * filename,
|
||||
struct compat_stat __user *statbuf)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue