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 <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net> [ sparc bits ]
Acked-by: Kyle McMartin <kyle@mcmartin.ca> [ parisc bits ]
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Christoph Hellwig
2008-10-15 22:02:05 -07:00
committed by Linus Torvalds
parent f7ad160b49
commit f7a5000f7a
9 changed files with 39 additions and 259 deletions

View File

@ -49,41 +49,6 @@
#define AA(__x) ((unsigned long)(__x))
int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
{
compat_ino_t ino;
typeof(ubuf->st_uid) uid = 0;
typeof(ubuf->st_gid) gid = 0;
SET_UID(uid, kbuf->uid);
SET_GID(gid, kbuf->gid);
if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
return -EOVERFLOW;
if (kbuf->size >= 0x7fffffff)
return -EOVERFLOW;
ino = kbuf->ino;
if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino)
return -EOVERFLOW;
if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
__put_user(old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
__put_user(ino, &ubuf->st_ino) ||
__put_user(kbuf->mode, &ubuf->st_mode) ||
__put_user(kbuf->nlink, &ubuf->st_nlink) ||
__put_user(uid, &ubuf->st_uid) ||
__put_user(gid, &ubuf->st_gid) ||
__put_user(old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
__put_user(kbuf->size, &ubuf->st_size) ||
__put_user(kbuf->atime.tv_sec, &ubuf->st_atime) ||
__put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
__put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
__put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
__put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
__put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
__put_user(kbuf->blksize, &ubuf->st_blksize) ||
__put_user(kbuf->blocks, &ubuf->st_blocks))
return -EFAULT;
return 0;
}
asmlinkage long sys32_truncate64(char __user *filename,
unsigned long offset_low,