2 * linux/fs/9p/vfs_inode.c
4 * This file contains vfs inode ops for the 9P2000 protocol.
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
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.
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
26 #include <linux/module.h>
27 #include <linux/errno.h>
29 #include <linux/file.h>
30 #include <linux/pagemap.h>
31 #include <linux/stat.h>
32 #include <linux/string.h>
33 #include <linux/inet.h>
34 #include <linux/namei.h>
35 #include <linux/idr.h>
36 #include <linux/sched.h>
37 #include <net/9p/9p.h>
38 #include <net/9p/client.h>
44 static const struct inode_operations v9fs_dir_inode_operations
;
45 static const struct inode_operations v9fs_dir_inode_operations_ext
;
46 static const struct inode_operations v9fs_file_inode_operations
;
47 static const struct inode_operations v9fs_symlink_inode_operations
;
50 * unixmode2p9mode - convert unix mode bits to plan 9
51 * @v9ses: v9fs session information
52 * @mode: mode to convert
56 static int unixmode2p9mode(struct v9fs_session_info
*v9ses
, int mode
)
62 if (v9fs_extended(v9ses
)) {
65 if (v9ses
->nodev
== 0) {
69 res
|= P9_DMNAMEDPIPE
;
76 if ((mode
& S_ISUID
) == S_ISUID
)
78 if ((mode
& S_ISGID
) == S_ISGID
)
80 if ((mode
& P9_DMLINK
))
88 * p9mode2unixmode- convert plan9 mode bits to unix mode bits
89 * @v9ses: v9fs session information
90 * @mode: mode to convert
94 static int p9mode2unixmode(struct v9fs_session_info
*v9ses
, int mode
)
100 if ((mode
& P9_DMDIR
) == P9_DMDIR
)
102 else if ((mode
& P9_DMSYMLINK
) && (v9fs_extended(v9ses
)))
104 else if ((mode
& P9_DMSOCKET
) && (v9fs_extended(v9ses
))
105 && (v9ses
->nodev
== 0))
107 else if ((mode
& P9_DMNAMEDPIPE
) && (v9fs_extended(v9ses
))
108 && (v9ses
->nodev
== 0))
110 else if ((mode
& P9_DMDEVICE
) && (v9fs_extended(v9ses
))
111 && (v9ses
->nodev
== 0))
116 if (v9fs_extended(v9ses
)) {
117 if ((mode
& P9_DMSETUID
) == P9_DMSETUID
)
120 if ((mode
& P9_DMSETGID
) == P9_DMSETGID
)
127 int v9fs_uflags2omode(int uflags
)
150 if (uflags
& O_TRUNC
)
153 if (uflags
& O_APPEND
)
160 * v9fs_blank_wstat - helper function to setup a 9P stat structure
161 * @v9ses: 9P session info (for determining extended mode)
162 * @wstat: structure to initialize
167 v9fs_blank_wstat(struct p9_wstat
*wstat
)
171 wstat
->qid
.type
= ~0;
172 wstat
->qid
.version
= ~0;
173 *((long long *)&wstat
->qid
.path
) = ~0;
185 wstat
->extension
= NULL
;
189 * v9fs_get_inode - helper function to setup an inode
191 * @mode: mode to setup inode with
195 struct inode
*v9fs_get_inode(struct super_block
*sb
, int mode
)
198 struct v9fs_session_info
*v9ses
= sb
->s_fs_info
;
200 P9_DPRINTK(P9_DEBUG_VFS
, "super block: %p mode: %o\n", sb
, mode
);
202 inode
= new_inode(sb
);
204 inode
->i_mode
= mode
;
205 inode
->i_uid
= current
->fsuid
;
206 inode
->i_gid
= current
->fsgid
;
209 inode
->i_atime
= inode
->i_mtime
= inode
->i_ctime
= CURRENT_TIME
;
210 inode
->i_mapping
->a_ops
= &v9fs_addr_operations
;
212 switch (mode
& S_IFMT
) {
217 if (!v9fs_extended(v9ses
)) {
218 P9_DPRINTK(P9_DEBUG_ERROR
,
219 "special files without extended mode\n");
220 return ERR_PTR(-EINVAL
);
222 init_special_inode(inode
, inode
->i_mode
,
226 inode
->i_op
= &v9fs_file_inode_operations
;
227 inode
->i_fop
= &v9fs_file_operations
;
230 if (!v9fs_extended(v9ses
)) {
231 P9_DPRINTK(P9_DEBUG_ERROR
,
232 "extended modes used w/o 9P2000.u\n");
233 return ERR_PTR(-EINVAL
);
235 inode
->i_op
= &v9fs_symlink_inode_operations
;
239 if (v9fs_extended(v9ses
))
240 inode
->i_op
= &v9fs_dir_inode_operations_ext
;
242 inode
->i_op
= &v9fs_dir_inode_operations
;
243 inode
->i_fop
= &v9fs_dir_operations
;
246 P9_DPRINTK(P9_DEBUG_ERROR
,
247 "BAD mode 0x%x S_IFMT 0x%x\n",
248 mode
, mode
& S_IFMT
);
249 return ERR_PTR(-EINVAL
);
252 P9_EPRINTK(KERN_WARNING
, "Problem allocating inode\n");
253 return ERR_PTR(-ENOMEM
);
259 static struct v9fs_fid*
260 v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
264 struct v9fs_fid *ret;
265 struct v9fs_fcall *fcall;
267 nfid = v9fs_get_idpool(&v9ses->fidpool);
269 eprintk(KERN_WARNING, "no free fids available\n");
270 return ERR_PTR(-ENOSPC);
273 err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
277 if (fcall && fcall->id == RWALK)
280 PRINT_FCALL_ERROR("walk error", fcall);
281 v9fs_put_idpool(nfid, &v9ses->fidpool);
287 ret = v9fs_fid_create(v9ses, nfid);
293 err = v9fs_fid_insert(ret, dentry);
295 v9fs_fid_destroy(ret);
302 v9fs_t_clunk(v9ses, nfid);
310 static struct inode
*
311 v9fs_inode_from_fid(struct v9fs_session_info
*v9ses
, struct p9_fid
*fid
,
312 struct super_block
*sb
)
319 st
= p9_client_stat(fid
);
326 umode
= p9mode2unixmode(v9ses
, st
->mode
);
327 ret
= v9fs_get_inode(sb
, umode
);
334 v9fs_stat2inode(st
, ret
, sb
);
335 ret
->i_ino
= v9fs_qid2ino(&st
->qid
);
348 * v9fs_remove - helper function to remove files and directories
349 * @dir: directory inode that is being deleted
350 * @file: dentry that is being deleted
351 * @rmdir: removing a directory
355 static int v9fs_remove(struct inode
*dir
, struct dentry
*file
, int rmdir
)
357 struct inode
*file_inode
;
358 struct v9fs_session_info
*v9ses
;
359 struct p9_fid
*v9fid
;
361 P9_DPRINTK(P9_DEBUG_VFS
, "inode: %p dentry: %p rmdir: %d\n", dir
, file
,
364 file_inode
= file
->d_inode
;
365 v9ses
= v9fs_inode2v9ses(file_inode
);
366 v9fid
= v9fs_fid_clone(file
);
368 return PTR_ERR(v9fid
);
370 return p9_client_remove(v9fid
);
374 v9fs_open_created(struct inode
*inode
, struct file
*file
)
381 * v9fs_create - Create a file
382 * @dentry: dentry that is being created
383 * @perm: create permissions
387 static struct p9_fid
*
388 v9fs_create(struct v9fs_session_info
*v9ses
, struct inode
*dir
,
389 struct dentry
*dentry
, char *extension
, u32 perm
, u8 mode
)
393 struct p9_fid
*dfid
, *ofid
, *fid
;
399 name
= (char *) dentry
->d_name
.name
;
400 dfid
= v9fs_fid_clone(dentry
->d_parent
);
407 /* clone a fid to use for creation */
408 ofid
= p9_client_walk(dfid
, 0, NULL
, 1);
415 err
= p9_client_fcreate(ofid
, name
, perm
, mode
, extension
);
419 /* now walk from the parent so we can get unopened fid */
420 fid
= p9_client_walk(dfid
, 1, &name
, 0);
428 /* instantiate inode and assign the unopened fid to the dentry */
429 inode
= v9fs_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
431 err
= PTR_ERR(inode
);
436 dentry
->d_op
= &v9fs_cached_dentry_operations
;
438 dentry
->d_op
= &v9fs_dentry_operations
;
440 d_instantiate(dentry
, inode
);
441 v9fs_fid_add(dentry
, fid
);
446 p9_client_clunk(dfid
);
449 p9_client_clunk(ofid
);
452 p9_client_clunk(fid
);
458 * v9fs_vfs_create - VFS hook to create files
459 * @inode: directory inode that is being created
460 * @dentry: dentry that is being deleted
461 * @mode: create permissions
462 * @nd: path information
467 v9fs_vfs_create(struct inode
*dir
, struct dentry
*dentry
, int mode
,
468 struct nameidata
*nd
)
473 struct v9fs_session_info
*v9ses
;
479 v9ses
= v9fs_inode2v9ses(dir
);
480 perm
= unixmode2p9mode(v9ses
, mode
);
481 if (nd
&& nd
->flags
& LOOKUP_OPEN
)
482 flags
= nd
->intent
.open
.flags
- 1;
486 fid
= v9fs_create(v9ses
, dir
, dentry
, NULL
, perm
,
487 v9fs_uflags2omode(flags
));
494 /* if we are opening a file, assign the open fid to the file */
495 if (nd
&& nd
->flags
& LOOKUP_OPEN
) {
496 filp
= lookup_instantiate_filp(nd
, dentry
, v9fs_open_created
);
502 filp
->private_data
= fid
;
504 p9_client_clunk(fid
);
510 p9_client_clunk(fid
);
516 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
517 * @inode: inode that is being unlinked
518 * @dentry: dentry that is being unlinked
519 * @mode: mode for new directory
523 static int v9fs_vfs_mkdir(struct inode
*dir
, struct dentry
*dentry
, int mode
)
527 struct v9fs_session_info
*v9ses
;
530 P9_DPRINTK(P9_DEBUG_VFS
, "name %s\n", dentry
->d_name
.name
);
532 v9ses
= v9fs_inode2v9ses(dir
);
533 perm
= unixmode2p9mode(v9ses
, mode
| S_IFDIR
);
534 fid
= v9fs_create(v9ses
, dir
, dentry
, NULL
, perm
, P9_OREAD
);
541 p9_client_clunk(fid
);
547 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
548 * @dir: inode that is being walked from
549 * @dentry: dentry that is being walked to?
550 * @nameidata: path data
554 static struct dentry
*v9fs_vfs_lookup(struct inode
*dir
, struct dentry
*dentry
,
555 struct nameidata
*nameidata
)
557 struct super_block
*sb
;
558 struct v9fs_session_info
*v9ses
;
559 struct p9_fid
*dfid
, *fid
;
564 P9_DPRINTK(P9_DEBUG_VFS
, "dir: %p dentry: (%s) %p nameidata: %p\n",
565 dir
, dentry
->d_name
.name
, dentry
, nameidata
);
568 v9ses
= v9fs_inode2v9ses(dir
);
569 dfid
= v9fs_fid_lookup(dentry
->d_parent
);
571 return ERR_PTR(PTR_ERR(dfid
));
573 name
= (char *) dentry
->d_name
.name
;
574 fid
= p9_client_walk(dfid
, 1, &name
, 1);
576 result
= PTR_ERR(fid
);
577 if (result
== -ENOENT
) {
582 return ERR_PTR(result
);
585 inode
= v9fs_inode_from_fid(v9ses
, fid
, dir
->i_sb
);
587 result
= PTR_ERR(inode
);
592 result
= v9fs_fid_add(dentry
, fid
);
596 if ((fid
->qid
.version
) && (v9ses
->cache
))
597 dentry
->d_op
= &v9fs_cached_dentry_operations
;
599 dentry
->d_op
= &v9fs_dentry_operations
;
601 d_add(dentry
, inode
);
606 p9_client_clunk(fid
);
608 return ERR_PTR(result
);
612 * v9fs_vfs_unlink - VFS unlink hook to delete an inode
613 * @i: inode that is being unlinked
614 * @d: dentry that is being unlinked
618 static int v9fs_vfs_unlink(struct inode
*i
, struct dentry
*d
)
620 return v9fs_remove(i
, d
, 0);
624 * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
625 * @i: inode that is being unlinked
626 * @d: dentry that is being unlinked
630 static int v9fs_vfs_rmdir(struct inode
*i
, struct dentry
*d
)
632 return v9fs_remove(i
, d
, 1);
636 * v9fs_vfs_rename - VFS hook to rename an inode
637 * @old_dir: old dir inode
638 * @old_dentry: old dentry
639 * @new_dir: new dir inode
640 * @new_dentry: new dentry
645 v9fs_vfs_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
646 struct inode
*new_dir
, struct dentry
*new_dentry
)
648 struct inode
*old_inode
;
649 struct v9fs_session_info
*v9ses
;
650 struct p9_fid
*oldfid
;
651 struct p9_fid
*olddirfid
;
652 struct p9_fid
*newdirfid
;
653 struct p9_wstat wstat
;
656 P9_DPRINTK(P9_DEBUG_VFS
, "\n");
658 old_inode
= old_dentry
->d_inode
;
659 v9ses
= v9fs_inode2v9ses(old_inode
);
660 oldfid
= v9fs_fid_lookup(old_dentry
);
662 return PTR_ERR(oldfid
);
664 olddirfid
= v9fs_fid_clone(old_dentry
->d_parent
);
665 if (IS_ERR(olddirfid
)) {
666 retval
= PTR_ERR(olddirfid
);
670 newdirfid
= v9fs_fid_clone(new_dentry
->d_parent
);
671 if (IS_ERR(newdirfid
)) {
672 retval
= PTR_ERR(newdirfid
);
676 /* 9P can only handle file rename in the same directory */
677 if (memcmp(&olddirfid
->qid
, &newdirfid
->qid
, sizeof(newdirfid
->qid
))) {
678 P9_DPRINTK(P9_DEBUG_ERROR
,
679 "old dir and new dir are different\n");
684 v9fs_blank_wstat(&wstat
);
685 wstat
.muid
= v9ses
->uname
;
686 wstat
.name
= (char *) new_dentry
->d_name
.name
;
687 retval
= p9_client_wstat(oldfid
, &wstat
);
690 p9_client_clunk(newdirfid
);
693 p9_client_clunk(olddirfid
);
700 * v9fs_vfs_getattr - retrieve file metadata
701 * @mnt - mount information
702 * @dentry - file to get attributes on
703 * @stat - metadata structure to populate
708 v9fs_vfs_getattr(struct vfsmount
*mnt
, struct dentry
*dentry
,
712 struct v9fs_session_info
*v9ses
;
716 P9_DPRINTK(P9_DEBUG_VFS
, "dentry: %p\n", dentry
);
718 v9ses
= v9fs_inode2v9ses(dentry
->d_inode
);
719 if (v9ses
->cache
== CACHE_LOOSE
)
720 return simple_getattr(mnt
, dentry
, stat
);
722 fid
= v9fs_fid_lookup(dentry
);
726 st
= p9_client_stat(fid
);
730 v9fs_stat2inode(st
, dentry
->d_inode
, dentry
->d_inode
->i_sb
);
731 generic_fillattr(dentry
->d_inode
, stat
);
738 * v9fs_vfs_setattr - set file metadata
739 * @dentry: file whose metadata to set
740 * @iattr: metadata assignment structure
744 static int v9fs_vfs_setattr(struct dentry
*dentry
, struct iattr
*iattr
)
747 struct v9fs_session_info
*v9ses
;
749 struct p9_wstat wstat
;
751 P9_DPRINTK(P9_DEBUG_VFS
, "\n");
753 v9ses
= v9fs_inode2v9ses(dentry
->d_inode
);
754 fid
= v9fs_fid_lookup(dentry
);
758 v9fs_blank_wstat(&wstat
);
759 if (iattr
->ia_valid
& ATTR_MODE
)
760 wstat
.mode
= unixmode2p9mode(v9ses
, iattr
->ia_mode
);
762 if (iattr
->ia_valid
& ATTR_MTIME
)
763 wstat
.mtime
= iattr
->ia_mtime
.tv_sec
;
765 if (iattr
->ia_valid
& ATTR_ATIME
)
766 wstat
.atime
= iattr
->ia_atime
.tv_sec
;
768 if (iattr
->ia_valid
& ATTR_SIZE
)
769 wstat
.length
= iattr
->ia_size
;
771 if (v9fs_extended(v9ses
)) {
772 if (iattr
->ia_valid
& ATTR_UID
)
773 wstat
.n_uid
= iattr
->ia_uid
;
775 if (iattr
->ia_valid
& ATTR_GID
)
776 wstat
.n_gid
= iattr
->ia_gid
;
779 retval
= p9_client_wstat(fid
, &wstat
);
781 retval
= inode_setattr(dentry
->d_inode
, iattr
);
787 * v9fs_stat2inode - populate an inode structure with mistat info
788 * @stat: Plan 9 metadata (mistat) structure
789 * @inode: inode to populate
790 * @sb: superblock of filesystem
795 v9fs_stat2inode(struct p9_stat
*stat
, struct inode
*inode
,
796 struct super_block
*sb
)
800 struct v9fs_session_info
*v9ses
= sb
->s_fs_info
;
804 inode
->i_atime
.tv_sec
= stat
->atime
;
805 inode
->i_mtime
.tv_sec
= stat
->mtime
;
806 inode
->i_ctime
.tv_sec
= stat
->mtime
;
808 inode
->i_uid
= v9ses
->dfltuid
;
809 inode
->i_gid
= v9ses
->dfltgid
;
811 if (v9fs_extended(v9ses
)) {
812 inode
->i_uid
= stat
->n_uid
;
813 inode
->i_gid
= stat
->n_gid
;
816 inode
->i_mode
= p9mode2unixmode(v9ses
, stat
->mode
);
817 if ((S_ISBLK(inode
->i_mode
)) || (S_ISCHR(inode
->i_mode
))) {
822 n
= stat
->extension
.len
;
823 if (n
> sizeof(ext
)-1)
825 memmove(ext
, stat
->extension
.str
, n
);
827 sscanf(ext
, "%c %u %u", &type
, &major
, &minor
);
830 inode
->i_mode
&= ~S_IFBLK
;
831 inode
->i_mode
|= S_IFCHR
;
836 P9_DPRINTK(P9_DEBUG_ERROR
,
837 "Unknown special type %c (%.*s)\n", type
,
838 stat
->extension
.len
, stat
->extension
.str
);
840 inode
->i_rdev
= MKDEV(major
, minor
);
844 inode
->i_size
= stat
->length
;
846 /* not real number of blocks, but 512 byte ones ... */
847 inode
->i_blocks
= (inode
->i_size
+ 512 - 1) >> 9;
851 * v9fs_qid2ino - convert qid into inode number
854 * BUG: potential for inode number collisions?
857 ino_t
v9fs_qid2ino(struct p9_qid
*qid
)
859 u64 path
= qid
->path
+ 2;
862 if (sizeof(ino_t
) == sizeof(path
))
863 memcpy(&i
, &path
, sizeof(ino_t
));
865 i
= (ino_t
) (path
^ (path
>> 32));
871 * v9fs_readlink - read a symlink's location (internal version)
872 * @dentry: dentry for symlink
873 * @buffer: buffer to load symlink location into
874 * @buflen: length of buffer
878 static int v9fs_readlink(struct dentry
*dentry
, char *buffer
, int buflen
)
882 struct v9fs_session_info
*v9ses
;
886 P9_DPRINTK(P9_DEBUG_VFS
, " %s\n", dentry
->d_name
.name
);
888 v9ses
= v9fs_inode2v9ses(dentry
->d_inode
);
889 fid
= v9fs_fid_lookup(dentry
);
893 if (!v9fs_extended(v9ses
))
896 st
= p9_client_stat(fid
);
900 if (!(st
->mode
& P9_DMSYMLINK
)) {
905 /* copy extension buffer into buffer */
906 if (st
->extension
.len
< buflen
)
907 buflen
= st
->extension
.len
+ 1;
909 memmove(buffer
, st
->extension
.str
, buflen
- 1);
910 buffer
[buflen
-1] = 0;
912 P9_DPRINTK(P9_DEBUG_VFS
,
913 "%s -> %.*s (%s)\n", dentry
->d_name
.name
, st
->extension
.len
,
914 st
->extension
.str
, buffer
);
924 * v9fs_vfs_readlink - read a symlink's location
925 * @dentry: dentry for symlink
926 * @buf: buffer to load symlink location into
927 * @buflen: length of buffer
931 static int v9fs_vfs_readlink(struct dentry
*dentry
, char __user
* buffer
,
936 char *link
= __getname();
941 if (buflen
> PATH_MAX
)
944 P9_DPRINTK(P9_DEBUG_VFS
, " dentry: %s (%p)\n", dentry
->d_iname
, dentry
);
946 retval
= v9fs_readlink(dentry
, link
, buflen
);
949 if ((ret
= copy_to_user(buffer
, link
, retval
)) != 0) {
950 P9_DPRINTK(P9_DEBUG_ERROR
,
951 "problem copying to user: %d\n", ret
);
961 * v9fs_vfs_follow_link - follow a symlink path
962 * @dentry: dentry for symlink
967 static void *v9fs_vfs_follow_link(struct dentry
*dentry
, struct nameidata
*nd
)
970 char *link
= __getname();
972 P9_DPRINTK(P9_DEBUG_VFS
, "%s n", dentry
->d_name
.name
);
975 link
= ERR_PTR(-ENOMEM
);
977 len
= v9fs_readlink(dentry
, link
, PATH_MAX
);
985 nd_set_link(nd
, link
);
991 * v9fs_vfs_put_link - release a symlink path
992 * @dentry: dentry for symlink
997 static void v9fs_vfs_put_link(struct dentry
*dentry
, struct nameidata
*nd
, void *p
)
999 char *s
= nd_get_link(nd
);
1001 P9_DPRINTK(P9_DEBUG_VFS
, " %s %s\n", dentry
->d_name
.name
, s
);
1006 static int v9fs_vfs_mkspecial(struct inode
*dir
, struct dentry
*dentry
,
1007 int mode
, const char *extension
)
1010 struct v9fs_session_info
*v9ses
;
1013 v9ses
= v9fs_inode2v9ses(dir
);
1014 if (!v9fs_extended(v9ses
)) {
1015 P9_DPRINTK(P9_DEBUG_ERROR
, "not extended\n");
1019 perm
= unixmode2p9mode(v9ses
, mode
);
1020 fid
= v9fs_create(v9ses
, dir
, dentry
, (char *) extension
, perm
,
1023 return PTR_ERR(fid
);
1025 p9_client_clunk(fid
);
1030 * v9fs_vfs_symlink - helper function to create symlinks
1031 * @dir: directory inode containing symlink
1032 * @dentry: dentry for symlink
1033 * @symname: symlink data
1035 * See 9P2000.u RFC for more information
1040 v9fs_vfs_symlink(struct inode
*dir
, struct dentry
*dentry
, const char *symname
)
1042 P9_DPRINTK(P9_DEBUG_VFS
, " %lu,%s,%s\n", dir
->i_ino
,
1043 dentry
->d_name
.name
, symname
);
1045 return v9fs_vfs_mkspecial(dir
, dentry
, S_IFLNK
, symname
);
1049 * v9fs_vfs_link - create a hardlink
1050 * @old_dentry: dentry for file to link to
1051 * @dir: inode destination for new link
1052 * @dentry: dentry for link
1056 /* XXX - lots of code dup'd from symlink and creates,
1057 * figure out a better reuse strategy
1061 v9fs_vfs_link(struct dentry
*old_dentry
, struct inode
*dir
,
1062 struct dentry
*dentry
)
1065 struct p9_fid
*oldfid
;
1068 P9_DPRINTK(P9_DEBUG_VFS
,
1069 " %lu,%s,%s\n", dir
->i_ino
, dentry
->d_name
.name
,
1070 old_dentry
->d_name
.name
);
1072 oldfid
= v9fs_fid_clone(old_dentry
);
1074 return PTR_ERR(oldfid
);
1077 if (unlikely(!name
)) {
1082 sprintf(name
, "%d\n", oldfid
->fid
);
1083 retval
= v9fs_vfs_mkspecial(dir
, dentry
, P9_DMLINK
, name
);
1087 p9_client_clunk(oldfid
);
1092 * v9fs_vfs_mknod - create a special file
1093 * @dir: inode destination for new link
1094 * @dentry: dentry for file
1095 * @mode: mode for creation
1096 * @dev_t: device associated with special file
1101 v9fs_vfs_mknod(struct inode
*dir
, struct dentry
*dentry
, int mode
, dev_t rdev
)
1106 P9_DPRINTK(P9_DEBUG_VFS
,
1107 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir
->i_ino
,
1108 dentry
->d_name
.name
, mode
, MAJOR(rdev
), MINOR(rdev
));
1110 if (!new_valid_dev(rdev
))
1116 /* build extension */
1118 sprintf(name
, "b %u %u", MAJOR(rdev
), MINOR(rdev
));
1119 else if (S_ISCHR(mode
))
1120 sprintf(name
, "c %u %u", MAJOR(rdev
), MINOR(rdev
));
1121 else if (S_ISFIFO(mode
))
1128 retval
= v9fs_vfs_mkspecial(dir
, dentry
, mode
, name
);
1134 static const struct inode_operations v9fs_dir_inode_operations_ext
= {
1135 .create
= v9fs_vfs_create
,
1136 .lookup
= v9fs_vfs_lookup
,
1137 .symlink
= v9fs_vfs_symlink
,
1138 .link
= v9fs_vfs_link
,
1139 .unlink
= v9fs_vfs_unlink
,
1140 .mkdir
= v9fs_vfs_mkdir
,
1141 .rmdir
= v9fs_vfs_rmdir
,
1142 .mknod
= v9fs_vfs_mknod
,
1143 .rename
= v9fs_vfs_rename
,
1144 .readlink
= v9fs_vfs_readlink
,
1145 .getattr
= v9fs_vfs_getattr
,
1146 .setattr
= v9fs_vfs_setattr
,
1149 static const struct inode_operations v9fs_dir_inode_operations
= {
1150 .create
= v9fs_vfs_create
,
1151 .lookup
= v9fs_vfs_lookup
,
1152 .unlink
= v9fs_vfs_unlink
,
1153 .mkdir
= v9fs_vfs_mkdir
,
1154 .rmdir
= v9fs_vfs_rmdir
,
1155 .mknod
= v9fs_vfs_mknod
,
1156 .rename
= v9fs_vfs_rename
,
1157 .getattr
= v9fs_vfs_getattr
,
1158 .setattr
= v9fs_vfs_setattr
,
1161 static const struct inode_operations v9fs_file_inode_operations
= {
1162 .getattr
= v9fs_vfs_getattr
,
1163 .setattr
= v9fs_vfs_setattr
,
1166 static const struct inode_operations v9fs_symlink_inode_operations
= {
1167 .readlink
= v9fs_vfs_readlink
,
1168 .follow_link
= v9fs_vfs_follow_link
,
1169 .put_link
= v9fs_vfs_put_link
,
1170 .getattr
= v9fs_vfs_getattr
,
1171 .setattr
= v9fs_vfs_setattr
,