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 & S_ISVTX) == S_ISVTX)
82 if ((mode & P9_DMLINK))
90 * p9mode2unixmode- convert plan9 mode bits to unix mode bits
91 * @v9ses: v9fs session information
92 * @mode: mode to convert
96 static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
102 if ((mode & P9_DMDIR) == P9_DMDIR)
104 else if ((mode & P9_DMSYMLINK) && (v9fs_extended(v9ses)))
106 else if ((mode & P9_DMSOCKET) && (v9fs_extended(v9ses))
107 && (v9ses->nodev == 0))
109 else if ((mode & P9_DMNAMEDPIPE) && (v9fs_extended(v9ses))
110 && (v9ses->nodev == 0))
112 else if ((mode & P9_DMDEVICE) && (v9fs_extended(v9ses))
113 && (v9ses->nodev == 0))
118 if (v9fs_extended(v9ses)) {
119 if ((mode & P9_DMSETUID) == P9_DMSETUID)
122 if ((mode & P9_DMSETGID) == P9_DMSETGID)
125 if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
133 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
134 * @uflags: flags to convert
135 * @extended: if .u extensions are active
138 int v9fs_uflags2omode(int uflags, int extended)
158 if (uflags & O_TRUNC)
165 if (uflags & O_APPEND)
173 * v9fs_blank_wstat - helper function to setup a 9P stat structure
174 * @wstat: structure to initialize
179 v9fs_blank_wstat(struct p9_wstat *wstat)
183 wstat->qid.type = ~0;
184 wstat->qid.version = ~0;
185 *((long long *)&wstat->qid.path) = ~0;
197 wstat->extension = NULL;
201 * v9fs_get_inode - helper function to setup an inode
203 * @mode: mode to setup inode with
207 struct inode *v9fs_get_inode(struct super_block *sb, int mode)
211 struct v9fs_session_info *v9ses = sb->s_fs_info;
213 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
215 inode = new_inode(sb);
217 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
218 return ERR_PTR(-ENOMEM);
221 inode->i_mode = mode;
222 inode->i_uid = current_fsuid();
223 inode->i_gid = current_fsgid();
226 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
227 inode->i_mapping->a_ops = &v9fs_addr_operations;
229 switch (mode & S_IFMT) {
234 if (!v9fs_extended(v9ses)) {
235 P9_DPRINTK(P9_DEBUG_ERROR,
236 "special files without extended mode\n");
240 init_special_inode(inode, inode->i_mode, inode->i_rdev);
243 inode->i_op = &v9fs_file_inode_operations;
244 inode->i_fop = &v9fs_file_operations;
247 if (!v9fs_extended(v9ses)) {
248 P9_DPRINTK(P9_DEBUG_ERROR,
249 "extended modes used w/o 9P2000.u\n");
253 inode->i_op = &v9fs_symlink_inode_operations;
257 if (v9fs_extended(v9ses))
258 inode->i_op = &v9fs_dir_inode_operations_ext;
260 inode->i_op = &v9fs_dir_inode_operations;
261 inode->i_fop = &v9fs_dir_operations;
264 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
265 mode, mode & S_IFMT);
278 static struct v9fs_fid*
279 v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
283 struct v9fs_fid *ret;
284 struct v9fs_fcall *fcall;
286 nfid = v9fs_get_idpool(&v9ses->fidpool);
288 eprintk(KERN_WARNING, "no free fids available\n");
289 return ERR_PTR(-ENOSPC);
292 err = v9fs_t_walk(v9ses, fid, nfid, (char *) dentry->d_name.name,
296 if (fcall && fcall->id == RWALK)
299 PRINT_FCALL_ERROR("walk error", fcall);
300 v9fs_put_idpool(nfid, &v9ses->fidpool);
306 ret = v9fs_fid_create(v9ses, nfid);
312 err = v9fs_fid_insert(ret, dentry);
314 v9fs_fid_destroy(ret);
321 v9fs_t_clunk(v9ses, nfid);
330 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
331 * @v9ses: session information
332 * @fid: fid to issue attribute request for
333 * @sb: superblock on which to create inode
337 static struct inode *
338 v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
339 struct super_block *sb)
346 st = p9_client_stat(fid);
350 umode = p9mode2unixmode(v9ses, st->mode);
351 ret = v9fs_get_inode(sb, umode);
357 v9fs_stat2inode(st, ret, sb);
358 ret->i_ino = v9fs_qid2ino(&st->qid);
370 * v9fs_remove - helper function to remove files and directories
371 * @dir: directory inode that is being deleted
372 * @file: dentry that is being deleted
373 * @rmdir: removing a directory
377 static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
379 struct inode *file_inode;
380 struct v9fs_session_info *v9ses;
381 struct p9_fid *v9fid;
383 P9_DPRINTK(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
386 file_inode = file->d_inode;
387 v9ses = v9fs_inode2v9ses(file_inode);
388 v9fid = v9fs_fid_clone(file);
390 return PTR_ERR(v9fid);
392 return p9_client_remove(v9fid);
396 v9fs_open_created(struct inode *inode, struct file *file)
403 * v9fs_create - Create a file
404 * @v9ses: session information
405 * @dir: directory that dentry is being created in
406 * @dentry: dentry that is being created
407 * @extension: 9p2000.u extension string to support devices, etc.
408 * @perm: create permissions
412 static struct p9_fid *
413 v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
414 struct dentry *dentry, char *extension, u32 perm, u8 mode)
418 struct p9_fid *dfid, *ofid, *fid;
421 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
426 name = (char *) dentry->d_name.name;
427 dfid = v9fs_fid_clone(dentry->d_parent);
430 P9_DPRINTK(P9_DEBUG_VFS, "fid clone failed %d\n", err);
435 /* clone a fid to use for creation */
436 ofid = p9_client_walk(dfid, 0, NULL, 1);
439 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
444 err = p9_client_fcreate(ofid, name, perm, mode, extension);
446 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err);
450 /* now walk from the parent so we can get unopened fid */
451 fid = p9_client_walk(dfid, 1, &name, 0);
454 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
460 /* instantiate inode and assign the unopened fid to the dentry */
461 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
463 err = PTR_ERR(inode);
464 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
469 dentry->d_op = &v9fs_cached_dentry_operations;
471 dentry->d_op = &v9fs_dentry_operations;
473 d_instantiate(dentry, inode);
474 err = v9fs_fid_add(dentry, fid);
482 p9_client_clunk(dfid);
485 p9_client_clunk(ofid);
488 p9_client_clunk(fid);
494 * v9fs_vfs_create - VFS hook to create files
495 * @dir: directory inode that is being created
496 * @dentry: dentry that is being deleted
497 * @mode: create permissions
498 * @nd: path information
503 v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
504 struct nameidata *nd)
509 struct v9fs_session_info *v9ses;
515 v9ses = v9fs_inode2v9ses(dir);
516 perm = unixmode2p9mode(v9ses, mode);
517 if (nd && nd->flags & LOOKUP_OPEN)
518 flags = nd->intent.open.flags - 1;
522 fid = v9fs_create(v9ses, dir, dentry, NULL, perm,
523 v9fs_uflags2omode(flags, v9fs_extended(v9ses)));
530 /* if we are opening a file, assign the open fid to the file */
531 if (nd && nd->flags & LOOKUP_OPEN) {
532 filp = lookup_instantiate_filp(nd, dentry, v9fs_open_created);
538 filp->private_data = fid;
540 p9_client_clunk(fid);
546 p9_client_clunk(fid);
552 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
553 * @dir: inode that is being unlinked
554 * @dentry: dentry that is being unlinked
555 * @mode: mode for new directory
559 static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
563 struct v9fs_session_info *v9ses;
566 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
568 v9ses = v9fs_inode2v9ses(dir);
569 perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
570 fid = v9fs_create(v9ses, dir, dentry, NULL, perm, P9_OREAD);
577 p9_client_clunk(fid);
583 * v9fs_vfs_lookup - VFS lookup hook to "walk" to a new inode
584 * @dir: inode that is being walked from
585 * @dentry: dentry that is being walked to?
586 * @nameidata: path data
590 static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
591 struct nameidata *nameidata)
593 struct super_block *sb;
594 struct v9fs_session_info *v9ses;
595 struct p9_fid *dfid, *fid;
600 P9_DPRINTK(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
601 dir, dentry->d_name.name, dentry, nameidata);
604 v9ses = v9fs_inode2v9ses(dir);
605 dfid = v9fs_fid_lookup(dentry->d_parent);
607 return ERR_CAST(dfid);
609 name = (char *) dentry->d_name.name;
610 fid = p9_client_walk(dfid, 1, &name, 1);
612 result = PTR_ERR(fid);
613 if (result == -ENOENT) {
618 return ERR_PTR(result);
621 inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
623 result = PTR_ERR(inode);
628 result = v9fs_fid_add(dentry, fid);
632 if ((fid->qid.version) && (v9ses->cache))
633 dentry->d_op = &v9fs_cached_dentry_operations;
635 dentry->d_op = &v9fs_dentry_operations;
637 d_add(dentry, inode);
641 p9_client_clunk(fid);
643 return ERR_PTR(result);
647 * v9fs_vfs_unlink - VFS unlink hook to delete an inode
648 * @i: inode that is being unlinked
649 * @d: dentry that is being unlinked
653 static int v9fs_vfs_unlink(struct inode *i, struct dentry *d)
655 return v9fs_remove(i, d, 0);
659 * v9fs_vfs_rmdir - VFS unlink hook to delete a directory
660 * @i: inode that is being unlinked
661 * @d: dentry that is being unlinked
665 static int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
667 return v9fs_remove(i, d, 1);
671 * v9fs_vfs_rename - VFS hook to rename an inode
672 * @old_dir: old dir inode
673 * @old_dentry: old dentry
674 * @new_dir: new dir inode
675 * @new_dentry: new dentry
680 v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
681 struct inode *new_dir, struct dentry *new_dentry)
683 struct inode *old_inode;
684 struct v9fs_session_info *v9ses;
685 struct p9_fid *oldfid;
686 struct p9_fid *olddirfid;
687 struct p9_fid *newdirfid;
688 struct p9_wstat wstat;
691 P9_DPRINTK(P9_DEBUG_VFS, "\n");
693 old_inode = old_dentry->d_inode;
694 v9ses = v9fs_inode2v9ses(old_inode);
695 oldfid = v9fs_fid_lookup(old_dentry);
697 return PTR_ERR(oldfid);
699 olddirfid = v9fs_fid_clone(old_dentry->d_parent);
700 if (IS_ERR(olddirfid)) {
701 retval = PTR_ERR(olddirfid);
705 newdirfid = v9fs_fid_clone(new_dentry->d_parent);
706 if (IS_ERR(newdirfid)) {
707 retval = PTR_ERR(newdirfid);
711 /* 9P can only handle file rename in the same directory */
712 if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) {
713 P9_DPRINTK(P9_DEBUG_ERROR,
714 "old dir and new dir are different\n");
719 v9fs_blank_wstat(&wstat);
720 wstat.muid = v9ses->uname;
721 wstat.name = (char *) new_dentry->d_name.name;
722 retval = p9_client_wstat(oldfid, &wstat);
725 p9_client_clunk(newdirfid);
728 p9_client_clunk(olddirfid);
735 * v9fs_vfs_getattr - retrieve file metadata
736 * @mnt: mount information
737 * @dentry: file to get attributes on
738 * @stat: metadata structure to populate
743 v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
747 struct v9fs_session_info *v9ses;
751 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
753 v9ses = v9fs_inode2v9ses(dentry->d_inode);
754 if (v9ses->cache == CACHE_LOOSE)
755 return simple_getattr(mnt, dentry, stat);
757 fid = v9fs_fid_lookup(dentry);
761 st = p9_client_stat(fid);
765 v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
766 generic_fillattr(dentry->d_inode, stat);
773 * v9fs_vfs_setattr - set file metadata
774 * @dentry: file whose metadata to set
775 * @iattr: metadata assignment structure
779 static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
782 struct v9fs_session_info *v9ses;
784 struct p9_wstat wstat;
786 P9_DPRINTK(P9_DEBUG_VFS, "\n");
788 v9ses = v9fs_inode2v9ses(dentry->d_inode);
789 fid = v9fs_fid_lookup(dentry);
793 v9fs_blank_wstat(&wstat);
794 if (iattr->ia_valid & ATTR_MODE)
795 wstat.mode = unixmode2p9mode(v9ses, iattr->ia_mode);
797 if (iattr->ia_valid & ATTR_MTIME)
798 wstat.mtime = iattr->ia_mtime.tv_sec;
800 if (iattr->ia_valid & ATTR_ATIME)
801 wstat.atime = iattr->ia_atime.tv_sec;
803 if (iattr->ia_valid & ATTR_SIZE)
804 wstat.length = iattr->ia_size;
806 if (v9fs_extended(v9ses)) {
807 if (iattr->ia_valid & ATTR_UID)
808 wstat.n_uid = iattr->ia_uid;
810 if (iattr->ia_valid & ATTR_GID)
811 wstat.n_gid = iattr->ia_gid;
814 retval = p9_client_wstat(fid, &wstat);
816 retval = inode_setattr(dentry->d_inode, iattr);
822 * v9fs_stat2inode - populate an inode structure with mistat info
823 * @stat: Plan 9 metadata (mistat) structure
824 * @inode: inode to populate
825 * @sb: superblock of filesystem
830 v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
831 struct super_block *sb)
834 struct v9fs_session_info *v9ses = sb->s_fs_info;
838 inode->i_atime.tv_sec = stat->atime;
839 inode->i_mtime.tv_sec = stat->mtime;
840 inode->i_ctime.tv_sec = stat->mtime;
842 inode->i_uid = v9ses->dfltuid;
843 inode->i_gid = v9ses->dfltgid;
845 if (v9fs_extended(v9ses)) {
846 inode->i_uid = stat->n_uid;
847 inode->i_gid = stat->n_gid;
850 inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
851 if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
856 strncpy(ext, stat->extension, sizeof(ext));
857 sscanf(ext, "%c %u %u", &type, &major, &minor);
860 inode->i_mode &= ~S_IFBLK;
861 inode->i_mode |= S_IFCHR;
866 P9_DPRINTK(P9_DEBUG_ERROR,
867 "Unknown special type %c %s\n", type,
870 inode->i_rdev = MKDEV(major, minor);
871 init_special_inode(inode, inode->i_mode, inode->i_rdev);
875 inode->i_size = stat->length;
877 /* not real number of blocks, but 512 byte ones ... */
878 inode->i_blocks = (inode->i_size + 512 - 1) >> 9;
882 * v9fs_qid2ino - convert qid into inode number
885 * BUG: potential for inode number collisions?
888 ino_t v9fs_qid2ino(struct p9_qid *qid)
890 u64 path = qid->path + 2;
893 if (sizeof(ino_t) == sizeof(path))
894 memcpy(&i, &path, sizeof(ino_t));
896 i = (ino_t) (path ^ (path >> 32));
902 * v9fs_readlink - read a symlink's location (internal version)
903 * @dentry: dentry for symlink
904 * @buffer: buffer to load symlink location into
905 * @buflen: length of buffer
909 static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
913 struct v9fs_session_info *v9ses;
917 P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
919 v9ses = v9fs_inode2v9ses(dentry->d_inode);
920 fid = v9fs_fid_lookup(dentry);
924 if (!v9fs_extended(v9ses))
927 st = p9_client_stat(fid);
931 if (!(st->mode & P9_DMSYMLINK)) {
936 /* copy extension buffer into buffer */
937 strncpy(buffer, st->extension, buflen);
939 P9_DPRINTK(P9_DEBUG_VFS,
940 "%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);
950 * v9fs_vfs_readlink - read a symlink's location
951 * @dentry: dentry for symlink
952 * @buffer: buffer to load symlink location into
953 * @buflen: length of buffer
957 static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer,
962 char *link = __getname();
967 if (buflen > PATH_MAX)
970 P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
973 retval = v9fs_readlink(dentry, link, buflen);
976 if ((ret = copy_to_user(buffer, link, retval)) != 0) {
977 P9_DPRINTK(P9_DEBUG_ERROR,
978 "problem copying to user: %d\n", ret);
988 * v9fs_vfs_follow_link - follow a symlink path
989 * @dentry: dentry for symlink
994 static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
997 char *link = __getname();
999 P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
1002 link = ERR_PTR(-ENOMEM);
1004 len = v9fs_readlink(dentry, link, PATH_MAX);
1008 link = ERR_PTR(len);
1012 nd_set_link(nd, link);
1018 * v9fs_vfs_put_link - release a symlink path
1019 * @dentry: dentry for symlink
1026 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1028 char *s = nd_get_link(nd);
1030 P9_DPRINTK(P9_DEBUG_VFS, " %s %s\n", dentry->d_name.name,
1031 IS_ERR(s) ? "<error>" : s);
1037 * v9fs_vfs_mkspecial - create a special file
1038 * @dir: inode to create special file in
1039 * @dentry: dentry to create
1040 * @mode: mode to create special file
1041 * @extension: 9p2000.u format extension string representing special file
1045 static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1046 int mode, const char *extension)
1049 struct v9fs_session_info *v9ses;
1052 v9ses = v9fs_inode2v9ses(dir);
1053 if (!v9fs_extended(v9ses)) {
1054 P9_DPRINTK(P9_DEBUG_ERROR, "not extended\n");
1058 perm = unixmode2p9mode(v9ses, mode);
1059 fid = v9fs_create(v9ses, dir, dentry, (char *) extension, perm,
1062 return PTR_ERR(fid);
1064 p9_client_clunk(fid);
1069 * v9fs_vfs_symlink - helper function to create symlinks
1070 * @dir: directory inode containing symlink
1071 * @dentry: dentry for symlink
1072 * @symname: symlink data
1074 * See Also: 9P2000.u RFC for more information
1079 v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1081 P9_DPRINTK(P9_DEBUG_VFS, " %lu,%s,%s\n", dir->i_ino,
1082 dentry->d_name.name, symname);
1084 return v9fs_vfs_mkspecial(dir, dentry, S_IFLNK, symname);
1088 * v9fs_vfs_link - create a hardlink
1089 * @old_dentry: dentry for file to link to
1090 * @dir: inode destination for new link
1091 * @dentry: dentry for link
1096 v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1097 struct dentry *dentry)
1100 struct p9_fid *oldfid;
1103 P9_DPRINTK(P9_DEBUG_VFS,
1104 " %lu,%s,%s\n", dir->i_ino, dentry->d_name.name,
1105 old_dentry->d_name.name);
1107 oldfid = v9fs_fid_clone(old_dentry);
1109 return PTR_ERR(oldfid);
1112 if (unlikely(!name)) {
1117 sprintf(name, "%d\n", oldfid->fid);
1118 retval = v9fs_vfs_mkspecial(dir, dentry, P9_DMLINK, name);
1122 p9_client_clunk(oldfid);
1127 * v9fs_vfs_mknod - create a special file
1128 * @dir: inode destination for new link
1129 * @dentry: dentry for file
1130 * @mode: mode for creation
1131 * @rdev: device associated with special file
1136 v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1141 P9_DPRINTK(P9_DEBUG_VFS,
1142 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
1143 dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
1145 if (!new_valid_dev(rdev))
1151 /* build extension */
1153 sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
1154 else if (S_ISCHR(mode))
1155 sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
1156 else if (S_ISFIFO(mode))
1163 retval = v9fs_vfs_mkspecial(dir, dentry, mode, name);
1169 static const struct inode_operations v9fs_dir_inode_operations_ext = {
1170 .create = v9fs_vfs_create,
1171 .lookup = v9fs_vfs_lookup,
1172 .symlink = v9fs_vfs_symlink,
1173 .link = v9fs_vfs_link,
1174 .unlink = v9fs_vfs_unlink,
1175 .mkdir = v9fs_vfs_mkdir,
1176 .rmdir = v9fs_vfs_rmdir,
1177 .mknod = v9fs_vfs_mknod,
1178 .rename = v9fs_vfs_rename,
1179 .readlink = v9fs_vfs_readlink,
1180 .getattr = v9fs_vfs_getattr,
1181 .setattr = v9fs_vfs_setattr,
1184 static const struct inode_operations v9fs_dir_inode_operations = {
1185 .create = v9fs_vfs_create,
1186 .lookup = v9fs_vfs_lookup,
1187 .unlink = v9fs_vfs_unlink,
1188 .mkdir = v9fs_vfs_mkdir,
1189 .rmdir = v9fs_vfs_rmdir,
1190 .mknod = v9fs_vfs_mknod,
1191 .rename = v9fs_vfs_rename,
1192 .getattr = v9fs_vfs_getattr,
1193 .setattr = v9fs_vfs_setattr,
1196 static const struct inode_operations v9fs_file_inode_operations = {
1197 .getattr = v9fs_vfs_getattr,
1198 .setattr = v9fs_vfs_setattr,
1201 static const struct inode_operations v9fs_symlink_inode_operations = {
1202 .readlink = v9fs_vfs_readlink,
1203 .follow_link = v9fs_vfs_follow_link,
1204 .put_link = v9fs_vfs_put_link,
1205 .getattr = v9fs_vfs_getattr,
1206 .setattr = v9fs_vfs_setattr,