Lines Matching refs:filp
35 static int setfl(int fd, struct file * filp, unsigned long arg)
37 struct inode * inode = file_inode(filp);
44 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
48 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
59 if (!filp->f_mapping || !filp->f_mapping->a_ops ||
60 !filp->f_mapping->a_ops->direct_IO)
64 if (filp->f_op->check_flags)
65 error = filp->f_op->check_flags(arg);
72 if (((arg ^ filp->f_flags) & FASYNC) && filp->f_op->fasync) {
73 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
79 spin_lock(&filp->f_lock);
80 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
81 spin_unlock(&filp->f_lock);
87 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
90 write_lock_irq(&filp->f_owner.lock);
91 if (force || !filp->f_owner.pid) {
92 put_pid(filp->f_owner.pid);
93 filp->f_owner.pid = get_pid(pid);
94 filp->f_owner.pid_type = type;
98 filp->f_owner.uid = cred->uid;
99 filp->f_owner.euid = cred->euid;
102 write_unlock_irq(&filp->f_owner.lock);
105 void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
108 security_file_set_fowner(filp);
109 f_modown(filp, pid, type, force);
113 int f_setown(struct file *filp, unsigned long arg, int force)
137 __f_setown(filp, pid, type, force);
144 void f_delown(struct file *filp)
146 f_modown(filp, NULL, PIDTYPE_TGID, 1);
149 pid_t f_getown(struct file *filp)
153 read_lock_irq(&filp->f_owner.lock);
155 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) {
156 pid = pid_vnr(filp->f_owner.pid);
157 if (filp->f_owner.pid_type == PIDTYPE_PGID)
161 read_unlock_irq(&filp->f_owner.lock);
165 static int f_setown_ex(struct file *filp, unsigned long arg)
199 __f_setown(filp, pid, type, 1);
205 static int f_getown_ex(struct file *filp, unsigned long arg)
211 read_lock_irq(&filp->f_owner.lock);
213 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type))
214 owner.pid = pid_vnr(filp->f_owner.pid);
216 switch (filp->f_owner.pid_type) {
234 read_unlock_irq(&filp->f_owner.lock);
245 static int f_getowner_uids(struct file *filp, unsigned long arg)
252 read_lock_irq(&filp->f_owner.lock);
253 src[0] = from_kuid(user_ns, filp->f_owner.uid);
254 src[1] = from_kuid(user_ns, filp->f_owner.euid);
255 read_unlock_irq(&filp->f_owner.lock);
263 static int f_getowner_uids(struct file *filp, unsigned long arg)
331 struct file *filp)
339 err = f_dupfd(arg, filp, 0);
342 err = f_dupfd(arg, filp, O_CLOEXEC);
352 err = filp->f_flags;
355 err = setfl(fd, filp, arg);
364 err = fcntl_getlk(filp, cmd, &flock);
378 err = fcntl_setlk(fd, filp, cmd, &flock);
388 err = f_getown(filp);
392 err = f_setown(filp, arg, 1);
395 err = f_getown_ex(filp, arg);
398 err = f_setown_ex(filp, arg);
401 err = f_getowner_uids(filp, arg);
404 err = filp->f_owner.signum;
412 filp->f_owner.signum = arg;
415 err = fcntl_getlease(filp);
418 err = fcntl_setlease(fd, filp, arg);
421 err = fcntl_dirnotify(fd, filp, arg);
425 err = pipe_fcntl(filp, cmd, arg);
429 err = memfd_fcntl(filp, cmd, arg);
435 err = fcntl_rw_hint(filp, cmd, arg);
876 * match the state "is the filp on a fasync list".
879 int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
884 spin_lock(&filp->f_lock);
887 if (fa->fa_file != filp)
896 filp->f_flags &= ~FASYNC;
901 spin_unlock(&filp->f_lock);
925 * match the state "is the filp on a fasync list".
927 struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasync_struct **fapp, struct fasync_struct *new)
931 spin_lock(&filp->f_lock);
934 if (fa->fa_file != filp)
945 new->fa_file = filp;
949 filp->f_flags |= FASYNC;
953 spin_unlock(&filp->f_lock);
961 static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp)
976 if (fasync_insert_entry(fd, filp, fapp, new)) {
990 int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
993 return fasync_remove_entry(filp, fapp);
994 return fasync_add_entry(fd, filp, fapp);