Lines Matching refs:filp

38 static int setfl(int fd, struct file * filp, unsigned int arg)
40 struct inode * inode = file_inode(filp);
47 if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode))
51 if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
52 if (!inode_owner_or_capable(file_mnt_idmap(filp), inode))
63 !(filp->f_mode & FMODE_CAN_ODIRECT))
66 if (filp->f_op->check_flags)
67 error = filp->f_op->check_flags(arg);
74 if (((arg ^ filp->f_flags) & FASYNC) && filp->f_op->fasync) {
75 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
81 spin_lock(&filp->f_lock);
82 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
83 filp->f_iocb_flags = iocb_flags(filp);
84 spin_unlock(&filp->f_lock);
90 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
93 write_lock_irq(&filp->f_owner.lock);
94 if (force || !filp->f_owner.pid) {
95 put_pid(filp->f_owner.pid);
96 filp->f_owner.pid = get_pid(pid);
97 filp->f_owner.pid_type = type;
101 filp->f_owner.uid = cred->uid;
102 filp->f_owner.euid = cred->euid;
105 write_unlock_irq(&filp->f_owner.lock);
108 void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
111 security_file_set_fowner(filp);
112 f_modown(filp, pid, type, force);
116 int f_setown(struct file *filp, int who, int force)
140 __f_setown(filp, pid, type, force);
147 void f_delown(struct file *filp)
149 f_modown(filp, NULL, PIDTYPE_TGID, 1);
152 pid_t f_getown(struct file *filp)
156 read_lock_irq(&filp->f_owner.lock);
158 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type)) {
159 pid = pid_vnr(filp->f_owner.pid);
160 if (filp->f_owner.pid_type == PIDTYPE_PGID)
164 read_unlock_irq(&filp->f_owner.lock);
168 static int f_setown_ex(struct file *filp, unsigned long arg)
202 __f_setown(filp, pid, type, 1);
208 static int f_getown_ex(struct file *filp, unsigned long arg)
214 read_lock_irq(&filp->f_owner.lock);
216 if (pid_task(filp->f_owner.pid, filp->f_owner.pid_type))
217 owner.pid = pid_vnr(filp->f_owner.pid);
219 switch (filp->f_owner.pid_type) {
237 read_unlock_irq(&filp->f_owner.lock);
248 static int f_getowner_uids(struct file *filp, unsigned long arg)
255 read_lock_irq(&filp->f_owner.lock);
256 src[0] = from_kuid(user_ns, filp->f_owner.uid);
257 src[1] = from_kuid(user_ns, filp->f_owner.euid);
258 read_unlock_irq(&filp->f_owner.lock);
266 static int f_getowner_uids(struct file *filp, unsigned long arg)
331 static long f_dupfd_query(int fd, struct file *filp)
343 return f.file == filp;
347 struct file *filp)
356 err = f_dupfd(argi, filp, 0);
359 err = f_dupfd(argi, filp, O_CLOEXEC);
362 err = f_dupfd_query(argi, filp);
372 err = filp->f_flags;
375 err = setfl(fd, filp, argi);
384 err = fcntl_getlk(filp, cmd, &flock);
398 err = fcntl_setlk(fd, filp, cmd, &flock);
408 err = f_getown(filp);
412 err = f_setown(filp, argi, 1);
415 err = f_getown_ex(filp, arg);
418 err = f_setown_ex(filp, arg);
421 err = f_getowner_uids(filp, arg);
424 err = filp->f_owner.signum;
432 filp->f_owner.signum = argi;
435 err = fcntl_getlease(filp);
438 err = fcntl_setlease(fd, filp, argi);
441 err = fcntl_dirnotify(fd, filp, argi);
445 err = pipe_fcntl(filp, cmd, argi);
449 err = memfd_fcntl(filp, cmd, argi);
452 err = fcntl_get_rw_hint(filp, cmd, arg);
455 err = fcntl_set_rw_hint(filp, cmd, arg);
891 * match the state "is the filp on a fasync list".
894 int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
899 spin_lock(&filp->f_lock);
902 if (fa->fa_file != filp)
911 filp->f_flags &= ~FASYNC;
916 spin_unlock(&filp->f_lock);
940 * match the state "is the filp on a fasync list".
942 struct fasync_struct *fasync_insert_entry(int fd, struct file *filp, struct fasync_struct **fapp, struct fasync_struct *new)
946 spin_lock(&filp->f_lock);
949 if (fa->fa_file != filp)
960 new->fa_file = filp;
964 filp->f_flags |= FASYNC;
968 spin_unlock(&filp->f_lock);
976 static int fasync_add_entry(int fd, struct file *filp, struct fasync_struct **fapp)
991 if (fasync_insert_entry(fd, filp, fapp, new)) {
1005 int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
1008 return fasync_remove_entry(filp, fapp);
1009 return fasync_add_entry(fd, filp, fapp);