diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-07-20 14:56:40 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1997-07-20 14:56:40 +0000 |
commit | e308faf24f68e262d92d294a01ddca7a17e76762 (patch) | |
tree | 22c47cb315811834861f013067878ff664e95abd /fs/stat.c | |
parent | 30c6397ce63178fcb3e7963ac247f0a03132aca9 (diff) |
Sync with Linux 2.1.46.
Diffstat (limited to 'fs/stat.c')
-rw-r--r-- | fs/stat.c | 155 |
1 files changed, 84 insertions, 71 deletions
@@ -48,8 +48,6 @@ static int cp_old_stat(struct inode * inode, struct __old_kernel_stat * statbuf) tmp.st_gid = inode->i_gid; tmp.st_rdev = kdev_t_to_nr(inode->i_rdev); tmp.st_size = inode->i_size; - if (inode->i_pipe) - tmp.st_size = PIPE_SIZE(*inode); tmp.st_atime = inode->i_atime; tmp.st_mtime = inode->i_mtime; tmp.st_ctime = inode->i_ctime; @@ -72,8 +70,6 @@ static int cp_new_stat(struct inode * inode, struct stat * statbuf) tmp.st_gid = inode->i_gid; tmp.st_rdev = kdev_t_to_nr(inode->i_rdev); tmp.st_size = inode->i_size; - if (inode->i_pipe) - tmp.st_size = PIPE_SIZE(*inode); tmp.st_atime = inode->i_atime; tmp.st_mtime = inode->i_mtime; tmp.st_ctime = inode->i_ctime; @@ -116,6 +112,7 @@ static int cp_new_stat(struct inode * inode, struct stat * statbuf) return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; } + #if !defined(__alpha__) && !defined(__sparc__) /* * For backward compatibility? Maybe this should be moved @@ -123,17 +120,21 @@ static int cp_new_stat(struct inode * inode, struct stat * statbuf) */ asmlinkage int sys_stat(char * filename, struct __old_kernel_stat * statbuf) { - struct inode * inode; + struct dentry * dentry; int error; lock_kernel(); - error = namei(NAM_FOLLOW_LINK, filename, &inode); - if (error) - goto out; - if ((error = do_revalidate(inode)) == 0) - error = cp_old_stat(inode,statbuf); - iput(inode); -out: + dentry = namei(filename); + + error = PTR_ERR(dentry); + if (!IS_ERR(dentry)) { + struct inode * inode = dentry->d_inode; + error = do_revalidate(inode); + if (!error) + error = cp_old_stat(inode, statbuf); + + dput(dentry); + } unlock_kernel(); return error; } @@ -141,17 +142,21 @@ out: asmlinkage int sys_newstat(char * filename, struct stat * statbuf) { - struct inode * inode; + struct dentry * dentry; int error; lock_kernel(); - error = namei(NAM_FOLLOW_LINK, filename, &inode); - if (error) - goto out; - if ((error = do_revalidate(inode)) == 0) - error = cp_new_stat(inode,statbuf); - iput(inode); -out: + dentry = namei(filename); + + error = PTR_ERR(dentry); + if (!IS_ERR(dentry)) { + struct inode * inode = dentry->d_inode; + error = do_revalidate(inode); + if (!error) + error = cp_new_stat(inode,statbuf); + + dput(dentry); + } unlock_kernel(); return error; } @@ -164,17 +169,21 @@ out: */ asmlinkage int sys_lstat(char * filename, struct __old_kernel_stat * statbuf) { - struct inode * inode; + struct dentry * dentry; int error; lock_kernel(); - error = namei(NAM_FOLLOW_TRAILSLASH, filename, &inode); - if (error) - goto out; - if ((error = do_revalidate(inode)) == 0) - error = cp_old_stat(inode,statbuf); - iput(inode); -out: + dentry = lnamei(filename); + + error = PTR_ERR(dentry); + if (!IS_ERR(dentry)) { + struct inode * inode = dentry->d_inode; + error = do_revalidate(inode); + if (!error) + error = cp_old_stat(inode, statbuf); + + dput(dentry); + } unlock_kernel(); return error; } @@ -183,17 +192,21 @@ out: asmlinkage int sys_newlstat(char * filename, struct stat * statbuf) { - struct inode * inode; + struct dentry * dentry; int error; lock_kernel(); - error = namei(NAM_FOLLOW_TRAILSLASH, filename, &inode); - if (error) - goto out; - if ((error = do_revalidate(inode)) == 0) - error = cp_new_stat(inode,statbuf); - iput(inode); -out: + dentry = lnamei(filename); + + error = PTR_ERR(dentry); + if (!IS_ERR(dentry)) { + struct inode * inode = dentry->d_inode; + error = do_revalidate(inode); + if (!error) + error = cp_new_stat(inode,statbuf); + + dput(dentry); + } unlock_kernel(); return error; } @@ -207,17 +220,19 @@ out: asmlinkage int sys_fstat(unsigned int fd, struct __old_kernel_stat * statbuf) { struct file * f; - struct inode * inode; - int ret = -EBADF; + int err = -EBADF; lock_kernel(); - if (fd >= NR_OPEN || !(f=current->files->fd[fd]) || !(inode=f->f_inode)) - goto out; - if ((ret = do_revalidate(inode)) == 0) - ret = cp_old_stat(inode,statbuf); -out: + if (fd < NR_OPEN && (f = current->files->fd[fd]) != NULL) { + struct dentry * dentry = f->f_dentry; + struct inode * inode = dentry->d_inode; + + err = do_revalidate(inode); + if (!err) + err = cp_old_stat(inode,statbuf); + } unlock_kernel(); - return ret; + return err; } #endif @@ -225,45 +240,43 @@ out: asmlinkage int sys_newfstat(unsigned int fd, struct stat * statbuf) { struct file * f; - struct inode * inode; int err = -EBADF; lock_kernel(); - if (fd >= NR_OPEN || !(f=current->files->fd[fd]) || !(inode=f->f_inode)) - goto out; - if ((err = do_revalidate(inode)) == 0) - err = cp_new_stat(inode,statbuf); -out: + if (fd < NR_OPEN && (f = current->files->fd[fd]) != NULL) { + struct dentry * dentry = f->f_dentry; + struct inode * inode = dentry->d_inode; + + err = do_revalidate(inode); + if (!err) + err = cp_new_stat(inode,statbuf); + } unlock_kernel(); return err; } asmlinkage int sys_readlink(const char * path, char * buf, int bufsiz) { - struct inode * inode; - int error = -EINVAL; + struct dentry * dentry; + int error; - lock_kernel(); if (bufsiz <= 0) - goto out; - error = verify_area(VERIFY_WRITE,buf,bufsiz); - if (error) - goto out; - error = namei(NAM_FOLLOW_TRAILSLASH, path, &inode); - if (error) - goto out; - error = -EINVAL; - if (!inode->i_op || !inode->i_op->readlink || - !S_ISLNK(inode->i_mode) || (error = do_revalidate(inode)) < 0) { - iput(inode); - goto out; - } - if (!IS_RDONLY(inode)) { - inode->i_atime = CURRENT_TIME; - inode->i_dirt = 1; + return -EINVAL; + + lock_kernel(); + dentry = lnamei(path); + + error = PTR_ERR(dentry); + if (!IS_ERR(dentry)) { + struct inode * inode = dentry->d_inode; + + error = -EINVAL; + if (inode->i_op && inode->i_op->readlink && !(error = do_revalidate(inode))) { + UPDATE_ATIME(inode); + error = inode->i_op->readlink(inode,buf,bufsiz); + } + dput(dentry); } - error = inode->i_op->readlink(inode,buf,bufsiz); -out: unlock_kernel(); return error; } |