14 #include <linux/module.h>
17 #include <linux/sched.h>
19 #define dprintk(fmt, args...) do{}while(0)
25 static int exportfs_get_name(
struct vfsmount *mnt,
struct dentry *dir,
32 return nop->
get_name(dir, name, child);
34 return get_name(&path, name, child);
45 struct dentry *dentry, *toput =
NULL;
49 if (acceptable(context, result))
56 spin_unlock(&inode->
i_lock);
59 if (dentry != result && acceptable(context, dentry)) {
66 spin_unlock(&inode->
i_lock);
76 static struct dentry *
77 find_disconnected_root(
struct dentry *dentry)
100 reconnect_path(
struct vfsmount *mnt,
struct dentry *target_dir,
char *nbuf)
114 struct dentry *
pd = find_disconnected_root(target_dir);
122 }
else if (pd == mnt->
mnt_sb->s_root) {
123 printk(
KERN_ERR "export: Eeek filesystem root is not connected, impossible\n");
144 struct dentry *ppd = ERR_PTR(-
EACCES);
148 if (mnt->
mnt_sb->s_export_op->get_parent)
149 ppd = mnt->
mnt_sb->s_export_op->get_parent(pd);
154 dprintk(
"%s: get_parent of %ld failed, err %d\n",
155 __func__, pd->
d_inode->i_ino, err);
160 dprintk(
"%s: find name of %lu in %lu\n", __func__,
162 err = exportfs_get_name(mnt, ppd, nbuf, pd);
173 dprintk(
"%s: found name: %s\n", __func__, nbuf);
179 dprintk(
"%s: lookup failed: %d\n",
193 printk(
"%s: npd != pd\n", __func__);
227 static int filldir_one(
void * __buf,
const char * name,
int len,
228 loff_t
pos,
u64 ino,
unsigned int d_type)
234 if (buf->
ino == ino) {
236 buf->
name[len] =
'\0';
252 static int get_name(
const struct path *path,
char *name,
struct dentry *child)
255 struct inode *dir = path->
dentry->d_inode;
270 error = PTR_ERR(file);
275 if (!file->
f_op->readdir)
283 int old_seq =
buffer.sequence;
295 if (old_seq ==
buffer.sequence)
317 static int export_encode_fh(
struct inode *inode,
struct fid *
fid,
318 int *max_len,
struct inode *parent)
323 if (parent && (len < 4)) {
326 }
else if (len < 2) {
335 fid->
i32.parent_ino = parent->
i_ino;
349 struct dentry *p =
NULL;
350 struct inode *inode = dentry->
d_inode, *parent =
NULL;
361 error = nop->
encode_fh(inode, fid->
raw, max_len, parent);
363 error = export_encode_fh(inode, fid, max_len, parent);
371 int fh_len,
int fileid_type,
372 int (*acceptable)(
void *,
struct dentry *),
void *context)
386 result = ERR_PTR(-
ESTALE);
400 err = reconnect_path(mnt, result, nbuf);
405 if (!acceptable(context, result)) {
415 struct dentry *target_dir, *nresult;
426 alias = find_acceptable_alias(result, acceptable, context);
439 fh_len, fileid_type);
442 err = PTR_ERR(target_dir);
443 if (IS_ERR(target_dir))
451 err = reconnect_path(mnt, target_dir, nbuf);
462 err = exportfs_get_name(mnt, target_dir, nbuf, result);
468 if (!IS_ERR(nresult)) {
487 alias = find_acceptable_alias(result, acceptable, context);