Lines Matching refs:filp
37 static int setfl(int fd, struct file * filp, unsigned int arg)
39 struct inode * inode = file_inode(filp);
46 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
50 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
51 if (!inode_owner_or_capable(file_mnt_idmap(filp), inode))
62 !(filp->f_mode & FMODE_CAN_ODIRECT))
65 if (filp->f_op->check_flags)
66 error = filp->f_op->check_flags(arg);
73 if (((arg ^ filp->f_flags) & FASYNC) && filp->f_op->fasync) {
74 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
80 spin_lock(&filp->f_lock);
81 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
82 filp->f_iocb_flags = iocb_flags(filp);
83 spin_unlock(&filp->f_lock);
89 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
92 write_lock_irq(&filp->f_owner.lock);
93 if (force || !filp->f_owner.pid) {
94 put_pid(filp->f_owner.pid);
95 filp->f_owner.pid = get_pid(pid);
96 filp->f_owner.pid_type = type;
100 filp->f_owner.uid = cred->uid;
101 filp->f_owner.euid = cred->euid;
104 write_unlock_irq(&filp->f_owner.lock);
107 void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
110 security_file_set_fowner(filp);
111 f_modown(filp, pid, type, force);
115 int f_setown(struct file *filp, int who, int force)
139 __f_setown(filp, pid, type, force);
146 void f_delown(struct file *filp)
148 f_modown(filp, NULL, PIDTYPE_TGID, 1);
151 pid_t f_getown(struct file *filp)
155 read_lock_irq(&filp->f_owner.lock);
157 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) {
158 pid = pid_vnr(filp->f_owner.pid);
159 if (filp->f_owner.pid_type == PIDTYPE_PGID)
163 read_unlock_irq(&filp->f_owner.lock);
167 static int f_setown_ex(struct file *filp, unsigned long arg)
201 __f_setown(filp, pid, type, 1);
207 static int f_getown_ex(struct file *filp, unsigned long arg)
213 read_lock_irq(&filp->f_owner.lock);
215 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type))
216 owner.pid = pid_vnr(filp->f_owner.pid);
218 switch (filp->f_owner.pid_type) {
236 read_unlock_irq(&filp->f_owner.lock);
247 static int f_getowner_uids(struct file *filp, unsigned long arg)
254 read_lock_irq(&filp->f_owner.lock);
255 src[0] = from_kuid(user_ns, filp->f_owner.uid);
256 src[1] = from_kuid(user_ns, filp->f_owner.euid);
257 read_unlock_irq(&filp->f_owner.lock);
265 static int f_getowner_uids(struct file *filp, unsigned long arg)
315 struct file *filp)
324 err = f_dupfd(argi, filp, 0);
327 err = f_dupfd(argi, filp, O_CLOEXEC);
337 err = filp->f_flags;
340 err = setfl(fd, filp, argi);
349 err = fcntl_getlk(filp, cmd, &flock);
363 err = fcntl_setlk(fd, filp, cmd, &flock);
373 err = f_getown(filp);
377 err = f_setown(filp, argi, 1);
380 err = f_getown_ex(filp, arg);
383 err = f_setown_ex(filp, arg);
386 err = f_getowner_uids(filp, arg);
389 err = filp->f_owner.signum;
397 filp->f_owner.signum = argi;
400 err = fcntl_getlease(filp);
403 err = fcntl_setlease(fd, filp, argi);
406 err = fcntl_dirnotify(fd, filp, argi);
410 err = pipe_fcntl(filp, cmd, argi);
414 err = memfd_fcntl(filp, cmd, argi);
418 err = fcntl_rw_hint(filp, cmd, arg);
859 * match the state "is the filp on a fasync list".
862 int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
867 spin_lock(&filp->f_lock);
870 if (fa->fa_file != filp)
879 filp->f_flags &= ~FASYNC;
884 spin_unlock(&filp->f_lock);
908 * match the state "is the filp on a fasync list".
910 struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasync_struct **fapp, struct fasync_struct *new)
914 spin_lock(&filp->f_lock);
917 if (fa->fa_file != filp)
928 new->fa_file = filp;
932 filp->f_flags |= FASYNC;
936 spin_unlock(&filp->f_lock);
944 static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp)
959 if (fasync_insert_entry(fd, filp, fapp, new)) {
973 int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
976 return fasync_remove_entry(filp, fapp);
977 return fasync_add_entry(fd, filp, fapp);