Whamcloud - gitweb
Move simple_mkdir() out of filterobd so that MDS can use it also.
[fs/lustre-release.git] / lustre / lib / simple.c
1 /*
2  *  lib/simple.c
3  *
4  * Copyright (C) 2002  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  *
9  * by Peter Braam <braam@clusterfs.com>
10  * and Andreas Dilger <adilger@clusterfs.com>
11  */
12
13 #define EXPORT_SYMTAB
14
15 #include <linux/version.h>
16 #include <linux/fs.h>
17 #include <asm/unistd.h>
18
19 #define DEBUG_SUBSYSTEM S_FILTER
20
21 #include <linux/lustre_mds.h>
22 #include <linux/lustre_lib.h>
23 #include <linux/lustre_net.h>
24
25 /* utility to make a directory */
26 int simple_mkdir(struct dentry *dir, char *name, int mode)
27 {
28         struct dentry *dchild;
29         int err;
30         ENTRY;
31
32         dchild = lookup_one_len(name, dir, strlen(name));
33         if (IS_ERR(dchild))
34                 RETURN(PTR_ERR(dchild));
35
36         if (dchild->d_inode)
37                 GOTO(out, err = -EEXIST);
38
39         err = vfs_mkdir(dir->d_inode, dchild, mode);
40 out:
41         l_dput(dchild);
42
43         RETURN(err);
44 }