mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 11:16:11 +00:00
kill vfs_stat_fd / vfs_lstat_fd
There's really no reason to keep vfs_stat_fd and vfs_lstat_fd with Oleg's vfs_fstatat. Use vfs_fstatat for the few cases having the directory fd, and switch all others to vfs_stat / vfs_lstat. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
0112fc2229
commit
2eae7a1874
3 changed files with 52 additions and 73 deletions
18
fs/compat.c
18
fs/compat.c
|
@ -181,22 +181,24 @@ asmlinkage long compat_sys_newstat(char __user * filename,
|
|||
struct compat_stat __user *statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_stat_fd(AT_FDCWD, filename, &stat);
|
||||
int error;
|
||||
|
||||
if (!error)
|
||||
error = cp_compat_stat(&stat, statbuf);
|
||||
return error;
|
||||
error = vfs_stat(filename, &stat);
|
||||
if (error)
|
||||
return error;
|
||||
return cp_compat_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
asmlinkage long compat_sys_newlstat(char __user * filename,
|
||||
struct compat_stat __user *statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_lstat_fd(AT_FDCWD, filename, &stat);
|
||||
int error;
|
||||
|
||||
if (!error)
|
||||
error = cp_compat_stat(&stat, statbuf);
|
||||
return error;
|
||||
error = vfs_lstat(filename, &stat);
|
||||
if (error)
|
||||
return error;
|
||||
return cp_compat_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
#ifndef __ARCH_WANT_STAT64
|
||||
|
|
105
fs/stat.c
105
fs/stat.c
|
@ -55,46 +55,6 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
|
|||
|
||||
EXPORT_SYMBOL(vfs_getattr);
|
||||
|
||||
int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
|
||||
error = user_path_at(dfd, name, LOOKUP_FOLLOW, &path);
|
||||
if (!error) {
|
||||
error = vfs_getattr(path.mnt, path.dentry, stat);
|
||||
path_put(&path);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
int vfs_stat(char __user *name, struct kstat *stat)
|
||||
{
|
||||
return vfs_stat_fd(AT_FDCWD, name, stat);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(vfs_stat);
|
||||
|
||||
int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
|
||||
error = user_path_at(dfd, name, 0, &path);
|
||||
if (!error) {
|
||||
error = vfs_getattr(path.mnt, path.dentry, stat);
|
||||
path_put(&path);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
int vfs_lstat(char __user *name, struct kstat *stat)
|
||||
{
|
||||
return vfs_lstat_fd(AT_FDCWD, name, stat);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(vfs_lstat);
|
||||
|
||||
int vfs_fstat(unsigned int fd, struct kstat *stat)
|
||||
{
|
||||
struct file *f = fget(fd);
|
||||
|
@ -106,26 +66,43 @@ int vfs_fstat(unsigned int fd, struct kstat *stat)
|
|||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(vfs_fstat);
|
||||
|
||||
int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag)
|
||||
{
|
||||
struct path path;
|
||||
int error = -EINVAL;
|
||||
int lookup_flags = 0;
|
||||
|
||||
if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
|
||||
goto out;
|
||||
|
||||
if (flag & AT_SYMLINK_NOFOLLOW)
|
||||
error = vfs_lstat_fd(dfd, filename, stat);
|
||||
else
|
||||
error = vfs_stat_fd(dfd, filename, stat);
|
||||
if (!(flag & AT_SYMLINK_NOFOLLOW))
|
||||
lookup_flags |= LOOKUP_FOLLOW;
|
||||
|
||||
error = user_path_at(dfd, filename, lookup_flags, &path);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
error = vfs_getattr(path.mnt, path.dentry, stat);
|
||||
path_put(&path);
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(vfs_fstatat);
|
||||
|
||||
int vfs_stat(char __user *name, struct kstat *stat)
|
||||
{
|
||||
return vfs_fstatat(AT_FDCWD, name, stat, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(vfs_stat);
|
||||
|
||||
int vfs_lstat(char __user *name, struct kstat *stat)
|
||||
{
|
||||
return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW);
|
||||
}
|
||||
EXPORT_SYMBOL(vfs_lstat);
|
||||
|
||||
|
||||
#ifdef __ARCH_WANT_OLD_STAT
|
||||
|
||||
|
@ -173,23 +150,25 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
|
|||
SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_stat_fd(AT_FDCWD, filename, &stat);
|
||||
int error;
|
||||
|
||||
if (!error)
|
||||
error = cp_old_stat(&stat, statbuf);
|
||||
error = vfs_stat(filename, &stat);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return error;
|
||||
return cp_old_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(lstat, char __user *, filename, struct __old_kernel_stat __user *, statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_lstat_fd(AT_FDCWD, filename, &stat);
|
||||
int error;
|
||||
|
||||
if (!error)
|
||||
error = cp_old_stat(&stat, statbuf);
|
||||
error = vfs_lstat(filename, &stat);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return error;
|
||||
return cp_old_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(fstat, unsigned int, fd, struct __old_kernel_stat __user *, statbuf)
|
||||
|
@ -258,23 +237,23 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
|
|||
SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_stat_fd(AT_FDCWD, filename, &stat);
|
||||
int error = vfs_stat(filename, &stat);
|
||||
|
||||
if (!error)
|
||||
error = cp_new_stat(&stat, statbuf);
|
||||
|
||||
return error;
|
||||
if (error)
|
||||
return error;
|
||||
return cp_new_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf)
|
||||
{
|
||||
struct kstat stat;
|
||||
int error = vfs_lstat_fd(AT_FDCWD, filename, &stat);
|
||||
int error;
|
||||
|
||||
if (!error)
|
||||
error = cp_new_stat(&stat, statbuf);
|
||||
error = vfs_lstat(filename, &stat);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return error;
|
||||
return cp_new_stat(&stat, statbuf);
|
||||
}
|
||||
|
||||
#if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT)
|
||||
|
|
|
@ -2299,8 +2299,6 @@ extern int vfs_readdir(struct file *, filldir_t, void *);
|
|||
|
||||
extern int vfs_stat(char __user *, struct kstat *);
|
||||
extern int vfs_lstat(char __user *, struct kstat *);
|
||||
extern int vfs_stat_fd(int dfd, char __user *, struct kstat *);
|
||||
extern int vfs_lstat_fd(int dfd, char __user *, struct kstat *);
|
||||
extern int vfs_fstat(unsigned int, struct kstat *);
|
||||
extern int vfs_fstatat(int , char __user *, struct kstat *, int);
|
||||
|
||||
|
|
Loading…
Reference in a new issue