blob: 5947628aefef142f99edb0bcc67f9bc625d125aa [file] [log] [blame]
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001/*
2 * linux/fs/9p/vfs_inode.c
3 *
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -07004 * This file contains vfs inode ops for the 9P2000 protocol.
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07005 *
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 *
9 * This program is free software; you can redistribute it and/or modify
Eric Van Hensbergen42e8c502006-03-25 03:07:28 -080010 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070012 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to:
20 * Free Software Foundation
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02111-1301 USA
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/errno.h>
28#include <linux/fs.h>
29#include <linux/file.h>
30#include <linux/pagemap.h>
31#include <linux/stat.h>
32#include <linux/string.h>
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070033#include <linux/inet.h>
34#include <linux/namei.h>
35#include <linux/idr.h>
Alexey Dobriyane8edc6e2007-05-21 01:22:52 +040036#include <linux/sched.h>
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050037#include <net/9p/9p.h>
38#include <net/9p/client.h>
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070039
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070040#include "v9fs.h"
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070041#include "v9fs_vfs.h"
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070042#include "fid.h"
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -050043#include "cache.h"
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070044
Arjan van de Ven754661f2007-02-12 00:55:38 -080045static const struct inode_operations v9fs_dir_inode_operations;
46static const struct inode_operations v9fs_dir_inode_operations_ext;
47static const struct inode_operations v9fs_file_inode_operations;
48static const struct inode_operations v9fs_symlink_inode_operations;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070049
50/**
51 * unixmode2p9mode - convert unix mode bits to plan 9
52 * @v9ses: v9fs session information
53 * @mode: mode to convert
54 *
55 */
56
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -070057static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070058{
59 int res;
60 res = mode & 0777;
61 if (S_ISDIR(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050062 res |= P9_DMDIR;
Latchesar Ionkov24056692007-10-17 14:31:07 -050063 if (v9fs_extended(v9ses)) {
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070064 if (S_ISLNK(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050065 res |= P9_DMSYMLINK;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070066 if (v9ses->nodev == 0) {
67 if (S_ISSOCK(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050068 res |= P9_DMSOCKET;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070069 if (S_ISFIFO(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050070 res |= P9_DMNAMEDPIPE;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070071 if (S_ISBLK(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050072 res |= P9_DMDEVICE;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070073 if (S_ISCHR(mode))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050074 res |= P9_DMDEVICE;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070075 }
76
77 if ((mode & S_ISUID) == S_ISUID)
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050078 res |= P9_DMSETUID;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070079 if ((mode & S_ISGID) == S_ISGID)
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050080 res |= P9_DMSETGID;
Anthony Liguorid199d652008-02-06 19:25:06 -060081 if ((mode & S_ISVTX) == S_ISVTX)
82 res |= P9_DMSETVTX;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050083 if ((mode & P9_DMLINK))
84 res |= P9_DMLINK;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070085 }
86
87 return res;
88}
89
90/**
91 * p9mode2unixmode- convert plan9 mode bits to unix mode bits
92 * @v9ses: v9fs session information
93 * @mode: mode to convert
94 *
95 */
96
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -070097static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -070098{
99 int res;
100
101 res = mode & 0777;
102
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500103 if ((mode & P9_DMDIR) == P9_DMDIR)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700104 res |= S_IFDIR;
Latchesar Ionkov24056692007-10-17 14:31:07 -0500105 else if ((mode & P9_DMSYMLINK) && (v9fs_extended(v9ses)))
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700106 res |= S_IFLNK;
Latchesar Ionkov24056692007-10-17 14:31:07 -0500107 else if ((mode & P9_DMSOCKET) && (v9fs_extended(v9ses))
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700108 && (v9ses->nodev == 0))
109 res |= S_IFSOCK;
Latchesar Ionkov24056692007-10-17 14:31:07 -0500110 else if ((mode & P9_DMNAMEDPIPE) && (v9fs_extended(v9ses))
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700111 && (v9ses->nodev == 0))
112 res |= S_IFIFO;
Latchesar Ionkov24056692007-10-17 14:31:07 -0500113 else if ((mode & P9_DMDEVICE) && (v9fs_extended(v9ses))
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700114 && (v9ses->nodev == 0))
115 res |= S_IFBLK;
116 else
117 res |= S_IFREG;
118
Latchesar Ionkov24056692007-10-17 14:31:07 -0500119 if (v9fs_extended(v9ses)) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500120 if ((mode & P9_DMSETUID) == P9_DMSETUID)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700121 res |= S_ISUID;
122
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500123 if ((mode & P9_DMSETGID) == P9_DMSETGID)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700124 res |= S_ISGID;
Anthony Liguorid199d652008-02-06 19:25:06 -0600125
126 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
127 res |= S_ISVTX;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700128 }
129
130 return res;
131}
132
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600133/**
134 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
135 * @uflags: flags to convert
Eric Van Hensbergen2e4bef42008-06-24 17:39:39 -0500136 * @extended: if .u extensions are active
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600137 */
138
Eric Van Hensbergen2e4bef42008-06-24 17:39:39 -0500139int v9fs_uflags2omode(int uflags, int extended)
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800140{
141 int ret;
142
143 ret = 0;
144 switch (uflags&3) {
145 default:
146 case O_RDONLY:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500147 ret = P9_OREAD;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800148 break;
149
150 case O_WRONLY:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500151 ret = P9_OWRITE;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800152 break;
153
154 case O_RDWR:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500155 ret = P9_ORDWR;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800156 break;
157 }
158
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800159 if (uflags & O_TRUNC)
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500160 ret |= P9_OTRUNC;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800161
Eric Van Hensbergen2e4bef42008-06-24 17:39:39 -0500162 if (extended) {
163 if (uflags & O_EXCL)
164 ret |= P9_OEXCL;
165
166 if (uflags & O_APPEND)
167 ret |= P9_OAPPEND;
168 }
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800169
170 return ret;
171}
172
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700173/**
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800174 * v9fs_blank_wstat - helper function to setup a 9P stat structure
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800175 * @wstat: structure to initialize
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700176 *
177 */
178
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -0700179static void
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500180v9fs_blank_wstat(struct p9_wstat *wstat)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700181{
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800182 wstat->type = ~0;
183 wstat->dev = ~0;
184 wstat->qid.type = ~0;
185 wstat->qid.version = ~0;
186 *((long long *)&wstat->qid.path) = ~0;
187 wstat->mode = ~0;
188 wstat->atime = ~0;
189 wstat->mtime = ~0;
190 wstat->length = ~0;
191 wstat->name = NULL;
192 wstat->uid = NULL;
193 wstat->gid = NULL;
194 wstat->muid = NULL;
195 wstat->n_uid = ~0;
196 wstat->n_gid = ~0;
197 wstat->n_muid = ~0;
198 wstat->extension = NULL;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700199}
200
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500201#ifdef CONFIG_9P_FSCACHE
202/**
203 * v9fs_alloc_inode - helper function to allocate an inode
204 * This callback is executed before setting up the inode so that we
205 * can associate a vcookie with each inode.
206 *
207 */
208
209struct inode *v9fs_alloc_inode(struct super_block *sb)
210{
211 struct v9fs_cookie *vcookie;
212 vcookie = (struct v9fs_cookie *)kmem_cache_alloc(vcookie_cache,
213 GFP_KERNEL);
214 if (!vcookie)
215 return NULL;
216
217 vcookie->fscache = NULL;
218 vcookie->qid = NULL;
219 spin_lock_init(&vcookie->lock);
220 return &vcookie->inode;
221}
222
223/**
224 * v9fs_destroy_inode - destroy an inode
225 *
226 */
227
228void v9fs_destroy_inode(struct inode *inode)
229{
230 kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode));
231}
232#endif
233
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700234/**
235 * v9fs_get_inode - helper function to setup an inode
236 * @sb: superblock
237 * @mode: mode to setup inode with
238 *
239 */
240
241struct inode *v9fs_get_inode(struct super_block *sb, int mode)
242{
Abhishek Kulkarni2bb54112009-07-19 13:41:56 -0600243 int err;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800244 struct inode *inode;
Eric Van Hensbergenb5016112005-09-09 13:04:27 -0700245 struct v9fs_session_info *v9ses = sb->s_fs_info;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700246
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500247 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700248
249 inode = new_inode(sb);
Abhishek Kulkarni2bb54112009-07-19 13:41:56 -0600250 if (!inode) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500251 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
Abhishek Kulkarni48559b4c2009-08-17 16:32:18 -0500252 return ERR_PTR(-ENOMEM);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700253 }
Abhishek Kulkarni2bb54112009-07-19 13:41:56 -0600254
255 inode->i_mode = mode;
256 inode->i_uid = current_fsuid();
257 inode->i_gid = current_fsgid();
258 inode->i_blocks = 0;
259 inode->i_rdev = 0;
260 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
261 inode->i_mapping->a_ops = &v9fs_addr_operations;
262
263 switch (mode & S_IFMT) {
264 case S_IFIFO:
265 case S_IFBLK:
266 case S_IFCHR:
267 case S_IFSOCK:
268 if (!v9fs_extended(v9ses)) {
269 P9_DPRINTK(P9_DEBUG_ERROR,
270 "special files without extended mode\n");
271 err = -EINVAL;
272 goto error;
273 }
274 init_special_inode(inode, inode->i_mode, inode->i_rdev);
275 break;
276 case S_IFREG:
277 inode->i_op = &v9fs_file_inode_operations;
278 inode->i_fop = &v9fs_file_operations;
279 break;
280 case S_IFLNK:
281 if (!v9fs_extended(v9ses)) {
282 P9_DPRINTK(P9_DEBUG_ERROR,
283 "extended modes used w/o 9P2000.u\n");
284 err = -EINVAL;
285 goto error;
286 }
287 inode->i_op = &v9fs_symlink_inode_operations;
288 break;
289 case S_IFDIR:
290 inc_nlink(inode);
291 if (v9fs_extended(v9ses))
292 inode->i_op = &v9fs_dir_inode_operations_ext;
293 else
294 inode->i_op = &v9fs_dir_inode_operations;
295 inode->i_fop = &v9fs_dir_operations;
296 break;
297 default:
298 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
299 mode, mode & S_IFMT);
300 err = -EINVAL;
301 goto error;
302 }
303
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700304 return inode;
Abhishek Kulkarni2bb54112009-07-19 13:41:56 -0600305
306error:
307 iput(inode);
308 return ERR_PTR(err);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700309}
310
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500311/*
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800312static struct v9fs_fid*
313v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
314{
315 int err;
Mika Kukkonen736c4b82006-12-06 20:36:29 -0800316 int nfid;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800317 struct v9fs_fid *ret;
318 struct v9fs_fcall *fcall;
319
320 nfid = v9fs_get_idpool(&v9ses->fidpool);
321 if (nfid < 0) {
322 eprintk(KERN_WARNING, "no free fids available\n");
Latchesar Ionkov731805b2006-03-07 21:55:42 -0800323 return ERR_PTR(-ENOSPC);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800324 }
325
326 err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
327 &fcall);
328
329 if (err < 0) {
Latchesar Ionkov41e5a6a2006-05-15 09:44:21 -0700330 if (fcall && fcall->id == RWALK)
331 goto clunk_fid;
332
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800333 PRINT_FCALL_ERROR("walk error", fcall);
334 v9fs_put_idpool(nfid, &v9ses->fidpool);
335 goto error;
336 }
337
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700338 kfree(fcall);
Latchesar Ionkov3cf64292006-01-08 01:04:58 -0800339 fcall = NULL;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800340 ret = v9fs_fid_create(v9ses, nfid);
341 if (!ret) {
342 err = -ENOMEM;
343 goto clunk_fid;
344 }
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700345
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800346 err = v9fs_fid_insert(ret, dentry);
347 if (err < 0) {
348 v9fs_fid_destroy(ret);
349 goto clunk_fid;
Latchesar Ionkov0b8dd172005-09-27 21:45:24 -0700350 }
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800351
352 return ret;
353
354clunk_fid:
355 v9fs_t_clunk(v9ses, nfid);
356
357error:
358 kfree(fcall);
359 return ERR_PTR(err);
360}
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500361*/
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800362
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500363
364/**
365 * v9fs_clear_inode - release an inode
366 * @inode: inode to release
367 *
368 */
369void v9fs_clear_inode(struct inode *inode)
370{
371 filemap_fdatawrite(inode->i_mapping);
372
373#ifdef CONFIG_9P_FSCACHE
374 v9fs_cache_inode_put_cookie(inode);
375#endif
376}
377
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600378/**
379 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
380 * @v9ses: session information
381 * @fid: fid to issue attribute request for
382 * @sb: superblock on which to create inode
383 *
384 */
385
Latchesar Ionkov5174fda2006-03-25 03:07:25 -0800386static struct inode *
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500387v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800388 struct super_block *sb)
389{
390 int err, umode;
391 struct inode *ret;
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500392 struct p9_wstat *st;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800393
394 ret = NULL;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500395 st = p9_client_stat(fid);
Abhishek Kulkarni02bc3562009-07-19 13:41:54 -0600396 if (IS_ERR(st))
397 return ERR_CAST(st);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800398
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500399 umode = p9mode2unixmode(v9ses, st->mode);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800400 ret = v9fs_get_inode(sb, umode);
401 if (IS_ERR(ret)) {
402 err = PTR_ERR(ret);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800403 goto error;
404 }
405
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500406 v9fs_stat2inode(st, ret, sb);
407 ret->i_ino = v9fs_qid2ino(&st->qid);
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500408
409#ifdef CONFIG_9P_FSCACHE
410 v9fs_vcookie_set_qid(ret, &st->qid);
411 v9fs_cache_inode_get_cookie(ret);
412#endif
Abhishek Kulkarni02bc3562009-07-19 13:41:54 -0600413 p9stat_free(st);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500414 kfree(st);
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500415
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800416 return ret;
417
418error:
Abhishek Kulkarni02bc3562009-07-19 13:41:54 -0600419 p9stat_free(st);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500420 kfree(st);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800421 return ERR_PTR(err);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700422}
423
424/**
425 * v9fs_remove - helper function to remove files and directories
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -0700426 * @dir: directory inode that is being deleted
427 * @file: dentry that is being deleted
428 * @rmdir: removing a directory
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700429 *
430 */
431
432static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
433{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500434 struct inode *file_inode;
435 struct v9fs_session_info *v9ses;
436 struct p9_fid *v9fid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700437
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500438 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700439 rmdir);
440
441 file_inode = file->d_inode;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700442 v9ses = v9fs_inode2v9ses(file_inode);
Latchesar Ionkovc959df92007-04-23 14:41:11 -0700443 v9fid = v9fs_fid_clone(file);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500444 if (IS_ERR(v9fid))
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800445 return PTR_ERR(v9fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700446
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500447 return p9_client_remove(v9fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700448}
449
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800450static int
451v9fs_open_created(struct inode *inode, struct file *file)
452{
453 return 0;
454}
455
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500456
457/**
458 * v9fs_create - Create a file
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600459 * @v9ses: session information
460 * @dir: directory that dentry is being created in
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500461 * @dentry: dentry that is being created
Abhishek Kulkarni0e155972009-07-19 13:41:55 -0600462 * @extension: 9p2000.u extension string to support devices, etc.
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500463 * @perm: create permissions
464 * @mode: open mode
465 *
466 */
467static struct p9_fid *
468v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
469 struct dentry *dentry, char *extension, u32 perm, u8 mode)
470{
471 int err;
472 char *name;
473 struct p9_fid *dfid, *ofid, *fid;
474 struct inode *inode;
475
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500476 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
477
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500478 err = 0;
479 ofid = NULL;
480 fid = NULL;
481 name = (char *) dentry->d_name.name;
482 dfid = v9fs_fid_clone(dentry->d_parent);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500483 if (IS_ERR(dfid)) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500484 err = PTR_ERR(dfid);
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500485 P9_DPRINTK(P9_DEBUG_VFS, "fid clone failed %d\n", err);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500486 dfid = NULL;
487 goto error;
488 }
489
490 /* clone a fid to use for creation */
491 ofid = p9_client_walk(dfid, 0, NULL, 1);
492 if (IS_ERR(ofid)) {
493 err = PTR_ERR(ofid);
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500494 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500495 ofid = NULL;
496 goto error;
497 }
498
499 err = p9_client_fcreate(ofid, name, perm, mode, extension);
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500500 if (err < 0) {
501 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500502 goto error;
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500503 }
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500504
505 /* now walk from the parent so we can get unopened fid */
506 fid = p9_client_walk(dfid, 1, &name, 0);
507 if (IS_ERR(fid)) {
508 err = PTR_ERR(fid);
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500509 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500510 fid = NULL;
511 goto error;
512 } else
513 dfid = NULL;
514
515 /* instantiate inode and assign the unopened fid to the dentry */
516 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
517 if (IS_ERR(inode)) {
518 err = PTR_ERR(inode);
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500519 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500520 goto error;
521 }
522
Latchesar Ionkovba176742007-10-17 14:31:07 -0500523 if (v9ses->cache)
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500524 dentry->d_op = &v9fs_cached_dentry_operations;
525 else
526 dentry->d_op = &v9fs_dentry_operations;
527
528 d_instantiate(dentry, inode);
Abhishek Kulkarni50fb6d22009-07-19 13:41:57 -0600529 err = v9fs_fid_add(dentry, fid);
530 if (err < 0)
531 goto error;
532
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500533 return ofid;
534
535error:
536 if (dfid)
537 p9_client_clunk(dfid);
538
539 if (ofid)
540 p9_client_clunk(ofid);
541
542 if (fid)
543 p9_client_clunk(fid);
544
545 return ERR_PTR(err);
546}
547
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700548/**
549 * v9fs_vfs_create - VFS hook to create files
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600550 * @dir: directory inode that is being created
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700551 * @dentry: dentry that is being deleted
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800552 * @mode: create permissions
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700553 * @nd: path information
554 *
555 */
556
557static int
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800558v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700559 struct nameidata *nd)
560{
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800561 int err;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500562 u32 perm;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800563 int flags;
564 struct v9fs_session_info *v9ses;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500565 struct p9_fid *fid;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800566 struct file *filp;
567
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500568 err = 0;
569 fid = NULL;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800570 v9ses = v9fs_inode2v9ses(dir);
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800571 perm = unixmode2p9mode(v9ses, mode);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800572 if (nd && nd->flags & LOOKUP_OPEN)
573 flags = nd->intent.open.flags - 1;
574 else
575 flags = O_RDWR;
576
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500577 fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
Eric Van Hensbergen2e4bef42008-06-24 17:39:39 -0500578 v9fs_uflags2omode(flags, v9fs_extended(v9ses)));
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500579 if (IS_ERR(fid)) {
580 err = PTR_ERR(fid);
581 fid = NULL;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800582 goto error;
583 }
584
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500585 /* if we are opening a file, assign the open fid to the file */
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800586 if (nd && nd->flags & LOOKUP_OPEN) {
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800587 filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created);
588 if (IS_ERR(filp)) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500589 err = PTR_ERR(filp);
590 goto error;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800591 }
592
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500593 filp->private_data = fid;
594 } else
595 p9_client_clunk(fid);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800596
597 return 0;
598
599error:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500600 if (fid)
601 p9_client_clunk(fid);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800602
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800603 return err;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700604}
605
606/**
607 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600608 * @dir: inode that is being unlinked
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700609 * @dentry: dentry that is being unlinked
610 * @mode: mode for new directory
611 *
612 */
613
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800614static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700615{
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800616 int err;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500617 u32 perm;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800618 struct v9fs_session_info *v9ses;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500619 struct p9_fid *fid;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800620
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500621 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
622 err = 0;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800623 v9ses = v9fs_inode2v9ses(dir);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800624 perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500625 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_OREAD);
626 if (IS_ERR(fid)) {
627 err = PTR_ERR(fid);
628 fid = NULL;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800629 }
630
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500631 if (fid)
632 p9_client_clunk(fid);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800633
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800634 return err;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700635}
636
637/**
638 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
639 * @dir: inode that is being walked from
640 * @dentry: dentry that is being walked to?
641 * @nameidata: path data
642 *
643 */
644
645static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
646 struct nameidata *nameidata)
647{
648 struct super_block *sb;
649 struct v9fs_session_info *v9ses;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500650 struct p9_fid *dfid, *fid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700651 struct inode *inode;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500652 char *name;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700653 int result = 0;
654
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500655 P9_DPRINTK(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
Latchesar Ionkov731805b2006-03-07 21:55:42 -0800656 dir, dentry->d_name.name, dentry, nameidata);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700657
658 sb = dir->i_sb;
659 v9ses = v9fs_inode2v9ses(dir);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500660 dfid = v9fs_fid_lookup(dentry->d_parent);
661 if (IS_ERR(dfid))
David Howellse231c2e2008-02-07 00:15:26 -0800662 return ERR_CAST(dfid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700663
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500664 name = (char *) dentry->d_name.name;
665 fid = p9_client_walk(dfid, 1, &name, 1);
666 if (IS_ERR(fid)) {
667 result = PTR_ERR(fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700668 if (result == -ENOENT) {
669 d_add(dentry, NULL);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700670 return NULL;
671 }
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700672
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500673 return ERR_PTR(result);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700674 }
675
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500676 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
677 if (IS_ERR(inode)) {
678 result = PTR_ERR(inode);
679 inode = NULL;
680 goto error;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700681 }
682
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500683 result = v9fs_fid_add(dentry, fid);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800684 if (result < 0)
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500685 goto error;
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -0800686
Latchesar Ionkovba176742007-10-17 14:31:07 -0500687 if ((fid->qid.version) && (v9ses->cache))
Eric Van Hensbergene03abc02007-02-11 13:21:39 -0600688 dentry->d_op = &v9fs_cached_dentry_operations;
689 else
690 dentry->d_op = &v9fs_dentry_operations;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700691
692 d_add(dentry, inode);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700693 return NULL;
694
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500695error:
Julien Brunel62aa5282008-09-24 16:22:22 -0500696 p9_client_clunk(fid);
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800697
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700698 return ERR_PTR(result);
699}
700
701/**
702 * v9fs_vfs_unlink - VFS unlink hook to delete an inode
703 * @i: inode that is being unlinked
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -0700704 * @d: dentry that is being unlinked
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700705 *
706 */
707
708static int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
709{
710 return v9fs_remove(i, d, 0);
711}
712
713/**
714 * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
715 * @i: inode that is being unlinked
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -0700716 * @d: dentry that is being unlinked
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700717 *
718 */
719
720static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
721{
722 return v9fs_remove(i, d, 1);
723}
724
725/**
726 * v9fs_vfs_rename - VFS hook to rename an inode
727 * @old_dir: old dir inode
728 * @old_dentry: old dentry
729 * @new_dir: new dir inode
730 * @new_dentry: new dentry
731 *
732 */
733
734static int
735v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
736 struct inode *new_dir, struct dentry *new_dentry)
737{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500738 struct inode *old_inode;
739 struct v9fs_session_info *v9ses;
740 struct p9_fid *oldfid;
741 struct p9_fid *olddirfid;
742 struct p9_fid *newdirfid;
743 struct p9_wstat wstat;
744 int retval;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700745
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500746 P9_DPRINTK(P9_DEBUG_VFS, "\n");
747 retval = 0;
748 old_inode = old_dentry->d_inode;
749 v9ses = v9fs_inode2v9ses(old_inode);
750 oldfid = v9fs_fid_lookup(old_dentry);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500751 if (IS_ERR(oldfid))
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800752 return PTR_ERR(oldfid);
753
754 olddirfid = v9fs_fid_clone(old_dentry->d_parent);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500755 if (IS_ERR(olddirfid)) {
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800756 retval = PTR_ERR(olddirfid);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500757 goto done;
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800758 }
759
760 newdirfid = v9fs_fid_clone(new_dentry->d_parent);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500761 if (IS_ERR(newdirfid)) {
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800762 retval = PTR_ERR(newdirfid);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500763 goto clunk_olddir;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700764 }
765
766 /* 9P can only handle file rename in the same directory */
767 if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500768 P9_DPRINTK(P9_DEBUG_ERROR,
769 "old dir and new dir are different\n");
Eric Van Hensbergen621997c2007-01-26 00:57:04 -0800770 retval = -EXDEV;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500771 goto clunk_newdir;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700772 }
773
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800774 v9fs_blank_wstat(&wstat);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500775 wstat.muid = v9ses->uname;
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800776 wstat.name = (char *) new_dentry->d_name.name;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500777 retval = p9_client_wstat(oldfid, &wstat);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700778
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500779clunk_newdir:
Latchesar Ionkov22150c42007-10-23 13:48:33 -0500780 p9_client_clunk(newdirfid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700781
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500782clunk_olddir:
Latchesar Ionkov22150c42007-10-23 13:48:33 -0500783 p9_client_clunk(olddirfid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700784
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500785done:
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700786 return retval;
787}
788
789/**
Adrian Bunk943ffb52006-01-10 00:10:13 +0100790 * v9fs_vfs_getattr - retrieve file metadata
Eric Van Hensbergenee443992008-03-05 07:08:09 -0600791 * @mnt: mount information
792 * @dentry: file to get attributes on
793 * @stat: metadata structure to populate
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700794 *
795 */
796
797static int
798v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
799 struct kstat *stat)
800{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500801 int err;
802 struct v9fs_session_info *v9ses;
803 struct p9_fid *fid;
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500804 struct p9_wstat *st;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700805
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500806 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
807 err = -EPERM;
808 v9ses = v9fs_inode2v9ses(dentry->d_inode);
Abhishek Kulkarni60e78d22009-09-23 13:00:27 -0500809 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
Eric Van Hensbergen9523a842007-07-13 13:01:27 -0500810 return simple_getattr(mnt, dentry, stat);
811
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500812 fid = v9fs_fid_lookup(dentry);
813 if (IS_ERR(fid))
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800814 return PTR_ERR(fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700815
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500816 st = p9_client_stat(fid);
817 if (IS_ERR(st))
818 return PTR_ERR(st);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700819
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500820 v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700821 generic_fillattr(dentry->d_inode, stat);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700822
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500823 kfree(st);
824 return 0;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700825}
826
827/**
828 * v9fs_vfs_setattr - set file metadata
829 * @dentry: file whose metadata to set
830 * @iattr: metadata assignment structure
831 *
832 */
833
834static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
835{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500836 int retval;
837 struct v9fs_session_info *v9ses;
838 struct p9_fid *fid;
839 struct p9_wstat wstat;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700840
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500841 P9_DPRINTK(P9_DEBUG_VFS, "\n");
842 retval = -EPERM;
843 v9ses = v9fs_inode2v9ses(dentry->d_inode);
844 fid = v9fs_fid_lookup(dentry);
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800845 if(IS_ERR(fid))
846 return PTR_ERR(fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700847
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800848 v9fs_blank_wstat(&wstat);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700849 if (iattr->ia_valid & ATTR_MODE)
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800850 wstat.mode = unixmode2p9mode(v9ses, iattr->ia_mode);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700851
852 if (iattr->ia_valid & ATTR_MTIME)
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800853 wstat.mtime = iattr->ia_mtime.tv_sec;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700854
855 if (iattr->ia_valid & ATTR_ATIME)
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800856 wstat.atime = iattr->ia_atime.tv_sec;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700857
858 if (iattr->ia_valid & ATTR_SIZE)
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800859 wstat.length = iattr->ia_size;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700860
Latchesar Ionkov24056692007-10-17 14:31:07 -0500861 if (v9fs_extended(v9ses)) {
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800862 if (iattr->ia_valid & ATTR_UID)
863 wstat.n_uid = iattr->ia_uid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700864
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800865 if (iattr->ia_valid & ATTR_GID)
866 wstat.n_gid = iattr->ia_gid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700867 }
868
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500869 retval = p9_client_wstat(fid, &wstat);
870 if (retval >= 0)
871 retval = inode_setattr(dentry->d_inode, iattr);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700872
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500873 return retval;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700874}
875
876/**
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800877 * v9fs_stat2inode - populate an inode structure with mistat info
878 * @stat: Plan 9 metadata (mistat) structure
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700879 * @inode: inode to populate
880 * @sb: superblock of filesystem
881 *
882 */
883
884void
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500885v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800886 struct super_block *sb)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700887{
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800888 char ext[32];
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700889 struct v9fs_session_info *v9ses = sb->s_fs_info;
890
891 inode->i_nlink = 1;
892
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800893 inode->i_atime.tv_sec = stat->atime;
894 inode->i_mtime.tv_sec = stat->mtime;
895 inode->i_ctime.tv_sec = stat->mtime;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700896
Latchesar Ionkovbd32b822007-10-17 14:31:07 -0500897 inode->i_uid = v9ses->dfltuid;
898 inode->i_gid = v9ses->dfltgid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700899
Latchesar Ionkov24056692007-10-17 14:31:07 -0500900 if (v9fs_extended(v9ses)) {
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800901 inode->i_uid = stat->n_uid;
902 inode->i_gid = stat->n_gid;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700903 }
904
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800905 inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700906 if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
907 char type = 0;
908 int major = -1;
909 int minor = -1;
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800910
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500911 strncpy(ext, stat->extension, sizeof(ext));
Latchesar Ionkov531b1092006-01-08 01:05:00 -0800912 sscanf(ext, "%c %u %u", &type, &major, &minor);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700913 switch (type) {
914 case 'c':
915 inode->i_mode &= ~S_IFBLK;
916 inode->i_mode |= S_IFCHR;
917 break;
918 case 'b':
919 break;
920 default:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500921 P9_DPRINTK(P9_DEBUG_ERROR,
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500922 "Unknown special type %c %s\n", type,
923 stat->extension);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700924 };
925 inode->i_rdev = MKDEV(major, minor);
Magnus Deininger57c7b4e2008-10-17 12:44:46 -0500926 init_special_inode(inode, inode->i_mode, inode->i_rdev);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700927 } else
928 inode->i_rdev = 0;
929
Abhishek Kulkarni7549ae32009-09-22 11:34:05 -0500930 i_size_write(inode, stat->length);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700931
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500932 /* not real number of blocks, but 512 byte ones ... */
Abhishek Kulkarni7549ae32009-09-22 11:34:05 -0500933 inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700934}
935
936/**
937 * v9fs_qid2ino - convert qid into inode number
938 * @qid: qid to hash
939 *
940 * BUG: potential for inode number collisions?
941 */
942
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500943ino_t v9fs_qid2ino(struct p9_qid *qid)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700944{
945 u64 path = qid->path + 2;
946 ino_t i = 0;
947
948 if (sizeof(ino_t) == sizeof(path))
949 memcpy(&i, &path, sizeof(ino_t));
950 else
951 i = (ino_t) (path ^ (path >> 32));
952
953 return i;
954}
955
956/**
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700957 * v9fs_readlink - read a symlink's location (internal version)
958 * @dentry: dentry for symlink
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -0700959 * @buffer: buffer to load symlink location into
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700960 * @buflen: length of buffer
961 *
962 */
963
964static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
965{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500966 int retval;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700967
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500968 struct v9fs_session_info *v9ses;
969 struct p9_fid *fid;
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500970 struct p9_wstat *st;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700971
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500972 P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
973 retval = -EPERM;
974 v9ses = v9fs_inode2v9ses(dentry->d_inode);
975 fid = v9fs_fid_lookup(dentry);
Latchesar Ionkovba176742007-10-17 14:31:07 -0500976 if (IS_ERR(fid))
Eric Van Hensbergenda977b22007-01-26 00:57:06 -0800977 return PTR_ERR(fid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700978
Latchesar Ionkov24056692007-10-17 14:31:07 -0500979 if (!v9fs_extended(v9ses))
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500980 return -EBADF;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700981
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500982 st = p9_client_stat(fid);
983 if (IS_ERR(st))
984 return PTR_ERR(st);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700985
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500986 if (!(st->mode & P9_DMSYMLINK)) {
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700987 retval = -EINVAL;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500988 goto done;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700989 }
990
991 /* copy extension buffer into buffer */
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500992 strncpy(buffer, st->extension, buflen);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700993
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500994 P9_DPRINTK(P9_DEBUG_VFS,
Eric Van Hensbergen51a87c52008-10-16 08:30:07 -0500995 "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500996
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -0700997 retval = buflen;
998
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500999done:
1000 kfree(st);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001001 return retval;
1002}
1003
1004/**
1005 * v9fs_vfs_readlink - read a symlink's location
1006 * @dentry: dentry for symlink
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001007 * @buffer: buffer to load symlink location into
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001008 * @buflen: length of buffer
1009 *
1010 */
1011
1012static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer,
1013 int buflen)
1014{
1015 int retval;
1016 int ret;
1017 char *link = __getname();
1018
Florin Malita0710d362006-06-25 05:48:31 -07001019 if (unlikely(!link))
1020 return -ENOMEM;
1021
Latchesar Ionkova1f9d8d2005-09-22 21:43:52 -07001022 if (buflen > PATH_MAX)
1023 buflen = PATH_MAX;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001024
Wu Fengguang7dd0cdc2008-12-19 16:47:40 -06001025 P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
1026 dentry);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001027
1028 retval = v9fs_readlink(dentry, link, buflen);
1029
1030 if (retval > 0) {
1031 if ((ret = copy_to_user(buffer, link, retval)) != 0) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001032 P9_DPRINTK(P9_DEBUG_ERROR,
1033 "problem copying to user: %d\n", ret);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001034 retval = ret;
1035 }
1036 }
1037
Davi Arnautce44eeb2005-11-07 00:59:36 -08001038 __putname(link);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001039 return retval;
1040}
1041
1042/**
1043 * v9fs_vfs_follow_link - follow a symlink path
1044 * @dentry: dentry for symlink
1045 * @nd: nameidata
1046 *
1047 */
1048
1049static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1050{
1051 int len = 0;
1052 char *link = __getname();
1053
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001054 P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001055
1056 if (!link)
1057 link = ERR_PTR(-ENOMEM);
1058 else {
Latchesar Ionkov16cce6d2006-03-25 03:07:26 -08001059 len = v9fs_readlink(dentry, link, PATH_MAX);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001060
1061 if (len < 0) {
Davi Arnautce44eeb2005-11-07 00:59:36 -08001062 __putname(link);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001063 link = ERR_PTR(len);
1064 } else
1065 link[len] = 0;
1066 }
1067 nd_set_link(nd, link);
1068
1069 return NULL;
1070}
1071
1072/**
1073 * v9fs_vfs_put_link - release a symlink path
1074 * @dentry: dentry for symlink
1075 * @nd: nameidata
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001076 * @p: unused
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001077 *
1078 */
1079
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001080static void
1081v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001082{
1083 char *s = nd_get_link(nd);
1084
Duane Griffin6ff23202008-12-19 16:45:21 -06001085 P9_DPRINTK(P9_DEBUG_VFS, " %s %s\n", dentry->d_name.name,
1086 IS_ERR(s) ? "<error>" : s);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001087 if (!IS_ERR(s))
Davi Arnautce44eeb2005-11-07 00:59:36 -08001088 __putname(s);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001089}
1090
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001091/**
1092 * v9fs_vfs_mkspecial - create a special file
1093 * @dir: inode to create special file in
1094 * @dentry: dentry to create
1095 * @mode: mode to create special file
1096 * @extension: 9p2000.u format extension string representing special file
1097 *
1098 */
1099
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001100static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1101 int mode, const char *extension)
1102{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001103 u32 perm;
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001104 struct v9fs_session_info *v9ses;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001105 struct p9_fid *fid;
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001106
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -08001107 v9ses = v9fs_inode2v9ses(dir);
Latchesar Ionkov24056692007-10-17 14:31:07 -05001108 if (!v9fs_extended(v9ses)) {
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001109 P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n");
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -08001110 return -EPERM;
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001111 }
1112
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001113 perm = unixmode2p9mode(v9ses, mode);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001114 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm,
1115 P9_OREAD);
1116 if (IS_ERR(fid))
1117 return PTR_ERR(fid);
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001118
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001119 p9_client_clunk(fid);
Latchesar Ionkov6a3124a2006-03-02 02:54:30 -08001120 return 0;
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001121}
1122
1123/**
1124 * v9fs_vfs_symlink - helper function to create symlinks
1125 * @dir: directory inode containing symlink
1126 * @dentry: dentry for symlink
1127 * @symname: symlink data
1128 *
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001129 * See Also: 9P2000.u RFC for more information
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001130 *
1131 */
1132
1133static int
1134v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1135{
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001136 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino,
1137 dentry->d_name.name, symname);
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001138
1139 return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname);
1140}
1141
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001142/**
1143 * v9fs_vfs_link - create a hardlink
1144 * @old_dentry: dentry for file to link to
1145 * @dir: inode destination for new link
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -07001146 * @dentry: dentry for link
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001147 *
1148 */
1149
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001150static int
1151v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1152 struct dentry *dentry)
1153{
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001154 int retval;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001155 struct p9_fid *oldfid;
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001156 char *name;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001157
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001158 P9_DPRINTK(P9_DEBUG_VFS,
1159 " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001160 old_dentry->d_name.name);
1161
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001162 oldfid = v9fs_fid_clone(old_dentry);
Latchesar Ionkovba176742007-10-17 14:31:07 -05001163 if (IS_ERR(oldfid))
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001164 return PTR_ERR(oldfid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001165
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001166 name = __getname();
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001167 if (unlikely(!name)) {
1168 retval = -ENOMEM;
1169 goto clunk_fid;
1170 }
Florin Malita0710d362006-06-25 05:48:31 -07001171
Latchesar Ionkov16cce6d2006-03-25 03:07:26 -08001172 sprintf(name, "%d\n", oldfid->fid);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001173 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name);
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001174 __putname(name);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001175
Eric Van Hensbergenda977b22007-01-26 00:57:06 -08001176clunk_fid:
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001177 p9_client_clunk(oldfid);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001178 return retval;
1179}
1180
1181/**
1182 * v9fs_vfs_mknod - create a special file
1183 * @dir: inode destination for new link
1184 * @dentry: dentry for file
1185 * @mode: mode for creation
Eric Van Hensbergenee443992008-03-05 07:08:09 -06001186 * @rdev: device associated with special file
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001187 *
1188 */
1189
1190static int
1191v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1192{
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001193 int retval;
1194 char *name;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001195
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001196 P9_DPRINTK(P9_DEBUG_VFS,
1197 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001198 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
1199
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001200 if (!new_valid_dev(rdev))
1201 return -EINVAL;
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -07001202
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001203 name = __getname();
Eugene Teoc0291a02006-03-25 03:07:27 -08001204 if (!name)
1205 return -ENOMEM;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001206 /* build extension */
1207 if (S_ISBLK(mode))
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001208 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001209 else if (S_ISCHR(mode))
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001210 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
Eric Van Hensbergen73c592b2005-09-09 13:04:26 -07001211 else if (S_ISFIFO(mode))
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001212 *name = 0;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001213 else {
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001214 __putname(name);
1215 return -EINVAL;
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001216 }
1217
Latchesar Ionkov531b1092006-01-08 01:05:00 -08001218 retval = v9fs_vfs_mkspecial(dir, dentry, mode, name);
1219 __putname(name);
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001220
1221 return retval;
1222}
1223
Arjan van de Ven754661f2007-02-12 00:55:38 -08001224static const struct inode_operations v9fs_dir_inode_operations_ext = {
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001225 .create = v9fs_vfs_create,
1226 .lookup = v9fs_vfs_lookup,
1227 .symlink = v9fs_vfs_symlink,
1228 .link = v9fs_vfs_link,
1229 .unlink = v9fs_vfs_unlink,
1230 .mkdir = v9fs_vfs_mkdir,
1231 .rmdir = v9fs_vfs_rmdir,
1232 .mknod = v9fs_vfs_mknod,
1233 .rename = v9fs_vfs_rename,
1234 .readlink = v9fs_vfs_readlink,
1235 .getattr = v9fs_vfs_getattr,
1236 .setattr = v9fs_vfs_setattr,
1237};
1238
Arjan van de Ven754661f2007-02-12 00:55:38 -08001239static const struct inode_operations v9fs_dir_inode_operations = {
Eric Van Hensbergenb5016112005-09-09 13:04:27 -07001240 .create = v9fs_vfs_create,
1241 .lookup = v9fs_vfs_lookup,
1242 .unlink = v9fs_vfs_unlink,
1243 .mkdir = v9fs_vfs_mkdir,
1244 .rmdir = v9fs_vfs_rmdir,
1245 .mknod = v9fs_vfs_mknod,
1246 .rename = v9fs_vfs_rename,
1247 .getattr = v9fs_vfs_getattr,
1248 .setattr = v9fs_vfs_setattr,
1249};
1250
Arjan van de Ven754661f2007-02-12 00:55:38 -08001251static const struct inode_operations v9fs_file_inode_operations = {
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001252 .getattr = v9fs_vfs_getattr,
1253 .setattr = v9fs_vfs_setattr,
1254};
1255
Arjan van de Ven754661f2007-02-12 00:55:38 -08001256static const struct inode_operations v9fs_symlink_inode_operations = {
Eric Van Hensbergen2bad8472005-09-09 13:04:19 -07001257 .readlink = v9fs_vfs_readlink,
1258 .follow_link = v9fs_vfs_follow_link,
1259 .put_link = v9fs_vfs_put_link,
1260 .getattr = v9fs_vfs_getattr,
1261 .setattr = v9fs_vfs_setattr,
1262};