Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * net/sunrpc/rpc_pipe.c |
| 3 | * |
| 4 | * Userland/kernel interface for rpcauth_gss. |
| 5 | * Code shamelessly plagiarized from fs/nfsd/nfsctl.c |
Rolf Eike Beer | d51fe1b | 2005-09-02 08:59:25 +0200 | [diff] [blame] | 6 | * and fs/sysfs/inode.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
| 8 | * Copyright (c) 2002, Trond Myklebust <trond.myklebust@fys.uio.no> |
| 9 | * |
| 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/slab.h> |
| 13 | #include <linux/string.h> |
| 14 | #include <linux/pagemap.h> |
| 15 | #include <linux/mount.h> |
| 16 | #include <linux/namei.h> |
Trond Myklebust | 50e437d | 2007-06-07 22:44:34 -0400 | [diff] [blame] | 17 | #include <linux/fsnotify.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/kernel.h> |
| 19 | |
| 20 | #include <asm/ioctls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/poll.h> |
| 22 | #include <linux/wait.h> |
| 23 | #include <linux/seq_file.h> |
| 24 | |
| 25 | #include <linux/sunrpc/clnt.h> |
| 26 | #include <linux/workqueue.h> |
| 27 | #include <linux/sunrpc/rpc_pipe_fs.h> |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 28 | #include <linux/sunrpc/cache.h> |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 29 | #include <linux/nsproxy.h> |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 30 | #include <linux/notifier.h> |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 31 | |
| 32 | #include "netns.h" |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 33 | #include "sunrpc.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Stanislav Kinsbursky | efc46bf | 2011-12-26 15:39:47 +0300 | [diff] [blame] | 35 | #define RPCDBG_FACILITY RPCDBG_DEBUG |
| 36 | |
| 37 | #define NET_NAME(net) ((net == &init_net) ? " (init_net)" : "") |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | static struct file_system_type rpc_pipe_fs_type; |
| 40 | |
| 41 | |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 42 | static struct kmem_cache *rpc_inode_cachep __read_mostly; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | #define RPC_UPCALL_TIMEOUT (30*HZ) |
| 45 | |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 46 | static BLOCKING_NOTIFIER_HEAD(rpc_pipefs_notifier_list); |
| 47 | |
| 48 | int rpc_pipefs_notifier_register(struct notifier_block *nb) |
| 49 | { |
| 50 | return blocking_notifier_chain_cond_register(&rpc_pipefs_notifier_list, nb); |
| 51 | } |
| 52 | EXPORT_SYMBOL_GPL(rpc_pipefs_notifier_register); |
| 53 | |
| 54 | void rpc_pipefs_notifier_unregister(struct notifier_block *nb) |
| 55 | { |
| 56 | blocking_notifier_chain_unregister(&rpc_pipefs_notifier_list, nb); |
| 57 | } |
| 58 | EXPORT_SYMBOL_GPL(rpc_pipefs_notifier_unregister); |
| 59 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 60 | static void rpc_purge_list(struct rpc_pipe *pipe, struct list_head *head, |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 61 | void (*destroy_msg)(struct rpc_pipe_msg *), int err) |
Trond Myklebust | b3eb67a | 2005-11-25 17:10:11 -0500 | [diff] [blame] | 62 | { |
| 63 | struct rpc_pipe_msg *msg; |
Trond Myklebust | b3eb67a | 2005-11-25 17:10:11 -0500 | [diff] [blame] | 64 | |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 65 | if (list_empty(head)) |
| 66 | return; |
| 67 | do { |
Trond Myklebust | b3eb67a | 2005-11-25 17:10:11 -0500 | [diff] [blame] | 68 | msg = list_entry(head->next, struct rpc_pipe_msg, list); |
Trond Myklebust | 5a67657 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 69 | list_del_init(&msg->list); |
Trond Myklebust | b3eb67a | 2005-11-25 17:10:11 -0500 | [diff] [blame] | 70 | msg->errno = err; |
| 71 | destroy_msg(msg); |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 72 | } while (!list_empty(head)); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 73 | wake_up(&pipe->waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 77 | rpc_timeout_upcall_queue(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 79 | LIST_HEAD(free_list); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 80 | struct rpc_pipe *pipe = |
| 81 | container_of(work, struct rpc_pipe, queue_timeout.work); |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 82 | void (*destroy_msg)(struct rpc_pipe_msg *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 84 | spin_lock(&pipe->lock); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 85 | destroy_msg = pipe->ops->destroy_msg; |
| 86 | if (pipe->nreaders == 0) { |
| 87 | list_splice_init(&pipe->pipe, &free_list); |
| 88 | pipe->pipelen = 0; |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 89 | } |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 90 | spin_unlock(&pipe->lock); |
| 91 | rpc_purge_list(pipe, &free_list, destroy_msg, -ETIMEDOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Peng Tao | c122515 | 2011-09-22 21:50:10 -0400 | [diff] [blame] | 94 | ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg, |
| 95 | char __user *dst, size_t buflen) |
| 96 | { |
| 97 | char *data = (char *)msg->data + msg->copied; |
| 98 | size_t mlen = min(msg->len - msg->copied, buflen); |
| 99 | unsigned long left; |
| 100 | |
| 101 | left = copy_to_user(dst, data, mlen); |
| 102 | if (left == mlen) { |
| 103 | msg->errno = -EFAULT; |
| 104 | return -EFAULT; |
| 105 | } |
| 106 | |
| 107 | mlen -= left; |
| 108 | msg->copied += mlen; |
| 109 | msg->errno = 0; |
| 110 | return mlen; |
| 111 | } |
| 112 | EXPORT_SYMBOL_GPL(rpc_pipe_generic_upcall); |
| 113 | |
J. Bruce Fields | 93a44a7 | 2007-11-06 13:06:03 -0500 | [diff] [blame] | 114 | /** |
Ben Hutchings | 1a5778a | 2010-02-14 22:35:47 -0800 | [diff] [blame] | 115 | * rpc_queue_upcall - queue an upcall message to userspace |
J. Bruce Fields | 93a44a7 | 2007-11-06 13:06:03 -0500 | [diff] [blame] | 116 | * @inode: inode of upcall pipe on which to queue given message |
| 117 | * @msg: message to queue |
| 118 | * |
| 119 | * Call with an @inode created by rpc_mkpipe() to queue an upcall. |
| 120 | * A userspace process may then later read the upcall by performing a |
| 121 | * read on an open file for this inode. It is up to the caller to |
| 122 | * initialize the fields of @msg (other than @msg->list) appropriately. |
| 123 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | int |
Stanislav Kinsbursky | d706ed1 | 2011-12-26 15:43:49 +0300 | [diff] [blame] | 125 | rpc_queue_upcall(struct rpc_pipe *pipe, struct rpc_pipe_msg *msg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Trond Myklebust | 6070fe6 | 2005-10-27 22:12:46 -0400 | [diff] [blame] | 127 | int res = -EPIPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 129 | spin_lock(&pipe->lock); |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 130 | if (pipe->nreaders) { |
| 131 | list_add_tail(&msg->list, &pipe->pipe); |
| 132 | pipe->pipelen += msg->len; |
Trond Myklebust | 6070fe6 | 2005-10-27 22:12:46 -0400 | [diff] [blame] | 133 | res = 0; |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 134 | } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) { |
| 135 | if (list_empty(&pipe->pipe)) |
Trond Myklebust | 24c5d9d | 2006-03-20 13:44:08 -0500 | [diff] [blame] | 136 | queue_delayed_work(rpciod_workqueue, |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 137 | &pipe->queue_timeout, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | RPC_UPCALL_TIMEOUT); |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 139 | list_add_tail(&msg->list, &pipe->pipe); |
| 140 | pipe->pipelen += msg->len; |
Trond Myklebust | 6070fe6 | 2005-10-27 22:12:46 -0400 | [diff] [blame] | 141 | res = 0; |
| 142 | } |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 143 | spin_unlock(&pipe->lock); |
| 144 | wake_up(&pipe->waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | return res; |
| 146 | } |
Trond Myklebust | 468039e | 2008-12-23 15:21:31 -0500 | [diff] [blame] | 147 | EXPORT_SYMBOL_GPL(rpc_queue_upcall); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
Trond Myklebust | 6070fe6 | 2005-10-27 22:12:46 -0400 | [diff] [blame] | 149 | static inline void |
| 150 | rpc_inode_setowner(struct inode *inode, void *private) |
| 151 | { |
| 152 | RPC_I(inode)->private = private; |
| 153 | } |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | static void |
| 156 | rpc_close_pipes(struct inode *inode) |
| 157 | { |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 158 | struct rpc_pipe *pipe = RPC_I(inode)->pipe; |
\"J. Bruce Fields\ | e712804 | 2008-12-23 16:09:47 -0500 | [diff] [blame] | 159 | int need_release; |
Stanislav Kinsbursky | ad6b134 | 2012-01-10 16:12:38 +0400 | [diff] [blame] | 160 | LIST_HEAD(free_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 162 | mutex_lock(&inode->i_mutex); |
Stanislav Kinsbursky | ad6b134 | 2012-01-10 16:12:38 +0400 | [diff] [blame] | 163 | spin_lock(&pipe->lock); |
| 164 | need_release = pipe->nreaders != 0 || pipe->nwriters != 0; |
| 165 | pipe->nreaders = 0; |
| 166 | list_splice_init(&pipe->in_upcall, &free_list); |
| 167 | list_splice_init(&pipe->pipe, &free_list); |
| 168 | pipe->pipelen = 0; |
| 169 | pipe->dentry = NULL; |
| 170 | spin_unlock(&pipe->lock); |
| 171 | rpc_purge_list(pipe, &free_list, pipe->ops->destroy_msg, -EPIPE); |
| 172 | pipe->nwriters = 0; |
| 173 | if (need_release && pipe->ops->release_pipe) |
| 174 | pipe->ops->release_pipe(inode); |
| 175 | cancel_delayed_work_sync(&pipe->queue_timeout); |
Trond Myklebust | 6070fe6 | 2005-10-27 22:12:46 -0400 | [diff] [blame] | 176 | rpc_inode_setowner(inode, NULL); |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 177 | RPC_I(inode)->pipe = NULL; |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 178 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | static struct inode * |
| 182 | rpc_alloc_inode(struct super_block *sb) |
| 183 | { |
| 184 | struct rpc_inode *rpci; |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 185 | rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | if (!rpci) |
| 187 | return NULL; |
| 188 | return &rpci->vfs_inode; |
| 189 | } |
| 190 | |
| 191 | static void |
Nick Piggin | fa0d7e3d | 2011-01-07 17:49:49 +1100 | [diff] [blame] | 192 | rpc_i_callback(struct rcu_head *head) |
| 193 | { |
| 194 | struct inode *inode = container_of(head, struct inode, i_rcu); |
Nick Piggin | fa0d7e3d | 2011-01-07 17:49:49 +1100 | [diff] [blame] | 195 | kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); |
| 196 | } |
| 197 | |
| 198 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | rpc_destroy_inode(struct inode *inode) |
| 200 | { |
Nick Piggin | fa0d7e3d | 2011-01-07 17:49:49 +1100 | [diff] [blame] | 201 | call_rcu(&inode->i_rcu, rpc_i_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static int |
| 205 | rpc_pipe_open(struct inode *inode, struct file *filp) |
| 206 | { |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 207 | struct rpc_pipe *pipe; |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 208 | int first_open; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | int res = -ENXIO; |
| 210 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 211 | mutex_lock(&inode->i_mutex); |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 212 | pipe = RPC_I(inode)->pipe; |
| 213 | if (pipe == NULL) |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 214 | goto out; |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 215 | first_open = pipe->nreaders == 0 && pipe->nwriters == 0; |
| 216 | if (first_open && pipe->ops->open_pipe) { |
| 217 | res = pipe->ops->open_pipe(inode); |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 218 | if (res) |
| 219 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 221 | if (filp->f_mode & FMODE_READ) |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 222 | pipe->nreaders++; |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 223 | if (filp->f_mode & FMODE_WRITE) |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 224 | pipe->nwriters++; |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 225 | res = 0; |
| 226 | out: |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 227 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | return res; |
| 229 | } |
| 230 | |
| 231 | static int |
| 232 | rpc_pipe_release(struct inode *inode, struct file *filp) |
| 233 | { |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 234 | struct rpc_pipe *pipe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | struct rpc_pipe_msg *msg; |
\"J. Bruce Fields\ | e712804 | 2008-12-23 16:09:47 -0500 | [diff] [blame] | 236 | int last_close; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 238 | mutex_lock(&inode->i_mutex); |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 239 | pipe = RPC_I(inode)->pipe; |
| 240 | if (pipe == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | goto out; |
Joe Perches | 655b5bb | 2010-09-04 18:52:53 -0700 | [diff] [blame] | 242 | msg = filp->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | if (msg != NULL) { |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 244 | spin_lock(&pipe->lock); |
Trond Myklebust | 48e4918 | 2005-12-19 17:11:22 -0500 | [diff] [blame] | 245 | msg->errno = -EAGAIN; |
Trond Myklebust | 5a67657 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 246 | list_del_init(&msg->list); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 247 | spin_unlock(&pipe->lock); |
| 248 | pipe->ops->destroy_msg(msg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | if (filp->f_mode & FMODE_WRITE) |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 251 | pipe->nwriters --; |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 252 | if (filp->f_mode & FMODE_READ) { |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 253 | pipe->nreaders --; |
| 254 | if (pipe->nreaders == 0) { |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 255 | LIST_HEAD(free_list); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 256 | spin_lock(&pipe->lock); |
| 257 | list_splice_init(&pipe->pipe, &free_list); |
| 258 | pipe->pipelen = 0; |
| 259 | spin_unlock(&pipe->lock); |
| 260 | rpc_purge_list(pipe, &free_list, |
| 261 | pipe->ops->destroy_msg, -EAGAIN); |
Trond Myklebust | 9842ef3 | 2006-02-01 12:18:44 -0500 | [diff] [blame] | 262 | } |
| 263 | } |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 264 | last_close = pipe->nwriters == 0 && pipe->nreaders == 0; |
| 265 | if (last_close && pipe->ops->release_pipe) |
| 266 | pipe->ops->release_pipe(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | out: |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 268 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | static ssize_t |
| 273 | rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset) |
| 274 | { |
Josef Sipek | 303b46b | 2006-12-08 02:37:42 -0800 | [diff] [blame] | 275 | struct inode *inode = filp->f_path.dentry->d_inode; |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 276 | struct rpc_pipe *pipe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | struct rpc_pipe_msg *msg; |
| 278 | int res = 0; |
| 279 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 280 | mutex_lock(&inode->i_mutex); |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 281 | pipe = RPC_I(inode)->pipe; |
| 282 | if (pipe == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | res = -EPIPE; |
| 284 | goto out_unlock; |
| 285 | } |
| 286 | msg = filp->private_data; |
| 287 | if (msg == NULL) { |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 288 | spin_lock(&pipe->lock); |
| 289 | if (!list_empty(&pipe->pipe)) { |
| 290 | msg = list_entry(pipe->pipe.next, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | struct rpc_pipe_msg, |
| 292 | list); |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 293 | list_move(&msg->list, &pipe->in_upcall); |
| 294 | pipe->pipelen -= msg->len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | filp->private_data = msg; |
| 296 | msg->copied = 0; |
| 297 | } |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 298 | spin_unlock(&pipe->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | if (msg == NULL) |
| 300 | goto out_unlock; |
| 301 | } |
| 302 | /* NOTE: it is up to the callback to update msg->copied */ |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 303 | res = pipe->ops->upcall(filp, msg, buf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | if (res < 0 || msg->len == msg->copied) { |
| 305 | filp->private_data = NULL; |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 306 | spin_lock(&pipe->lock); |
Trond Myklebust | 5a67657 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 307 | list_del_init(&msg->list); |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 308 | spin_unlock(&pipe->lock); |
| 309 | pipe->ops->destroy_msg(msg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
| 311 | out_unlock: |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 312 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | return res; |
| 314 | } |
| 315 | |
| 316 | static ssize_t |
| 317 | rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset) |
| 318 | { |
Josef Sipek | 303b46b | 2006-12-08 02:37:42 -0800 | [diff] [blame] | 319 | struct inode *inode = filp->f_path.dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | int res; |
| 321 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 322 | mutex_lock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | res = -EPIPE; |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 324 | if (RPC_I(inode)->pipe != NULL) |
| 325 | res = RPC_I(inode)->pipe->ops->downcall(filp, buf, len); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 326 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | return res; |
| 328 | } |
| 329 | |
| 330 | static unsigned int |
| 331 | rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) |
| 332 | { |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 333 | struct rpc_pipe *pipe = RPC_I(filp->f_path.dentry->d_inode)->pipe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | unsigned int mask = 0; |
| 335 | |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 336 | poll_wait(filp, &pipe->waitq, wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
| 338 | mask = POLLOUT | POLLWRNORM; |
Stanislav Kinsbursky | ad6b134 | 2012-01-10 16:12:38 +0400 | [diff] [blame] | 339 | if (pipe->dentry == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | mask |= POLLERR | POLLHUP; |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 341 | if (filp->private_data || !list_empty(&pipe->pipe)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | mask |= POLLIN | POLLRDNORM; |
| 343 | return mask; |
| 344 | } |
| 345 | |
Arnd Bergmann | a6f8dbc | 2010-10-04 21:18:23 +0200 | [diff] [blame] | 346 | static long |
| 347 | rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { |
Arnd Bergmann | a6f8dbc | 2010-10-04 21:18:23 +0200 | [diff] [blame] | 349 | struct inode *inode = filp->f_path.dentry->d_inode; |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 350 | struct rpc_pipe *pipe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | int len; |
| 352 | |
| 353 | switch (cmd) { |
| 354 | case FIONREAD: |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 355 | mutex_lock(&inode->i_mutex); |
| 356 | pipe = RPC_I(inode)->pipe; |
| 357 | if (pipe == NULL) { |
| 358 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | return -EPIPE; |
Arnd Bergmann | a6f8dbc | 2010-10-04 21:18:23 +0200 | [diff] [blame] | 360 | } |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 361 | spin_lock(&pipe->lock); |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 362 | len = pipe->pipelen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | if (filp->private_data) { |
| 364 | struct rpc_pipe_msg *msg; |
Joe Perches | 655b5bb | 2010-09-04 18:52:53 -0700 | [diff] [blame] | 365 | msg = filp->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | len += msg->len - msg->copied; |
| 367 | } |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 368 | spin_unlock(&pipe->lock); |
Stanislav Kinsbursky | 2c9030e | 2012-02-27 22:05:45 +0400 | [diff] [blame^] | 369 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | return put_user(len, (int __user *)arg); |
| 371 | default: |
| 372 | return -EINVAL; |
| 373 | } |
| 374 | } |
| 375 | |
Arjan van de Ven | da7071d | 2007-02-12 00:55:36 -0800 | [diff] [blame] | 376 | static const struct file_operations rpc_pipe_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | .owner = THIS_MODULE, |
| 378 | .llseek = no_llseek, |
| 379 | .read = rpc_pipe_read, |
| 380 | .write = rpc_pipe_write, |
| 381 | .poll = rpc_pipe_poll, |
Frederic Weisbecker | 674b604 | 2010-05-19 15:08:17 +0200 | [diff] [blame] | 382 | .unlocked_ioctl = rpc_pipe_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | .open = rpc_pipe_open, |
| 384 | .release = rpc_pipe_release, |
| 385 | }; |
| 386 | |
| 387 | static int |
| 388 | rpc_show_info(struct seq_file *m, void *v) |
| 389 | { |
| 390 | struct rpc_clnt *clnt = m->private; |
| 391 | |
| 392 | seq_printf(m, "RPC server: %s\n", clnt->cl_server); |
| 393 | seq_printf(m, "service: %s (%d) version %d\n", clnt->cl_protname, |
| 394 | clnt->cl_prog, clnt->cl_vers); |
Chuck Lever | e7f7865 | 2006-08-22 20:06:19 -0400 | [diff] [blame] | 395 | seq_printf(m, "address: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_ADDR)); |
| 396 | seq_printf(m, "protocol: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_PROTO)); |
J. Bruce Fields | bf19aac | 2007-09-26 14:38:09 -0400 | [diff] [blame] | 397 | seq_printf(m, "port: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_PORT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | static int |
| 402 | rpc_info_open(struct inode *inode, struct file *file) |
| 403 | { |
Trond Myklebust | 006abe8 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 404 | struct rpc_clnt *clnt = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | int ret = single_open(file, rpc_show_info, NULL); |
| 406 | |
| 407 | if (!ret) { |
| 408 | struct seq_file *m = file->private_data; |
Trond Myklebust | 006abe8 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 409 | |
| 410 | spin_lock(&file->f_path.dentry->d_lock); |
| 411 | if (!d_unhashed(file->f_path.dentry)) |
| 412 | clnt = RPC_I(inode)->private; |
| 413 | if (clnt != NULL && atomic_inc_not_zero(&clnt->cl_count)) { |
| 414 | spin_unlock(&file->f_path.dentry->d_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | m->private = clnt; |
| 416 | } else { |
Trond Myklebust | 006abe8 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 417 | spin_unlock(&file->f_path.dentry->d_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | single_release(inode, file); |
| 419 | ret = -EINVAL; |
| 420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | return ret; |
| 423 | } |
| 424 | |
| 425 | static int |
| 426 | rpc_info_release(struct inode *inode, struct file *file) |
| 427 | { |
| 428 | struct seq_file *m = file->private_data; |
| 429 | struct rpc_clnt *clnt = (struct rpc_clnt *)m->private; |
| 430 | |
| 431 | if (clnt) |
| 432 | rpc_release_client(clnt); |
| 433 | return single_release(inode, file); |
| 434 | } |
| 435 | |
Arjan van de Ven | da7071d | 2007-02-12 00:55:36 -0800 | [diff] [blame] | 436 | static const struct file_operations rpc_info_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | .owner = THIS_MODULE, |
| 438 | .open = rpc_info_open, |
| 439 | .read = seq_read, |
| 440 | .llseek = seq_lseek, |
| 441 | .release = rpc_info_release, |
| 442 | }; |
| 443 | |
| 444 | |
| 445 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | * Description of fs contents. |
| 447 | */ |
| 448 | struct rpc_filelist { |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 449 | const char *name; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 450 | const struct file_operations *i_fop; |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 451 | umode_t mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | }; |
| 453 | |
Nick Piggin | fe15ce4 | 2011-01-07 17:49:23 +1100 | [diff] [blame] | 454 | static int rpc_delete_dentry(const struct dentry *dentry) |
Trond Myklebust | 62e1761 | 2007-06-08 14:14:46 -0400 | [diff] [blame] | 455 | { |
| 456 | return 1; |
| 457 | } |
| 458 | |
Al Viro | 3ba13d1 | 2009-02-20 06:02:22 +0000 | [diff] [blame] | 459 | static const struct dentry_operations rpc_dentry_operations = { |
Trond Myklebust | 62e1761 | 2007-06-08 14:14:46 -0400 | [diff] [blame] | 460 | .d_delete = rpc_delete_dentry, |
| 461 | }; |
| 462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | static struct inode * |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 464 | rpc_get_inode(struct super_block *sb, umode_t mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | { |
| 466 | struct inode *inode = new_inode(sb); |
| 467 | if (!inode) |
| 468 | return NULL; |
Christoph Hellwig | 85fe402 | 2010-10-23 11:19:54 -0400 | [diff] [blame] | 469 | inode->i_ino = get_next_ino(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | inode->i_mode = mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
Joe Perches | 89f0e4f | 2011-07-01 09:43:12 +0000 | [diff] [blame] | 472 | switch (mode & S_IFMT) { |
| 473 | case S_IFDIR: |
| 474 | inode->i_fop = &simple_dir_operations; |
| 475 | inode->i_op = &simple_dir_inode_operations; |
| 476 | inc_nlink(inode); |
| 477 | default: |
| 478 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | return inode; |
| 481 | } |
| 482 | |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 483 | static int __rpc_create_common(struct inode *dir, struct dentry *dentry, |
| 484 | umode_t mode, |
| 485 | const struct file_operations *i_fop, |
| 486 | void *private) |
| 487 | { |
| 488 | struct inode *inode; |
| 489 | |
Trond Myklebust | beb0f0a | 2010-12-20 21:19:26 +0000 | [diff] [blame] | 490 | d_drop(dentry); |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 491 | inode = rpc_get_inode(dir->i_sb, mode); |
| 492 | if (!inode) |
| 493 | goto out_err; |
| 494 | inode->i_ino = iunique(dir->i_sb, 100); |
| 495 | if (i_fop) |
| 496 | inode->i_fop = i_fop; |
| 497 | if (private) |
| 498 | rpc_inode_setowner(inode, private); |
| 499 | d_add(dentry, inode); |
| 500 | return 0; |
| 501 | out_err: |
| 502 | printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n", |
| 503 | __FILE__, __func__, dentry->d_name.name); |
| 504 | dput(dentry); |
| 505 | return -ENOMEM; |
| 506 | } |
| 507 | |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 508 | static int __rpc_create(struct inode *dir, struct dentry *dentry, |
| 509 | umode_t mode, |
| 510 | const struct file_operations *i_fop, |
| 511 | void *private) |
| 512 | { |
| 513 | int err; |
| 514 | |
| 515 | err = __rpc_create_common(dir, dentry, S_IFREG | mode, i_fop, private); |
| 516 | if (err) |
| 517 | return err; |
| 518 | fsnotify_create(dir, dentry); |
| 519 | return 0; |
| 520 | } |
| 521 | |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 522 | static int __rpc_mkdir(struct inode *dir, struct dentry *dentry, |
| 523 | umode_t mode, |
| 524 | const struct file_operations *i_fop, |
| 525 | void *private) |
| 526 | { |
| 527 | int err; |
| 528 | |
| 529 | err = __rpc_create_common(dir, dentry, S_IFDIR | mode, i_fop, private); |
| 530 | if (err) |
| 531 | return err; |
| 532 | inc_nlink(dir); |
| 533 | fsnotify_mkdir(dir, dentry); |
| 534 | return 0; |
| 535 | } |
| 536 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 537 | static void |
| 538 | init_pipe(struct rpc_pipe *pipe) |
| 539 | { |
| 540 | pipe->nreaders = 0; |
| 541 | pipe->nwriters = 0; |
| 542 | INIT_LIST_HEAD(&pipe->in_upcall); |
| 543 | INIT_LIST_HEAD(&pipe->in_downcall); |
| 544 | INIT_LIST_HEAD(&pipe->pipe); |
| 545 | pipe->pipelen = 0; |
| 546 | init_waitqueue_head(&pipe->waitq); |
| 547 | INIT_DELAYED_WORK(&pipe->queue_timeout, |
| 548 | rpc_timeout_upcall_queue); |
| 549 | pipe->ops = NULL; |
| 550 | spin_lock_init(&pipe->lock); |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 551 | pipe->dentry = NULL; |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 552 | } |
| 553 | |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 554 | void rpc_destroy_pipe_data(struct rpc_pipe *pipe) |
| 555 | { |
| 556 | kfree(pipe); |
| 557 | } |
| 558 | EXPORT_SYMBOL_GPL(rpc_destroy_pipe_data); |
| 559 | |
| 560 | struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags) |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 561 | { |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 562 | struct rpc_pipe *pipe; |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 563 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 564 | pipe = kzalloc(sizeof(struct rpc_pipe), GFP_KERNEL); |
| 565 | if (!pipe) |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 566 | return ERR_PTR(-ENOMEM); |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 567 | init_pipe(pipe); |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 568 | pipe->ops = ops; |
| 569 | pipe->flags = flags; |
| 570 | return pipe; |
| 571 | } |
| 572 | EXPORT_SYMBOL_GPL(rpc_mkpipe_data); |
| 573 | |
| 574 | static int __rpc_mkpipe_dentry(struct inode *dir, struct dentry *dentry, |
| 575 | umode_t mode, |
| 576 | const struct file_operations *i_fop, |
| 577 | void *private, |
| 578 | struct rpc_pipe *pipe) |
| 579 | { |
| 580 | struct rpc_inode *rpci; |
| 581 | int err; |
| 582 | |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 583 | err = __rpc_create_common(dir, dentry, S_IFIFO | mode, i_fop, private); |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 584 | if (err) |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 585 | return err; |
| 586 | rpci = RPC_I(dentry->d_inode); |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 587 | rpci->private = private; |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 588 | rpci->pipe = pipe; |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 589 | fsnotify_create(dir, dentry); |
| 590 | return 0; |
| 591 | } |
| 592 | |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 593 | static int __rpc_rmdir(struct inode *dir, struct dentry *dentry) |
| 594 | { |
| 595 | int ret; |
| 596 | |
| 597 | dget(dentry); |
| 598 | ret = simple_rmdir(dir, dentry); |
| 599 | d_delete(dentry); |
| 600 | dput(dentry); |
| 601 | return ret; |
| 602 | } |
| 603 | |
Stanislav Kinsbursky | eee17325 | 2012-01-10 16:13:19 +0400 | [diff] [blame] | 604 | int rpc_rmdir(struct dentry *dentry) |
| 605 | { |
| 606 | struct dentry *parent; |
| 607 | struct inode *dir; |
| 608 | int error; |
| 609 | |
| 610 | parent = dget_parent(dentry); |
| 611 | dir = parent->d_inode; |
| 612 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
| 613 | error = __rpc_rmdir(dir, dentry); |
| 614 | mutex_unlock(&dir->i_mutex); |
| 615 | dput(parent); |
| 616 | return error; |
| 617 | } |
| 618 | EXPORT_SYMBOL_GPL(rpc_rmdir); |
| 619 | |
Trond Myklebust | 810d90b | 2009-08-09 15:14:18 -0400 | [diff] [blame] | 620 | static int __rpc_unlink(struct inode *dir, struct dentry *dentry) |
| 621 | { |
| 622 | int ret; |
| 623 | |
| 624 | dget(dentry); |
| 625 | ret = simple_unlink(dir, dentry); |
| 626 | d_delete(dentry); |
| 627 | dput(dentry); |
| 628 | return ret; |
| 629 | } |
| 630 | |
| 631 | static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry) |
| 632 | { |
| 633 | struct inode *inode = dentry->d_inode; |
Trond Myklebust | 810d90b | 2009-08-09 15:14:18 -0400 | [diff] [blame] | 634 | |
Trond Myklebust | 810d90b | 2009-08-09 15:14:18 -0400 | [diff] [blame] | 635 | rpc_close_pipes(inode); |
| 636 | return __rpc_unlink(dir, dentry); |
| 637 | } |
| 638 | |
Trond Myklebust | cfeaa4a | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 639 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, |
| 640 | struct qstr *name) |
| 641 | { |
| 642 | struct dentry *dentry; |
| 643 | |
Stanislav Kinsbursky | 5bff038 | 2011-11-08 15:09:19 +0300 | [diff] [blame] | 644 | dentry = d_lookup(parent, name); |
| 645 | if (!dentry) { |
| 646 | dentry = d_alloc(parent, name); |
| 647 | if (!dentry) |
| 648 | return ERR_PTR(-ENOMEM); |
| 649 | } |
| 650 | if (dentry->d_inode == NULL) { |
| 651 | d_set_d_op(dentry, &rpc_dentry_operations); |
Dan Carpenter | f1f0abe1 | 2010-03-21 12:10:34 -0400 | [diff] [blame] | 652 | return dentry; |
Stanislav Kinsbursky | 5bff038 | 2011-11-08 15:09:19 +0300 | [diff] [blame] | 653 | } |
Trond Myklebust | cfeaa4a | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 654 | dput(dentry); |
| 655 | return ERR_PTR(-EEXIST); |
| 656 | } |
| 657 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | /* |
| 659 | * FIXME: This probably has races. |
| 660 | */ |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 661 | static void __rpc_depopulate(struct dentry *parent, |
| 662 | const struct rpc_filelist *files, |
| 663 | int start, int eof) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | { |
| 665 | struct inode *dir = parent->d_inode; |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 666 | struct dentry *dentry; |
| 667 | struct qstr name; |
| 668 | int i; |
| 669 | |
| 670 | for (i = start; i < eof; i++) { |
| 671 | name.name = files[i].name; |
| 672 | name.len = strlen(files[i].name); |
| 673 | name.hash = full_name_hash(name.name, name.len); |
| 674 | dentry = d_lookup(parent, &name); |
| 675 | |
| 676 | if (dentry == NULL) |
| 677 | continue; |
| 678 | if (dentry->d_inode == NULL) |
| 679 | goto next; |
| 680 | switch (dentry->d_inode->i_mode & S_IFMT) { |
| 681 | default: |
| 682 | BUG(); |
| 683 | case S_IFREG: |
| 684 | __rpc_unlink(dir, dentry); |
| 685 | break; |
| 686 | case S_IFDIR: |
| 687 | __rpc_rmdir(dir, dentry); |
| 688 | } |
| 689 | next: |
| 690 | dput(dentry); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | static void rpc_depopulate(struct dentry *parent, |
| 695 | const struct rpc_filelist *files, |
| 696 | int start, int eof) |
| 697 | { |
| 698 | struct inode *dir = parent->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | |
Arjan van de Ven | c6573c2 | 2006-07-03 00:25:16 -0700 | [diff] [blame] | 700 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD); |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 701 | __rpc_depopulate(parent, files, start, eof); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 702 | mutex_unlock(&dir->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | } |
| 704 | |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 705 | static int rpc_populate(struct dentry *parent, |
| 706 | const struct rpc_filelist *files, |
| 707 | int start, int eof, |
| 708 | void *private) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 710 | struct inode *dir = parent->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | struct dentry *dentry; |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 712 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 714 | mutex_lock(&dir->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | for (i = start; i < eof; i++) { |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 716 | struct qstr q; |
| 717 | |
| 718 | q.name = files[i].name; |
| 719 | q.len = strlen(files[i].name); |
| 720 | q.hash = full_name_hash(q.name, q.len); |
| 721 | dentry = __rpc_lookup_create_exclusive(parent, &q); |
| 722 | err = PTR_ERR(dentry); |
| 723 | if (IS_ERR(dentry)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | goto out_bad; |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 725 | switch (files[i].mode & S_IFMT) { |
| 726 | default: |
| 727 | BUG(); |
| 728 | case S_IFREG: |
| 729 | err = __rpc_create(dir, dentry, |
| 730 | files[i].mode, |
| 731 | files[i].i_fop, |
| 732 | private); |
| 733 | break; |
| 734 | case S_IFDIR: |
| 735 | err = __rpc_mkdir(dir, dentry, |
| 736 | files[i].mode, |
| 737 | NULL, |
| 738 | private); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | } |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 740 | if (err != 0) |
| 741 | goto out_bad; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | } |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 743 | mutex_unlock(&dir->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | return 0; |
| 745 | out_bad: |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 746 | __rpc_depopulate(parent, files, start, eof); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 747 | mutex_unlock(&dir->i_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | printk(KERN_WARNING "%s: %s failed to populate directory %s\n", |
Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 749 | __FILE__, __func__, parent->d_name.name); |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 750 | return err; |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 751 | } |
Christoph Hellwig | 278c995 | 2005-07-24 23:53:01 +0100 | [diff] [blame] | 752 | |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 753 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, |
| 754 | struct qstr *name, umode_t mode, void *private, |
| 755 | int (*populate)(struct dentry *, void *), void *args_populate) |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 756 | { |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 757 | struct dentry *dentry; |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 758 | struct inode *dir = parent->d_inode; |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 759 | int error; |
| 760 | |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 761 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
| 762 | dentry = __rpc_lookup_create_exclusive(parent, name); |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 763 | if (IS_ERR(dentry)) |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 764 | goto out; |
| 765 | error = __rpc_mkdir(dir, dentry, mode, NULL, private); |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 766 | if (error != 0) |
| 767 | goto out_err; |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 768 | if (populate != NULL) { |
| 769 | error = populate(dentry, args_populate); |
| 770 | if (error) |
| 771 | goto err_rmdir; |
| 772 | } |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 773 | out: |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 774 | mutex_unlock(&dir->i_mutex); |
Trond Myklebust | 5c3e985 | 2006-07-29 17:37:40 -0400 | [diff] [blame] | 775 | return dentry; |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 776 | err_rmdir: |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 777 | __rpc_rmdir(dir, dentry); |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 778 | out_err: |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 779 | dentry = ERR_PTR(error); |
| 780 | goto out; |
| 781 | } |
| 782 | |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 783 | static int rpc_rmdir_depopulate(struct dentry *dentry, |
| 784 | void (*depopulate)(struct dentry *)) |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 785 | { |
Trond Myklebust | dff02cc | 2006-07-31 14:17:18 -0700 | [diff] [blame] | 786 | struct dentry *parent; |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 787 | struct inode *dir; |
| 788 | int error; |
| 789 | |
Trond Myklebust | dff02cc | 2006-07-31 14:17:18 -0700 | [diff] [blame] | 790 | parent = dget_parent(dentry); |
| 791 | dir = parent->d_inode; |
Arjan van de Ven | c6573c2 | 2006-07-03 00:25:16 -0700 | [diff] [blame] | 792 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 793 | if (depopulate != NULL) |
| 794 | depopulate(dentry); |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 795 | error = __rpc_rmdir(dir, dentry); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 796 | mutex_unlock(&dir->i_mutex); |
Trond Myklebust | dff02cc | 2006-07-31 14:17:18 -0700 | [diff] [blame] | 797 | dput(parent); |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 798 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | } |
| 800 | |
J. Bruce Fields | 93a44a7 | 2007-11-06 13:06:03 -0500 | [diff] [blame] | 801 | /** |
| 802 | * rpc_mkpipe - make an rpc_pipefs file for kernel<->userspace communication |
| 803 | * @parent: dentry of directory to create new "pipe" in |
| 804 | * @name: name of pipe |
| 805 | * @private: private data to associate with the pipe, for the caller's use |
| 806 | * @ops: operations defining the behavior of the pipe: upcall, downcall, |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 807 | * release_pipe, open_pipe, and destroy_msg. |
Stanislav Kinsbursky | d0fe13b | 2011-12-26 15:43:41 +0300 | [diff] [blame] | 808 | * @flags: rpc_pipe flags |
J. Bruce Fields | 93a44a7 | 2007-11-06 13:06:03 -0500 | [diff] [blame] | 809 | * |
| 810 | * Data is made available for userspace to read by calls to |
| 811 | * rpc_queue_upcall(). The actual reads will result in calls to |
| 812 | * @ops->upcall, which will be called with the file pointer, |
| 813 | * message, and userspace buffer to copy to. |
| 814 | * |
| 815 | * Writes can come at any time, and do not necessarily have to be |
| 816 | * responses to upcalls. They will result in calls to @msg->downcall. |
| 817 | * |
| 818 | * The @private argument passed here will be available to all these methods |
| 819 | * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private. |
| 820 | */ |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 821 | struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, |
| 822 | void *private, struct rpc_pipe *pipe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | struct dentry *dentry; |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 825 | struct inode *dir = parent->d_inode; |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 826 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; |
Trond Myklebust | cfeaa4a | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 827 | struct qstr q; |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 828 | int err; |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 829 | |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 830 | if (pipe->ops->upcall == NULL) |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 831 | umode &= ~S_IRUGO; |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 832 | if (pipe->ops->downcall == NULL) |
Trond Myklebust | 7364af6 | 2009-08-09 15:14:16 -0400 | [diff] [blame] | 833 | umode &= ~S_IWUGO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | |
Trond Myklebust | cfeaa4a | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 835 | q.name = name; |
| 836 | q.len = strlen(name); |
| 837 | q.hash = full_name_hash(q.name, q.len), |
| 838 | |
| 839 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
Stanislav Kinsbursky | 5bff038 | 2011-11-08 15:09:19 +0300 | [diff] [blame] | 840 | dentry = __rpc_lookup_create_exclusive(parent, &q); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | if (IS_ERR(dentry)) |
Trond Myklebust | cfeaa4a | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 842 | goto out; |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 843 | err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, |
| 844 | private, pipe); |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 845 | if (err) |
| 846 | goto out_err; |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 847 | out: |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 848 | mutex_unlock(&dir->i_mutex); |
Trond Myklebust | 5c3e985 | 2006-07-29 17:37:40 -0400 | [diff] [blame] | 849 | return dentry; |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 850 | out_err: |
| 851 | dentry = ERR_PTR(err); |
Trond Myklebust | 158998b | 2006-08-24 01:03:17 -0400 | [diff] [blame] | 852 | printk(KERN_WARNING "%s: %s() failed to create pipe %s/%s (errno = %d)\n", |
Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 853 | __FILE__, __func__, parent->d_name.name, name, |
Trond Myklebust | 7589806 | 2009-08-09 15:14:17 -0400 | [diff] [blame] | 854 | err); |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 855 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | } |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 857 | EXPORT_SYMBOL_GPL(rpc_mkpipe_dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | |
J. Bruce Fields | 93a44a7 | 2007-11-06 13:06:03 -0500 | [diff] [blame] | 859 | /** |
| 860 | * rpc_unlink - remove a pipe |
| 861 | * @dentry: dentry for the pipe, as returned from rpc_mkpipe |
| 862 | * |
| 863 | * After this call, lookups will no longer find the pipe, and any |
| 864 | * attempts to read or write using preexisting opens of the pipe will |
| 865 | * return -EPIPE. |
| 866 | */ |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 867 | int |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 868 | rpc_unlink(struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | { |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 870 | struct dentry *parent; |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 871 | struct inode *dir; |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 872 | int error = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 874 | parent = dget_parent(dentry); |
| 875 | dir = parent->d_inode; |
Arjan van de Ven | c6573c2 | 2006-07-03 00:25:16 -0700 | [diff] [blame] | 876 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
Trond Myklebust | 810d90b | 2009-08-09 15:14:18 -0400 | [diff] [blame] | 877 | error = __rpc_rmpipe(dir, dentry); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 878 | mutex_unlock(&dir->i_mutex); |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 879 | dput(parent); |
Trond Myklebust | f134585 | 2005-09-23 11:08:25 -0400 | [diff] [blame] | 880 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | } |
Trond Myklebust | 468039e | 2008-12-23 15:21:31 -0500 | [diff] [blame] | 882 | EXPORT_SYMBOL_GPL(rpc_unlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 884 | enum { |
| 885 | RPCAUTH_info, |
| 886 | RPCAUTH_EOF |
| 887 | }; |
| 888 | |
| 889 | static const struct rpc_filelist authfiles[] = { |
| 890 | [RPCAUTH_info] = { |
| 891 | .name = "info", |
| 892 | .i_fop = &rpc_info_operations, |
| 893 | .mode = S_IFREG | S_IRUSR, |
| 894 | }, |
| 895 | }; |
| 896 | |
| 897 | static int rpc_clntdir_populate(struct dentry *dentry, void *private) |
| 898 | { |
| 899 | return rpc_populate(dentry, |
| 900 | authfiles, RPCAUTH_info, RPCAUTH_EOF, |
| 901 | private); |
| 902 | } |
| 903 | |
| 904 | static void rpc_clntdir_depopulate(struct dentry *dentry) |
| 905 | { |
| 906 | rpc_depopulate(dentry, authfiles, RPCAUTH_info, RPCAUTH_EOF); |
| 907 | } |
| 908 | |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 909 | /** |
| 910 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs |
Randy Dunlap | 4111d4f | 2009-09-23 14:36:38 -0400 | [diff] [blame] | 911 | * @dentry: dentry from the rpc_pipefs root to the new directory |
| 912 | * @name: &struct qstr for the name |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 913 | * @rpc_client: rpc client to associate with this directory |
| 914 | * |
| 915 | * This creates a directory at the given @path associated with |
| 916 | * @rpc_clnt, which will contain a file named "info" with some basic |
| 917 | * information about the client, together with any "pipes" that may |
| 918 | * later be created using rpc_mkpipe(). |
| 919 | */ |
Trond Myklebust | 23ac658 | 2009-08-09 15:14:25 -0400 | [diff] [blame] | 920 | struct dentry *rpc_create_client_dir(struct dentry *dentry, |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 921 | struct qstr *name, |
| 922 | struct rpc_clnt *rpc_client) |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 923 | { |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 924 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, |
| 925 | rpc_clntdir_populate, rpc_client); |
| 926 | } |
| 927 | |
| 928 | /** |
| 929 | * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir() |
Stanislav Kinsbursky | 80df9d2 | 2012-01-11 19:18:17 +0400 | [diff] [blame] | 930 | * @clnt: rpc client |
Trond Myklebust | e57aed7 | 2009-08-09 15:14:26 -0400 | [diff] [blame] | 931 | */ |
| 932 | int rpc_remove_client_dir(struct dentry *dentry) |
| 933 | { |
| 934 | return rpc_rmdir_depopulate(dentry, rpc_clntdir_depopulate); |
Trond Myklebust | 7d59d1e | 2009-08-09 15:14:23 -0400 | [diff] [blame] | 935 | } |
| 936 | |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 937 | static const struct rpc_filelist cache_pipefs_files[3] = { |
| 938 | [0] = { |
| 939 | .name = "channel", |
| 940 | .i_fop = &cache_file_operations_pipefs, |
Trond Myklebust | 96c61cb | 2009-08-19 18:12:21 -0400 | [diff] [blame] | 941 | .mode = S_IFREG|S_IRUSR|S_IWUSR, |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 942 | }, |
| 943 | [1] = { |
| 944 | .name = "content", |
| 945 | .i_fop = &content_file_operations_pipefs, |
| 946 | .mode = S_IFREG|S_IRUSR, |
| 947 | }, |
| 948 | [2] = { |
| 949 | .name = "flush", |
| 950 | .i_fop = &cache_flush_operations_pipefs, |
| 951 | .mode = S_IFREG|S_IRUSR|S_IWUSR, |
| 952 | }, |
| 953 | }; |
| 954 | |
| 955 | static int rpc_cachedir_populate(struct dentry *dentry, void *private) |
| 956 | { |
| 957 | return rpc_populate(dentry, |
| 958 | cache_pipefs_files, 0, 3, |
| 959 | private); |
| 960 | } |
| 961 | |
| 962 | static void rpc_cachedir_depopulate(struct dentry *dentry) |
| 963 | { |
| 964 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); |
| 965 | } |
| 966 | |
| 967 | struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, |
Al Viro | 64f1426 | 2011-07-25 00:35:13 -0400 | [diff] [blame] | 968 | umode_t umode, struct cache_detail *cd) |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 969 | { |
| 970 | return rpc_mkdir_populate(parent, name, umode, NULL, |
| 971 | rpc_cachedir_populate, cd); |
| 972 | } |
| 973 | |
| 974 | void rpc_remove_cache_dir(struct dentry *dentry) |
| 975 | { |
| 976 | rpc_rmdir_depopulate(dentry, rpc_cachedir_depopulate); |
| 977 | } |
| 978 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | /* |
| 980 | * populate the filesystem |
| 981 | */ |
Alexey Dobriyan | b87221d | 2009-09-21 17:01:09 -0700 | [diff] [blame] | 982 | static const struct super_operations s_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | .alloc_inode = rpc_alloc_inode, |
| 984 | .destroy_inode = rpc_destroy_inode, |
| 985 | .statfs = simple_statfs, |
| 986 | }; |
| 987 | |
| 988 | #define RPCAUTH_GSSMAGIC 0x67596969 |
| 989 | |
Trond Myklebust | bb15674 | 2009-08-09 15:14:21 -0400 | [diff] [blame] | 990 | /* |
| 991 | * We have a single directory with 1 node in it. |
| 992 | */ |
| 993 | enum { |
| 994 | RPCAUTH_lockd, |
| 995 | RPCAUTH_mount, |
| 996 | RPCAUTH_nfs, |
| 997 | RPCAUTH_portmap, |
| 998 | RPCAUTH_statd, |
| 999 | RPCAUTH_nfsd4_cb, |
Trond Myklebust | e571cbf | 2009-08-19 18:12:27 -0400 | [diff] [blame] | 1000 | RPCAUTH_cache, |
Trond Myklebust | bb15674 | 2009-08-09 15:14:21 -0400 | [diff] [blame] | 1001 | RPCAUTH_RootEOF |
| 1002 | }; |
| 1003 | |
| 1004 | static const struct rpc_filelist files[] = { |
| 1005 | [RPCAUTH_lockd] = { |
| 1006 | .name = "lockd", |
| 1007 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1008 | }, |
| 1009 | [RPCAUTH_mount] = { |
| 1010 | .name = "mount", |
| 1011 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1012 | }, |
| 1013 | [RPCAUTH_nfs] = { |
| 1014 | .name = "nfs", |
| 1015 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1016 | }, |
| 1017 | [RPCAUTH_portmap] = { |
| 1018 | .name = "portmap", |
| 1019 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1020 | }, |
| 1021 | [RPCAUTH_statd] = { |
| 1022 | .name = "statd", |
| 1023 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1024 | }, |
| 1025 | [RPCAUTH_nfsd4_cb] = { |
| 1026 | .name = "nfsd4_cb", |
| 1027 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1028 | }, |
Trond Myklebust | e571cbf | 2009-08-19 18:12:27 -0400 | [diff] [blame] | 1029 | [RPCAUTH_cache] = { |
| 1030 | .name = "cache", |
| 1031 | .mode = S_IFDIR | S_IRUGO | S_IXUGO, |
| 1032 | }, |
Trond Myklebust | bb15674 | 2009-08-09 15:14:21 -0400 | [diff] [blame] | 1033 | }; |
| 1034 | |
Stanislav Kinsbursky | 432eb1a | 2011-12-26 15:39:22 +0300 | [diff] [blame] | 1035 | /* |
| 1036 | * This call can be used only in RPC pipefs mount notification hooks. |
| 1037 | */ |
| 1038 | struct dentry *rpc_d_lookup_sb(const struct super_block *sb, |
| 1039 | const unsigned char *dir_name) |
| 1040 | { |
| 1041 | struct qstr dir = { |
| 1042 | .name = dir_name, |
| 1043 | .len = strlen(dir_name), |
| 1044 | .hash = full_name_hash(dir_name, strlen(dir_name)), |
| 1045 | }; |
| 1046 | |
| 1047 | return d_lookup(sb->s_root, &dir); |
| 1048 | } |
| 1049 | EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); |
| 1050 | |
Stanislav Kinsbursky | c21a588 | 2011-12-26 15:39:39 +0300 | [diff] [blame] | 1051 | void rpc_pipefs_init_net(struct net *net) |
| 1052 | { |
| 1053 | struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); |
| 1054 | |
| 1055 | mutex_init(&sn->pipefs_sb_lock); |
| 1056 | } |
| 1057 | |
| 1058 | /* |
| 1059 | * This call will be used for per network namespace operations calls. |
| 1060 | * Note: Function will be returned with pipefs_sb_lock taken if superblock was |
| 1061 | * found. This lock have to be released by rpc_put_sb_net() when all operations |
| 1062 | * will be completed. |
| 1063 | */ |
| 1064 | struct super_block *rpc_get_sb_net(const struct net *net) |
| 1065 | { |
| 1066 | struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); |
| 1067 | |
| 1068 | mutex_lock(&sn->pipefs_sb_lock); |
| 1069 | if (sn->pipefs_sb) |
| 1070 | return sn->pipefs_sb; |
| 1071 | mutex_unlock(&sn->pipefs_sb_lock); |
| 1072 | return NULL; |
| 1073 | } |
| 1074 | EXPORT_SYMBOL_GPL(rpc_get_sb_net); |
| 1075 | |
| 1076 | void rpc_put_sb_net(const struct net *net) |
| 1077 | { |
| 1078 | struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); |
| 1079 | |
| 1080 | BUG_ON(sn->pipefs_sb == NULL); |
| 1081 | mutex_unlock(&sn->pipefs_sb_lock); |
| 1082 | } |
| 1083 | EXPORT_SYMBOL_GPL(rpc_put_sb_net); |
| 1084 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | static int |
| 1086 | rpc_fill_super(struct super_block *sb, void *data, int silent) |
| 1087 | { |
| 1088 | struct inode *inode; |
| 1089 | struct dentry *root; |
Stanislav Kinsbursky | 38b0da7 | 2011-12-26 15:38:56 +0300 | [diff] [blame] | 1090 | struct net *net = data; |
Stanislav Kinsbursky | 90c4e82 | 2011-12-26 15:39:30 +0300 | [diff] [blame] | 1091 | struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 1092 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | |
| 1094 | sb->s_blocksize = PAGE_CACHE_SIZE; |
| 1095 | sb->s_blocksize_bits = PAGE_CACHE_SHIFT; |
| 1096 | sb->s_magic = RPCAUTH_GSSMAGIC; |
| 1097 | sb->s_op = &s_ops; |
| 1098 | sb->s_time_gran = 1; |
| 1099 | |
| 1100 | inode = rpc_get_inode(sb, S_IFDIR | 0755); |
| 1101 | if (!inode) |
| 1102 | return -ENOMEM; |
Al Viro | fc7bed8 | 2010-01-25 18:30:38 -0500 | [diff] [blame] | 1103 | sb->s_root = root = d_alloc_root(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | if (!root) { |
| 1105 | iput(inode); |
| 1106 | return -ENOMEM; |
| 1107 | } |
Trond Myklebust | ac6fece | 2009-08-09 15:14:20 -0400 | [diff] [blame] | 1108 | if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL)) |
Al Viro | fc7bed8 | 2010-01-25 18:30:38 -0500 | [diff] [blame] | 1109 | return -ENOMEM; |
Stanislav Kinsbursky | efc46bf | 2011-12-26 15:39:47 +0300 | [diff] [blame] | 1110 | dprintk("RPC: sending pipefs MOUNT notification for net %p%s\n", net, |
| 1111 | NET_NAME(net)); |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 1112 | err = blocking_notifier_call_chain(&rpc_pipefs_notifier_list, |
| 1113 | RPC_PIPEFS_MOUNT, |
| 1114 | sb); |
| 1115 | if (err) |
| 1116 | goto err_depopulate; |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1117 | sb->s_fs_info = get_net(net); |
Stanislav Kinsbursky | 90c4e82 | 2011-12-26 15:39:30 +0300 | [diff] [blame] | 1118 | sn->pipefs_sb = sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | return 0; |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 1120 | |
| 1121 | err_depopulate: |
| 1122 | blocking_notifier_call_chain(&rpc_pipefs_notifier_list, |
| 1123 | RPC_PIPEFS_UMOUNT, |
| 1124 | sb); |
| 1125 | __rpc_depopulate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF); |
| 1126 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
Al Viro | fc14f2f | 2010-07-25 01:48:30 +0400 | [diff] [blame] | 1129 | static struct dentry * |
| 1130 | rpc_mount(struct file_system_type *fs_type, |
| 1131 | int flags, const char *dev_name, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | { |
Stanislav Kinsbursky | 38b0da7 | 2011-12-26 15:38:56 +0300 | [diff] [blame] | 1133 | return mount_ns(fs_type, flags, current->nsproxy->net_ns, rpc_fill_super); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1134 | } |
| 1135 | |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1136 | void rpc_kill_sb(struct super_block *sb) |
| 1137 | { |
| 1138 | struct net *net = sb->s_fs_info; |
Stanislav Kinsbursky | 90c4e82 | 2011-12-26 15:39:30 +0300 | [diff] [blame] | 1139 | struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1140 | |
Stanislav Kinsbursky | c21a588 | 2011-12-26 15:39:39 +0300 | [diff] [blame] | 1141 | mutex_lock(&sn->pipefs_sb_lock); |
Stanislav Kinsbursky | 90c4e82 | 2011-12-26 15:39:30 +0300 | [diff] [blame] | 1142 | sn->pipefs_sb = NULL; |
Stanislav Kinsbursky | c21a588 | 2011-12-26 15:39:39 +0300 | [diff] [blame] | 1143 | mutex_unlock(&sn->pipefs_sb_lock); |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1144 | put_net(net); |
Stanislav Kinsbursky | efc46bf | 2011-12-26 15:39:47 +0300 | [diff] [blame] | 1145 | dprintk("RPC: sending pipefs UMOUNT notification for net %p%s\n", net, |
| 1146 | NET_NAME(net)); |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 1147 | blocking_notifier_call_chain(&rpc_pipefs_notifier_list, |
| 1148 | RPC_PIPEFS_UMOUNT, |
| 1149 | sb); |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1150 | kill_litter_super(sb); |
| 1151 | } |
| 1152 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | static struct file_system_type rpc_pipe_fs_type = { |
| 1154 | .owner = THIS_MODULE, |
| 1155 | .name = "rpc_pipefs", |
Al Viro | fc14f2f | 2010-07-25 01:48:30 +0400 | [diff] [blame] | 1156 | .mount = rpc_mount, |
Stanislav Kinsbursky | 021c68d | 2011-12-26 15:39:04 +0300 | [diff] [blame] | 1157 | .kill_sb = rpc_kill_sb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | }; |
| 1159 | |
| 1160 | static void |
Alexey Dobriyan | 51cc506 | 2008-07-25 19:45:34 -0700 | [diff] [blame] | 1161 | init_once(void *foo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | { |
| 1163 | struct rpc_inode *rpci = (struct rpc_inode *) foo; |
| 1164 | |
Christoph Lameter | a35afb8 | 2007-05-16 22:10:57 -0700 | [diff] [blame] | 1165 | inode_init_once(&rpci->vfs_inode); |
| 1166 | rpci->private = NULL; |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 1167 | rpci->pipe = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | } |
| 1169 | |
| 1170 | int register_rpc_pipefs(void) |
| 1171 | { |
Akinobu Mita | 5bd5f58 | 2007-05-09 02:34:51 -0700 | [diff] [blame] | 1172 | int err; |
| 1173 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | rpc_inode_cachep = kmem_cache_create("rpc_inode_cache", |
Paul Jackson | fffb60f | 2006-03-24 03:16:06 -0800 | [diff] [blame] | 1175 | sizeof(struct rpc_inode), |
| 1176 | 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| |
| 1177 | SLAB_MEM_SPREAD), |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 1178 | init_once); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | if (!rpc_inode_cachep) |
| 1180 | return -ENOMEM; |
Stanislav Kinsbursky | 80df9d2 | 2012-01-11 19:18:17 +0400 | [diff] [blame] | 1181 | err = rpc_clients_notifier_register(); |
| 1182 | if (err) |
| 1183 | goto err_notifier; |
Akinobu Mita | 5bd5f58 | 2007-05-09 02:34:51 -0700 | [diff] [blame] | 1184 | err = register_filesystem(&rpc_pipe_fs_type); |
Stanislav Kinsbursky | 80df9d2 | 2012-01-11 19:18:17 +0400 | [diff] [blame] | 1185 | if (err) |
| 1186 | goto err_register; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | return 0; |
Stanislav Kinsbursky | 80df9d2 | 2012-01-11 19:18:17 +0400 | [diff] [blame] | 1188 | |
| 1189 | err_register: |
| 1190 | rpc_clients_notifier_unregister(); |
| 1191 | err_notifier: |
| 1192 | kmem_cache_destroy(rpc_inode_cachep); |
| 1193 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | void unregister_rpc_pipefs(void) |
| 1197 | { |
Stanislav Kinsbursky | 80df9d2 | 2012-01-11 19:18:17 +0400 | [diff] [blame] | 1198 | rpc_clients_notifier_unregister(); |
Alexey Dobriyan | 1a1d92c | 2006-09-27 01:49:40 -0700 | [diff] [blame] | 1199 | kmem_cache_destroy(rpc_inode_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 | unregister_filesystem(&rpc_pipe_fs_type); |
| 1201 | } |
Michal Schmidt | dcbf8c3 | 2011-07-02 00:47:12 +0200 | [diff] [blame] | 1202 | |
| 1203 | /* Make 'mount -t rpc_pipefs ...' autoload this module. */ |
| 1204 | MODULE_ALIAS("rpc_pipefs"); |