Lines Matching refs:filp

37 static int setfl(int fd, struct file * filp, unsigned long arg)  in setfl()  argument
39 struct inode * inode = file_inode(filp); in setfl()
46 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) in setfl()
50 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME)) in setfl()
51 if (!inode_owner_or_capable(file_mnt_idmap(filp), inode)) in setfl()
62 !(filp->f_mode & FMODE_CAN_ODIRECT)) in setfl()
65 if (filp->f_op->check_flags) in setfl()
66 error = filp->f_op->check_flags(arg); in setfl()
73 if (((arg ^ filp->f_flags) & FASYNC) && filp->f_op->fasync) { in setfl()
74 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); in setfl()
80 spin_lock(&filp->f_lock); in setfl()
81 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); in setfl()
82 filp->f_iocb_flags = iocb_flags(filp); in setfl()
83 spin_unlock(&filp->f_lock); in setfl()
89 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, in f_modown() argument
92 write_lock_irq(&filp->f_owner.lock); in f_modown()
93 if (force || !filp->f_owner.pid) { in f_modown()
94 put_pid(filp->f_owner.pid); in f_modown()
95 filp->f_owner.pid = get_pid(pid); in f_modown()
96 filp->f_owner.pid_type = type; in f_modown()
100 filp->f_owner.uid = cred->uid; in f_modown()
101 filp->f_owner.euid = cred->euid; in f_modown()
104 write_unlock_irq(&filp->f_owner.lock); in f_modown()
107 void __f_setown(struct file *filp, struct pid *pid, enum pid_type type, in __f_setown() argument
110 security_file_set_fowner(filp); in __f_setown()
111 f_modown(filp, pid, type, force); in __f_setown()
115 int f_setown(struct file *filp, unsigned long arg, int force) in f_setown() argument
139 __f_setown(filp, pid, type, force); in f_setown()
146 void f_delown(struct file *filp) in f_delown() argument
148 f_modown(filp, NULL, PIDTYPE_TGID, 1); in f_delown()
151 pid_t f_getown(struct file *filp) in f_getown() argument
155 read_lock_irq(&filp->f_owner.lock); in f_getown()
157 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) { in f_getown()
158 pid = pid_vnr(filp->f_owner.pid); in f_getown()
159 if (filp->f_owner.pid_type == PIDTYPE_PGID) in f_getown()
163 read_unlock_irq(&filp->f_owner.lock); in f_getown()
167 static int f_setown_ex(struct file *filp, unsigned long arg) in f_setown_ex() argument
201 __f_setown(filp, pid, type, 1); in f_setown_ex()
207 static int f_getown_ex(struct file *filp, unsigned long arg) in f_getown_ex() argument
213 read_lock_irq(&filp->f_owner.lock); in f_getown_ex()
215 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) in f_getown_ex()
216 owner.pid = pid_vnr(filp->f_owner.pid); in f_getown_ex()
218 switch (filp->f_owner.pid_type) { in f_getown_ex()
236 read_unlock_irq(&filp->f_owner.lock); in f_getown_ex()
247 static int f_getowner_uids(struct file *filp, unsigned long arg) in f_getowner_uids() argument
254 read_lock_irq(&filp->f_owner.lock); in f_getowner_uids()
255 src[0] = from_kuid(user_ns, filp->f_owner.uid); in f_getowner_uids()
256 src[1] = from_kuid(user_ns, filp->f_owner.euid); in f_getowner_uids()
257 read_unlock_irq(&filp->f_owner.lock); in f_getowner_uids()
265 static int f_getowner_uids(struct file *filp, unsigned long arg) in f_getowner_uids() argument
317 struct file *filp) in do_fcntl() argument
325 err = f_dupfd(arg, filp, 0); in do_fcntl()
328 err = f_dupfd(arg, filp, O_CLOEXEC); in do_fcntl()
338 err = filp->f_flags; in do_fcntl()
341 err = setfl(fd, filp, arg); in do_fcntl()
350 err = fcntl_getlk(filp, cmd, &flock); in do_fcntl()
364 err = fcntl_setlk(fd, filp, cmd, &flock); in do_fcntl()
374 err = f_getown(filp); in do_fcntl()
378 err = f_setown(filp, arg, 1); in do_fcntl()
381 err = f_getown_ex(filp, arg); in do_fcntl()
384 err = f_setown_ex(filp, arg); in do_fcntl()
387 err = f_getowner_uids(filp, arg); in do_fcntl()
390 err = filp->f_owner.signum; in do_fcntl()
398 filp->f_owner.signum = arg; in do_fcntl()
401 err = fcntl_getlease(filp); in do_fcntl()
404 err = fcntl_setlease(fd, filp, arg); in do_fcntl()
407 err = fcntl_dirnotify(fd, filp, arg); in do_fcntl()
411 err = pipe_fcntl(filp, cmd, arg); in do_fcntl()
415 err = memfd_fcntl(filp, cmd, arg); in do_fcntl()
419 err = fcntl_rw_hint(filp, cmd, arg); in do_fcntl()
863 int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp) in fasync_remove_entry() argument
868 spin_lock(&filp->f_lock); in fasync_remove_entry()
871 if (fa->fa_file != filp) in fasync_remove_entry()
880 filp->f_flags &= ~FASYNC; in fasync_remove_entry()
885 spin_unlock(&filp->f_lock); in fasync_remove_entry()
911 struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasync_struct **fapp, s… in fasync_insert_entry() argument
915 spin_lock(&filp->f_lock); in fasync_insert_entry()
918 if (fa->fa_file != filp) in fasync_insert_entry()
929 new->fa_file = filp; in fasync_insert_entry()
933 filp->f_flags |= FASYNC; in fasync_insert_entry()
937 spin_unlock(&filp->f_lock); in fasync_insert_entry()
945 static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp) in fasync_add_entry() argument
960 if (fasync_insert_entry(fd, filp, fapp, new)) { in fasync_add_entry()
974 int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp) in fasync_helper() argument
977 return fasync_remove_entry(filp, fapp); in fasync_helper()
978 return fasync_add_entry(fd, filp, fapp); in fasync_helper()