SYSCALL_DEFINE1(fchdir, unsigned int, fd) { struct file *file; struct inode *inode; int error, fput_needed; error = -EBADF; file = fget_raw_light(fd, &fput_needed); if (!file) goto out; inode = file->f_path.dentry->d_inode; error = -ENOTDIR; if (!S_ISDIR(inode->i_mode)) goto out_putf; error = inode_permission(inode, MAY_EXEC | MAY_CHDIR); if (!error) set_fs_pwd(current->fs, &file->f_path); out_putf: fput_light(file, fput_needed); out: return error; }
int vfs_fstat(unsigned int fd, struct kstat *stat) { int fput_needed; struct file *f = fget_raw_light(fd, &fput_needed); int error = -EBADF; if (f) { error = vfs_getattr(f->f_path.mnt, f->f_path.dentry, stat); fput_light(f, fput_needed); } return error; }