4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * by Peter Braam <braam@clusterfs.com>
10 * and Andreas Dilger <adilger@clusterfs.com>
15 #include <linux/version.h>
17 #include <asm/unistd.h>
19 #define DEBUG_SUBSYSTEM S_FILTER
21 #include <linux/lustre_mds.h>
22 #include <linux/lustre_lib.h>
23 #include <linux/lustre_net.h>
26 /* push / pop to root of obd store */
27 void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new)
30 save->pwd = dget(current->fs->pwd);
31 save->pwdmnt = mntget(current->fs->pwdmnt);
34 set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
37 void pop_ctxt(struct obd_run_ctxt *saved)
40 set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
43 mntput(saved->pwdmnt);
46 /* utility to make a directory */
47 int simple_mkdir(struct dentry *dir, char *name, int mode)
49 struct dentry *dchild;
53 dchild = lookup_one_len(name, dir, strlen(name));
55 RETURN(PTR_ERR(dchild));
57 if (dchild->d_inode) {
58 if (!S_ISDIR(dchild->d_inode->i_mode))
59 GOTO(out, err = -ENOTDIR);
61 GOTO(out, err = -EEXIST);
64 err = vfs_mkdir(dir->d_inode, dchild, mode);
71 int lustre_fread(struct file *file, char *str, int len, loff_t *off)
73 if (!file || !file->f_op || !file->f_op->read || !off)
76 return file->f_op->read(file, str, len, off);
79 int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off)
81 if (!file || !file->f_op || !off)
84 if (!file->f_op->write)
87 return file->f_op->write(file, str, len, off);
90 int lustre_fsync(struct file *file)
92 if (!file || !file->f_op || !file->f_op->fsync)
95 return file->f_op->fsync(file, file->f_dentry, 0);