summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Viro <viro@math.psu.edu>2002-02-05 18:46:34 -0800
committerLinus Torvalds <torvalds@penguin.transmeta.com>2002-02-05 18:46:34 -0800
commit73136fa5557d2b29b9bc471fd88d44fd65fe6c7a (patch)
treec8fd70f80f32eb098687b4a79e3def76432a5732
parent9bf01f069791ba1dbcd2d3f955428e27f3cf6fbd (diff)
[PATCH] (3/5) beginning of getattr series.
irix_...() switched from sys_new*stat() to vfs_*stat() and cleaned up. Missing LFS check added
-rw-r--r--arch/mips/kernel/sysirix.c213
1 files changed, 76 insertions, 137 deletions
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index fbd4a2dcc105..9f820f87e25f 100644
--- a/arch/mips/kernel/sysirix.c
+++ b/arch/mips/kernel/sysirix.c
@@ -1178,7 +1178,7 @@ linux_to_irix_dev_t (dev_t t)
return MAJOR (t) << 18 | MINOR (t);
}
-static inline int irix_xstat32_xlate(struct stat *kb, void *ubuf)
+static inline int irix_xstat32_xlate(struct kstat *stat, void *ubuf)
{
struct xstat32 {
u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
@@ -1191,28 +1191,32 @@ static inline int irix_xstat32_xlate(struct stat *kb, void *ubuf)
u32 st_pad4[8];
} ub;
- ub.st_dev = linux_to_irix_dev_t (kb->st_dev);
- ub.st_ino = kb->st_ino;
- ub.st_mode = kb->st_mode;
- ub.st_nlink = kb->st_nlink;
- ub.st_uid = kb->st_uid;
- ub.st_gid = kb->st_gid;
- ub.st_rdev = linux_to_irix_dev_t (kb->st_rdev);
- ub.st_size = kb->st_size;
- ub.st_atime0 = kb->st_atime;
+ ub.st_dev = linux_to_irix_dev_t(stat->dev);
+ ub.st_ino = stat->ino;
+ ub.st_mode = stat->mode;
+ ub.st_nlink = stat->nlink;
+ SET_STAT_UID(ub, stat->uid);
+ SET_STAT_GID(ub, stat->gid);
+ ub.st_rdev = linux_to_irix_dev_t(stat->rdev);
+#if BITS_PER_LONG == 32
+ if (stat->size > MAX_NON_LFS)
+ return -EOVERFLOW;
+#endif
+ ub.st_size = stat->size;
+ ub.st_atime0 = stat->atime;
ub.st_atime1 = 0;
- ub.st_mtime0 = kb->st_mtime;
+ ub.st_mtime0 = stat->mtime;
ub.st_mtime1 = 0;
- ub.st_ctime0 = kb->st_ctime;
+ ub.st_ctime0 = stat->ctime;
ub.st_ctime1 = 0;
- ub.st_blksize = kb->st_blksize;
- ub.st_blocks = kb->st_blocks;
+ ub.st_blksize = stat->blksize;
+ ub.st_blocks = stat->blocks;
strcpy (ub.st_fstype, "efs");
return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
}
-static inline void irix_xstat64_xlate(struct stat *sb)
+static inline void irix_xstat64_xlate(struct kstat *stat, void *ubuf)
{
struct xstat64 {
u32 st_dev; s32 st_pad1[3];
@@ -1229,177 +1233,112 @@ static inline void irix_xstat64_xlate(struct stat *sb)
s32 st_pad4[8];
} ks;
- ks.st_dev = linux_to_irix_dev_t (sb->st_dev);
+ ks.st_dev = linux_to_irix_dev_t(stat->dev);
ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
- ks.st_ino = (unsigned long long) sb->st_ino;
- ks.st_mode = (u32) sb->st_mode;
- ks.st_nlink = (u32) sb->st_nlink;
- ks.st_uid = (s32) sb->st_uid;
- ks.st_gid = (s32) sb->st_gid;
- ks.st_rdev = linux_to_irix_dev_t (sb->st_rdev);
+ ks.st_ino = (unsigned long long) stat->ino;
+ ks.st_mode = (u32) stat->mode;
+ ks.st_nlink = (u32) stat->nlink;
+ ks.st_uid = (s32) stat->uid;
+ ks.st_gid = (s32) stat->gid;
+ ks.st_rdev = linux_to_irix_dev_t (stat->rdev);
ks.st_pad2[0] = ks.st_pad2[1] = 0;
- ks.st_size = (long long) sb->st_size;
+ ks.st_size = (long long) stat->size;
ks.st_pad3 = 0;
/* XXX hackety hack... */
- ks.st_atime.tv_sec = (s32) sb->st_atime; ks.st_atime.tv_nsec = 0;
- ks.st_mtime.tv_sec = (s32) sb->st_atime; ks.st_mtime.tv_nsec = 0;
- ks.st_ctime.tv_sec = (s32) sb->st_atime; ks.st_ctime.tv_nsec = 0;
+ ks.st_atime.tv_sec = (s32) stat->atime; ks.st_atime.tv_nsec = 0;
+ ks.st_mtime.tv_sec = (s32) stat->atime; ks.st_mtime.tv_nsec = 0;
+ ks.st_ctime.tv_sec = (s32) stat->atime; ks.st_ctime.tv_nsec = 0;
- ks.st_blksize = (s32) sb->st_blksize;
- ks.st_blocks = (long long) sb->st_blocks;
+ ks.st_blksize = (s32) stat->blksize;
+ ks.st_blocks = (long long) stat->blocks;
memset(ks.st_fstype, 0, 16);
ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;
/* Now write it all back. */
- copy_to_user(sb, &ks, sizeof(struct xstat64));
+ copy_to_user(ubuf, &ks, sizeof(struct xstat64));
}
-extern asmlinkage int sys_newstat(char * filename, struct stat * statbuf);
-
asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf)
{
int retval;
+ struct kstat stat;
#ifdef DEBUG_XSTAT
printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
current->comm, current->pid, version, filename, statbuf);
#endif
- switch(version) {
- case 2: {
- struct stat kb;
- mm_segment_t old_fs;
-
- old_fs = get_fs(); set_fs(get_ds());
- retval = sys_newstat(filename, &kb);
- set_fs(old_fs);
-#ifdef DEBUG_XSTAT
- printk("retval[%d]\n", retval);
-#endif
- if(retval)
- goto out;
- retval = irix_xstat32_xlate(&kb, statbuf);
- goto out;
- }
-
- case 3: {
- retval = sys_newstat(filename, statbuf);
-#ifdef DEBUG_XSTAT
- printk("retval[%d]\n", retval);
-#endif
- if(retval)
- goto out;
-
- irix_xstat64_xlate(statbuf);
- retval = 0;
- break;
- }
- default:
- retval = -EINVAL;
- break;
+ retval = vfs_stat(filename, &stat);
+ if (!retval) {
+ switch(version) {
+ case 2:
+ retval = irix_xstat32_xlate(&stat, statbuf);
+ break;
+ case 3:
+ irix_xstat64_xlate(&stat, statbuf);
+ retval = 0; /* Really? */
+ break;
+ default:
+ retval = -EINVAL;
+ }
}
-
-out:
return retval;
}
-extern asmlinkage int sys_newlstat(char * filename, struct stat * statbuf);
-
asmlinkage int irix_lxstat(int version, char *filename, struct stat *statbuf)
{
int error;
+ struct kstat stat;
#ifdef DEBUG_XSTAT
printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
current->comm, current->pid, version, filename, statbuf);
#endif
- switch(version) {
- case 2: {
- struct stat kb;
- mm_segment_t old_fs;
-
- old_fs = get_fs(); set_fs(get_ds());
- error = sys_newlstat(filename, &kb);
- set_fs(old_fs);
-#ifdef DEBUG_XSTAT
- printk("error[%d]\n", error);
-#endif
- if(error)
- goto out;
- error = irix_xstat32_xlate(&kb, statbuf);
- goto out;
- }
-
- case 3: {
- error = sys_newlstat(filename, statbuf);
-#ifdef DEBUG_XSTAT
- printk("error[%d]\n", error);
-#endif
- if(error)
- goto out;
-
- irix_xstat64_xlate(statbuf);
- error = 0;
- goto out;
- }
- default:
- error = -EINVAL;
- goto out;
+ error = vfs_lstat(filename, &stat);
+
+ if (!error) {
+ switch (version) {
+ case 2:
+ error = irix_xstat32_xlate(&stat, statbuf);
+ break;
+ case 3:
+ irix_xstat64_xlate(&stat, statbuf);
+ error = 0;
+ break;
+ default:
+ error = -EINVAL;
+ }
}
-
-out:
return error;
}
-extern asmlinkage int sys_newfstat(unsigned int fd, struct stat * statbuf);
-
asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf)
{
int error;
+ struct kstat stat;
#ifdef DEBUG_XSTAT
printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
current->comm, current->pid, version, fd, statbuf);
#endif
- switch(version) {
- case 2: {
- struct stat kb;
- mm_segment_t old_fs;
-
- old_fs = get_fs(); set_fs(get_ds());
- error = sys_newfstat(fd, &kb);
- set_fs(old_fs);
-#ifdef DEBUG_XSTAT
- printk("error[%d]\n", error);
-#endif
- if(error)
- goto out;
- error = irix_xstat32_xlate(&kb, statbuf);
- goto out;
- }
-
- case 3: {
- error = sys_newfstat(fd, statbuf);
-#ifdef DEBUG_XSTAT
- printk("error[%d]\n", error);
-#endif
- if(error)
- goto out;
- irix_xstat64_xlate(statbuf);
- error = 0;
- goto out;
- }
-
- default:
- error = -EINVAL;
- goto out;
+ error = vfs_fstat(fd, &stat);
+ if (!error) {
+ switch (version) {
+ case 2:
+ error = irix_xstat32_xlate(&stat, statbuf);
+ break;
+ case 3:
+ irix_xstat64_xlate(&stat, statbuf);
+ error = 0;
+ break;
+ default:
+ error = -EINVAL;
+ }
}
-
-out:
return error;
}