Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright 1997-1998 Transmeta Corporation - All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *  Copyright 2005-2006 Ian Kent <raven@themaw.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) /* Internal header file for autofs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/auto_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/auto_dev-ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/magic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /* This is the range of ioctl() numbers we claim as ours */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define AUTOFS_IOC_FIRST     AUTOFS_IOC_READY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define AUTOFS_IOC_COUNT     32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define AUTOFS_DEV_IOCTL_IOC_FIRST	(AUTOFS_DEV_IOCTL_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define AUTOFS_DEV_IOCTL_IOC_COUNT \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	(AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD - AUTOFS_DEV_IOCTL_VERSION_CMD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #ifdef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #undef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define pr_fmt(fmt) KBUILD_MODNAME ":pid:%d:%s: " fmt, current->pid, __func__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) extern struct file_system_type autofs_fs_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * Unified info structure.  This is pointed to by both the dentry and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * inode structures.  Each file in the filesystem has an instance of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * structure.  It holds a reference to the dentry, so dentries are never
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * flushed while the file exists.  All name lookups are dealt with at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * dentry level, although the filesystem can interfere in the validation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * process.  Readdir is implemented by traversing the dentry lists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) struct autofs_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	struct dentry	*dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	struct inode	*inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int		flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct completion expire_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct list_head active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct list_head expiring;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct autofs_sb_info *sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	unsigned long last_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define AUTOFS_INF_EXPIRING	(1<<0) /* dentry in the process of expiring */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define AUTOFS_INF_WANT_EXPIRE	(1<<1) /* the dentry is being considered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 					* for expiry, so RCU_walk is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 					* not permitted.  If it progresses to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 					* actual expiry attempt, the flag is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 					* not cleared when EXPIRING is set -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					* in that case it gets cleared only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 					* when it comes to clearing EXPIRING.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 					*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define AUTOFS_INF_PENDING	(1<<2) /* dentry pending mount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) struct autofs_wait_queue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	wait_queue_head_t queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct autofs_wait_queue *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	autofs_wqt_t wait_queue_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	/* We use the following to see what we are waiting for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct qstr name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	u32 dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	u64 ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	pid_t pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	pid_t tgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* This is for status reporting upon return */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	unsigned int wait_ctr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define AUTOFS_SBI_MAGIC 0x6d4a556d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define AUTOFS_SBI_CATATONIC	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define AUTOFS_SBI_STRICTEXPIRE 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define AUTOFS_SBI_IGNORE	0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct autofs_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	u32 magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	int pipefd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct file *pipe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct pid *oz_pgrp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	int version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	int sub_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	int min_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	int max_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	unsigned long exp_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	unsigned int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct mutex wq_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct mutex pipe_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	spinlock_t fs_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct autofs_wait_queue *queues; /* Wait queue pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	spinlock_t lookup_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct list_head active_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct list_head expiring_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return (struct autofs_sb_info *)(sb->s_fs_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return (struct autofs_info *)(dentry->d_fsdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /* autofs_oz_mode(): do we see the man behind the curtain?  (The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * processes which do manipulations for us in user space sees the raw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  * filesystem without "magic".)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static inline int autofs_oz_mode(struct autofs_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	return ((sbi->flags & AUTOFS_SBI_CATATONIC) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		 task_pgrp(current) == sbi->oz_pgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct inode *autofs_get_inode(struct super_block *, umode_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void autofs_free_ino(struct autofs_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Expiration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) int is_autofs_dentry(struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int autofs_expire_wait(const struct path *path, int rcu_walk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int autofs_expire_run(struct super_block *, struct vfsmount *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		      struct autofs_sb_info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		      struct autofs_packet_expire __user *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			   struct autofs_sb_info *sbi, unsigned int how);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int autofs_expire_multi(struct super_block *, struct vfsmount *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			struct autofs_sb_info *, int __user *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* Device node initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int autofs_dev_ioctl_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void autofs_dev_ioctl_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Operations structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern const struct inode_operations autofs_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) extern const struct inode_operations autofs_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) extern const struct file_operations autofs_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) extern const struct file_operations autofs_root_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) extern const struct dentry_operations autofs_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /* VFS automount flags management functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static inline void __managed_dentry_set_managed(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	dentry->d_flags |= (DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static inline void managed_dentry_set_managed(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	spin_lock(&dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	__managed_dentry_set_managed(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	spin_unlock(&dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static inline void __managed_dentry_clear_managed(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	dentry->d_flags &= ~(DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) static inline void managed_dentry_clear_managed(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	spin_lock(&dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	__managed_dentry_clear_managed(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	spin_unlock(&dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* Initializing function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) int autofs_fill_super(struct super_block *, void *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct autofs_info *autofs_new_ino(struct autofs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) void autofs_clean_ino(struct autofs_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) static inline int autofs_prepare_pipe(struct file *pipe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (!(pipe->f_mode & FMODE_CAN_WRITE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	if (!S_ISFIFO(file_inode(pipe)->i_mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	/* We want a packet pipe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	pipe->f_flags |= O_DIRECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	/* We don't expect -EAGAIN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	pipe->f_flags &= ~O_NONBLOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Queue management functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) int autofs_wait(struct autofs_sb_info *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		 const struct path *, enum autofs_notify);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) int autofs_wait_release(struct autofs_sb_info *, autofs_wqt_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) void autofs_catatonic_mode(struct autofs_sb_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static inline u32 autofs_get_dev(struct autofs_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return new_encode_dev(sbi->sb->s_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline u64 autofs_get_ino(struct autofs_sb_info *sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	return d_inode(sbi->sb->s_root)->i_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static inline void __autofs_add_expiring(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct autofs_info *ino = autofs_dentry_ino(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	if (ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		if (list_empty(&ino->expiring))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			list_add(&ino->expiring, &sbi->expiring_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static inline void autofs_add_expiring(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	struct autofs_info *ino = autofs_dentry_ino(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	if (ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		spin_lock(&sbi->lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		if (list_empty(&ino->expiring))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			list_add(&ino->expiring, &sbi->expiring_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		spin_unlock(&sbi->lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline void autofs_del_expiring(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	struct autofs_info *ino = autofs_dentry_ino(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		spin_lock(&sbi->lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		if (!list_empty(&ino->expiring))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			list_del_init(&ino->expiring);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		spin_unlock(&sbi->lookup_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) void autofs_kill_sb(struct super_block *);