1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * Copyright (C) 2002 Cluster File Systems, Inc.
8 * This code is issued under the GNU General Public License.
9 * See the file COPYING in this distribution
11 * by Peter Braam <braam@clusterfs.com>
12 * and Andreas Dilger <adilger@clusterfs.com>
17 #include <linux/version.h>
19 #include <asm/unistd.h>
21 #define DEBUG_SUBSYSTEM S_FILTER
23 #include <linux/lustre_mds.h>
24 #include <linux/lustre_lib.h>
25 #include <linux/lustre_net.h>
28 /* push / pop to root of obd store */
29 void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new)
32 save->pwd = dget(current->fs->pwd);
33 save->pwdmnt = mntget(current->fs->pwdmnt);
36 set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
39 void pop_ctxt(struct obd_run_ctxt *saved)
42 set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
45 mntput(saved->pwdmnt);
48 /* utility to make a directory */
49 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode)
51 struct dentry *dchild;
55 CDEBUG(D_INODE, "creating directory %*s\n", strlen(name), name);
56 dchild = lookup_one_len(name, dir, strlen(name));
60 if (dchild->d_inode) {
61 if (!S_ISDIR(dchild->d_inode->i_mode))
62 GOTO(out, err = -ENOTDIR);
67 err = vfs_mkdir(dir->d_inode, dchild, mode);
78 int lustre_fread(struct file *file, char *str, int len, loff_t *off)
80 if (!file || !file->f_op || !file->f_op->read || !off)
83 return file->f_op->read(file, str, len, off);
86 int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off)
88 if (!file || !file->f_op || !off)
91 if (!file->f_op->write)
94 return file->f_op->write(file, str, len, off);
97 int lustre_fsync(struct file *file)
99 if (!file || !file->f_op || !file->f_op->fsync)
102 return file->f_op->fsync(file, file->f_dentry, 0);