@@ -117,6 +117,92 @@ asmlinkage long ilp32_sys_semctl(int first, int second, int third, int arg)
}
#define compat_sys_semctl ilp32_sys_semctl
+struct ilp32_stat {
+ unsigned long st_dev;
+
+ unsigned long st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned int st_uid;
+ unsigned int st_gid;
+
+ unsigned long st_rdev;
+ unsigned long __st_rdev_pad;
+
+ long st_size;
+
+ unsigned int st_blksize;
+ unsigned int __st_blksize_pad;
+
+ unsigned long st_blocks;
+
+ unsigned int st_atime;
+ unsigned int st_atime_nsec;
+
+ unsigned int st_mtime;
+ unsigned int st_mtime_nsec;
+
+ unsigned int st_ctime;
+ unsigned int st_ctime_nsec;
+
+ unsigned int __unused[2];
+};
+
+static long ilp32_cp_stat(struct kstat *stat,
+ struct ilp32_stat __user *statbuf)
+{
+ struct ilp32_stat tmp = {
+ .st_dev = huge_encode_dev(stat->dev),
+ .st_ino = stat->ino,
+ .st_mode = stat->mode,
+ .st_nlink = stat->nlink,
+ .st_uid = from_kuid_munged(current_user_ns(), stat->uid),
+ .st_gid = from_kgid_munged(current_user_ns(), stat->gid),
+ .st_rdev = huge_encode_dev(stat->rdev),
+ .__st_rdev_pad = 0,
+ .st_size = stat->size,
+ .st_blksize = stat->blksize,
+ .__st_blksize_pad = 0,
+ .st_blocks = stat->blocks,
+ .st_atime = stat->atime.tv_sec,
+ .st_atime_nsec = stat->atime.tv_nsec,
+ .st_mtime = stat->mtime.tv_sec,
+ .st_mtime_nsec = stat->mtime.tv_nsec,
+ .st_ctime = stat->ctime.tv_sec,
+ .st_ctime_nsec = stat->ctime.tv_nsec,
+ .__unused = { 0, 0 }
+ };
+
+ return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
+}
+
+asmlinkage long ilp32_sys_fstat64(unsigned int fd,
+ struct ilp32_stat __user *statbuf)
+{
+ struct kstat stat;
+ int error = vfs_fstat(fd, &stat);
+
+ if (!error)
+ error = ilp32_cp_stat(&stat, statbuf);
+ return error;
+}
+#define sys_fstat64 ilp32_sys_fstat64
+
+asmlinkage long ilp32_sys_fstatat64(unsigned int dfd,
+ const char __user *filename,
+ struct ilp32_stat __user *statbuf, int flag)
+{
+ struct kstat stat;
+ int error = vfs_fstatat(dfd, filename, &stat, flag);
+
+ if (!error)
+ error = ilp32_cp_stat(&stat, statbuf);
+ return error;
+}
+#define sys_fstatat64 ilp32_sys_fstatat64
+
#include <asm/syscall.h>
#undef __SYSCALL