@@ -1053,6 +1053,19 @@ void __f_unlock_pos(struct file *f)
mutex_unlock(&f->f_pos_lock);
}
+int file_pos_lock_nowait(struct file *file, bool nowait)
+{
+ if (!(file->f_mode & FMODE_ATOMIC_POS))
+ return 0;
+
+ if (!nowait)
+ mutex_lock(&file->f_pos_lock);
+ else if (!mutex_trylock(&file->f_pos_lock))
+ return -EAGAIN;
+
+ return 1;
+}
+
/*
* We only lock f_pos if we have threads or if the file might be
* shared with another process. In both cases we'll have an elevated
@@ -81,6 +81,8 @@ static inline void fdput_pos(struct fd f)
fdput(f);
}
+extern int file_pos_lock_nowait(struct file *file, bool nowait);
+
DEFINE_CLASS(fd, struct fd, fdput(_T), fdget(fd), int fd)
extern int f_dupfd(unsigned int from, struct file *file, unsigned flags);