mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
Merge pull request #8 from zhangn1985/sun8i
fs/file_table: split fget_light
This commit is contained in:
@@ -322,7 +322,7 @@ 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;
|
||||
@@ -330,13 +330,13 @@ struct file *fget_light(unsigned int fd, int *fput_needed)
|
||||
*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);
|
||||
|
||||
Reference in New Issue
Block a user