Skip to content
Permalink
Browse files

Merge pull request #8 from zhangn1985/sun8i

fs/file_table: split fget_light
  • Loading branch information...
igorpecovnik committed Jan 31, 2019
2 parents 002a60c + ca925a7 commit 1d512229ab803fa4b88ecc4c7cf4b93c6cbedff1
Showing with 10 additions and 4 deletions.
  1. +8 −3 fs/file_table.c
  2. +1 −1 fs/stat.c
  3. +1 −0 include/linux/file.h
@@ -322,21 +322,21 @@ EXPORT_SYMBOL(fget_raw);
* The fput_needed flag returned by fget_light should be passed to the
* corresponding fput_light.
*/
struct file *fget_light(unsigned int fd, int *fput_needed)
struct file *__fget_light(unsigned int fd, fmode_t mode, int *fput_needed)
{
struct file *file;
struct files_struct *files = current->files;

*fput_needed = 0;
if (atomic_read(&files->count) == 1) {
file = fcheck_files(files, fd);
if (file && (file->f_mode & FMODE_PATH))
if (file && (file->f_mode & mode))
file = NULL;
} else {
rcu_read_lock();
file = fcheck_files(files, fd);
if (file) {
if (!(file->f_mode & FMODE_PATH) &&
if (!(file->f_mode & mode) &&
atomic_long_inc_not_zero(&file->f_count))
*fput_needed = 1;
else
@@ -349,6 +349,11 @@ struct file *fget_light(unsigned int fd, int *fput_needed)
return file;
}

struct file *fget_light(unsigned int fd, int *fput_needed)
{
return __fget_light(fd, FMODE_PATH, fput_needed);
}

struct file *fget_raw_light(unsigned int fd, int *fput_needed)
{
struct file *file;
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(vfs_getattr);
int vfs_fstat(unsigned int fd, struct kstat *stat)
{
int fput_needed;
struct file *f = fget_light(fd, &fput_needed);
struct file *f = __fget_light(fd, 0, &fput_needed);
int error = -EBADF;

if (f) {
@@ -28,6 +28,7 @@ static inline void fput_light(struct file *file, int fput_needed)

extern struct file *fget(unsigned int fd);
extern struct file *fget_light(unsigned int fd, int *fput_needed);
extern struct file *__fget_light(unsigned int fd, fmode_t mode, int *fput_needed);
extern struct file *fget_raw(unsigned int fd);
extern struct file *fget_raw_light(unsigned int fd, int *fput_needed);
extern void set_close_on_exec(unsigned int fd, int flag);

0 comments on commit 1d51222

Please sign in to comment.
You can’t perform that action at this time.