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>
此提交包含在:
@@ -237,53 +237,6 @@ int sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user
|
||||
return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
|
||||
}
|
||||
|
||||
int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
|
||||
{
|
||||
compat_ino_t ino;
|
||||
int err;
|
||||
|
||||
if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
|
||||
!new_valid_dev(stat->rdev))
|
||||
return -EOVERFLOW;
|
||||
|
||||
ino = stat->ino;
|
||||
if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
|
||||
return -EOVERFLOW;
|
||||
|
||||
err = put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
|
||||
err |= put_user(ino, &statbuf->st_ino);
|
||||
err |= put_user(stat->mode, &statbuf->st_mode);
|
||||
err |= put_user(stat->nlink, &statbuf->st_nlink);
|
||||
err |= put_user(0, &statbuf->st_reserved1);
|
||||
err |= put_user(0, &statbuf->st_reserved2);
|
||||
err |= put_user(new_encode_dev(stat->rdev), &statbuf->st_rdev);
|
||||
err |= put_user(stat->size, &statbuf->st_size);
|
||||
err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
|
||||
err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
|
||||
err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
|
||||
err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
|
||||
err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
|
||||
err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
|
||||
err |= put_user(stat->blksize, &statbuf->st_blksize);
|
||||
err |= put_user(stat->blocks, &statbuf->st_blocks);
|
||||
err |= put_user(0, &statbuf->__unused1);
|
||||
err |= put_user(0, &statbuf->__unused2);
|
||||
err |= put_user(0, &statbuf->__unused3);
|
||||
err |= put_user(0, &statbuf->__unused4);
|
||||
err |= put_user(0, &statbuf->__unused5);
|
||||
err |= put_user(0, &statbuf->st_fstype); /* not avail */
|
||||
err |= put_user(0, &statbuf->st_realdev); /* not avail */
|
||||
err |= put_user(0, &statbuf->st_basemode); /* not avail */
|
||||
err |= put_user(0, &statbuf->st_spareshort);
|
||||
err |= put_user(stat->uid, &statbuf->st_uid);
|
||||
err |= put_user(stat->gid, &statbuf->st_gid);
|
||||
err |= put_user(0, &statbuf->st_spare4[0]);
|
||||
err |= put_user(0, &statbuf->st_spare4[1]);
|
||||
err |= put_user(0, &statbuf->st_spare4[2]);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*** copied from mips64 ***/
|
||||
/*
|
||||
* Ooo, nasty. We need here to frob 32-bit unsigned longs to
|
||||
|
新增問題並參考
封鎖使用者