2005-04-17 05:20:36 +07:00
|
|
|
|
2007-07-17 18:04:28 +07:00
|
|
|
#include <linux/exportfs.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/module.h>
|
2007-07-17 18:04:30 +07:00
|
|
|
#include <linux/mount.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/namei.h>
|
|
|
|
|
2007-07-17 18:04:31 +07:00
|
|
|
#define dprintk(fmt, args...) do{}while(0)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
|
2007-07-17 18:04:31 +07:00
|
|
|
static int get_name(struct dentry *dentry, char *name,
|
|
|
|
struct dentry *child);
|
|
|
|
|
|
|
|
|
|
|
|
static struct dentry *exportfs_get_dentry(struct super_block *sb, void *obj)
|
|
|
|
{
|
|
|
|
struct dentry *result = ERR_PTR(-ESTALE);
|
|
|
|
|
|
|
|
if (sb->s_export_op->get_dentry) {
|
|
|
|
result = sb->s_export_op->get_dentry(sb, obj);
|
|
|
|
if (!result)
|
|
|
|
result = ERR_PTR(-ESTALE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exportfs_get_name(struct dentry *dir, char *name,
|
|
|
|
struct dentry *child)
|
|
|
|
{
|
|
|
|
struct export_operations *nop = dir->d_sb->s_export_op;
|
|
|
|
|
|
|
|
if (nop->get_name)
|
|
|
|
return nop->get_name(dir, name, child);
|
|
|
|
else
|
|
|
|
return get_name(dir, name, child);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-19 08:43:52 +07:00
|
|
|
static struct dentry *
|
|
|
|
find_acceptable_alias(struct dentry *result,
|
|
|
|
int (*acceptable)(void *context, struct dentry *dentry),
|
|
|
|
void *context)
|
|
|
|
{
|
|
|
|
struct dentry *dentry, *toput = NULL;
|
|
|
|
|
|
|
|
spin_lock(&dcache_lock);
|
|
|
|
list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) {
|
|
|
|
dget_locked(dentry);
|
|
|
|
spin_unlock(&dcache_lock);
|
|
|
|
if (toput)
|
|
|
|
dput(toput);
|
|
|
|
if (dentry != result && acceptable(context, dentry)) {
|
|
|
|
dput(result);
|
|
|
|
return dentry;
|
|
|
|
}
|
|
|
|
spin_lock(&dcache_lock);
|
|
|
|
toput = dentry;
|
|
|
|
}
|
|
|
|
spin_unlock(&dcache_lock);
|
|
|
|
|
|
|
|
if (toput)
|
|
|
|
dput(toput);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/**
|
|
|
|
* find_exported_dentry - helper routine to implement export_operations->decode_fh
|
|
|
|
* @sb: The &super_block identifying the filesystem
|
|
|
|
* @obj: An opaque identifier of the object to be found - passed to
|
|
|
|
* get_inode
|
|
|
|
* @parent: An optional opqaue identifier of the parent of the object.
|
|
|
|
* @acceptable: A function used to test possible &dentries to see if they are
|
|
|
|
* acceptable
|
|
|
|
* @context: A parameter to @acceptable so that it knows on what basis to
|
|
|
|
* judge.
|
|
|
|
*
|
|
|
|
* find_exported_dentry is the central helper routine to enable file systems
|
|
|
|
* to provide the decode_fh() export_operation. It's main task is to take
|
|
|
|
* an &inode, find or create an appropriate &dentry structure, and possibly
|
|
|
|
* splice this into the dcache in the correct place.
|
|
|
|
*
|
|
|
|
* The decode_fh() operation provided by the filesystem should call
|
|
|
|
* find_exported_dentry() with the same parameters that it received except
|
|
|
|
* that instead of the file handle fragment, pointers to opaque identifiers
|
|
|
|
* for the object and optionally its parent are passed. The default decode_fh
|
|
|
|
* routine passes one pointer to the start of the filehandle fragment, and
|
|
|
|
* one 8 bytes into the fragment. It is expected that most filesystems will
|
|
|
|
* take this approach, though the offset to the parent identifier may well be
|
|
|
|
* different.
|
|
|
|
*
|
|
|
|
* find_exported_dentry() will call get_dentry to get an dentry pointer from
|
|
|
|
* the file system. If any &dentry in the d_alias list is acceptable, it will
|
|
|
|
* be returned. Otherwise find_exported_dentry() will attempt to splice a new
|
|
|
|
* &dentry into the dcache using get_name() and get_parent() to find the
|
|
|
|
* appropriate place.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct dentry *
|
|
|
|
find_exported_dentry(struct super_block *sb, void *obj, void *parent,
|
|
|
|
int (*acceptable)(void *context, struct dentry *de),
|
|
|
|
void *context)
|
|
|
|
{
|
|
|
|
struct dentry *result = NULL;
|
|
|
|
struct dentry *target_dir;
|
2007-07-17 18:04:31 +07:00
|
|
|
int err = -ESTALE;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct export_operations *nops = sb->s_export_op;
|
2006-01-19 08:43:52 +07:00
|
|
|
struct dentry *alias;
|
2005-04-17 05:20:36 +07:00
|
|
|
int noprogress;
|
|
|
|
char nbuf[NAME_MAX+1];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to find the inode.
|
|
|
|
*/
|
2007-07-17 18:04:31 +07:00
|
|
|
result = exportfs_get_dentry(sb, obj);
|
|
|
|
if (IS_ERR(result))
|
|
|
|
return result;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (S_ISDIR(result->d_inode->i_mode) &&
|
|
|
|
(result->d_flags & DCACHE_DISCONNECTED)) {
|
|
|
|
/* it is an unconnected directory, we must connect it */
|
|
|
|
;
|
|
|
|
} else {
|
|
|
|
if (acceptable(context, result))
|
|
|
|
return result;
|
|
|
|
if (S_ISDIR(result->d_inode->i_mode)) {
|
2006-05-21 04:59:56 +07:00
|
|
|
err = -EACCES;
|
2005-04-17 05:20:36 +07:00
|
|
|
goto err_result;
|
|
|
|
}
|
2006-01-19 08:43:52 +07:00
|
|
|
|
|
|
|
alias = find_acceptable_alias(result, acceptable, context);
|
|
|
|
if (alias)
|
|
|
|
return alias;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* It's a directory, or we are required to confirm the file's
|
|
|
|
* location in the tree based on the parent information
|
|
|
|
*/
|
|
|
|
dprintk("find_exported_dentry: need to look harder for %s/%d\n",sb->s_id,*(int*)obj);
|
|
|
|
if (S_ISDIR(result->d_inode->i_mode))
|
|
|
|
target_dir = dget(result);
|
|
|
|
else {
|
|
|
|
if (parent == NULL)
|
|
|
|
goto err_result;
|
|
|
|
|
2007-07-17 18:04:31 +07:00
|
|
|
target_dir = exportfs_get_dentry(sb,parent);
|
|
|
|
if (IS_ERR(target_dir)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
err = PTR_ERR(target_dir);
|
|
|
|
goto err_result;
|
2007-07-17 18:04:31 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Now we need to make sure that target_dir is properly connected.
|
|
|
|
* It may already be, as the flag isn't always updated when connection
|
|
|
|
* happens.
|
|
|
|
* So, we walk up parent links until we find a connected directory,
|
|
|
|
* or we run out of directories. Then we find the parent, find
|
|
|
|
* the name of the child in that parent, and do a lookup.
|
|
|
|
* This should connect the child into the parent
|
|
|
|
* We then repeat.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* it is possible that a confused file system might not let us complete
|
|
|
|
* the path to the root. For example, if get_parent returns a directory
|
|
|
|
* in which we cannot find a name for the child. While this implies a
|
|
|
|
* very sick filesystem we don't want it to cause knfsd to spin. Hence
|
|
|
|
* the noprogress counter. If we go through the loop 10 times (2 is
|
|
|
|
* probably enough) without getting anywhere, we just give up
|
|
|
|
*/
|
|
|
|
noprogress= 0;
|
|
|
|
while (target_dir->d_flags & DCACHE_DISCONNECTED && noprogress++ < 10) {
|
|
|
|
struct dentry *pd = target_dir;
|
|
|
|
|
|
|
|
dget(pd);
|
|
|
|
spin_lock(&pd->d_lock);
|
|
|
|
while (!IS_ROOT(pd) &&
|
|
|
|
(pd->d_parent->d_flags&DCACHE_DISCONNECTED)) {
|
|
|
|
struct dentry *parent = pd->d_parent;
|
|
|
|
|
|
|
|
dget(parent);
|
|
|
|
spin_unlock(&pd->d_lock);
|
|
|
|
dput(pd);
|
|
|
|
pd = parent;
|
|
|
|
spin_lock(&pd->d_lock);
|
|
|
|
}
|
|
|
|
spin_unlock(&pd->d_lock);
|
|
|
|
|
|
|
|
if (!IS_ROOT(pd)) {
|
|
|
|
/* must have found a connected parent - great */
|
|
|
|
spin_lock(&pd->d_lock);
|
|
|
|
pd->d_flags &= ~DCACHE_DISCONNECTED;
|
|
|
|
spin_unlock(&pd->d_lock);
|
|
|
|
noprogress = 0;
|
|
|
|
} else if (pd == sb->s_root) {
|
|
|
|
printk(KERN_ERR "export: Eeek filesystem root is not connected, impossible\n");
|
|
|
|
spin_lock(&pd->d_lock);
|
|
|
|
pd->d_flags &= ~DCACHE_DISCONNECTED;
|
|
|
|
spin_unlock(&pd->d_lock);
|
|
|
|
noprogress = 0;
|
|
|
|
} else {
|
2007-07-17 18:04:31 +07:00
|
|
|
/*
|
|
|
|
* We have hit the top of a disconnected path, try to
|
|
|
|
* find parent and connect.
|
|
|
|
*
|
|
|
|
* Racing with some other process renaming a directory
|
|
|
|
* isn't much of a problem here. If someone renames
|
|
|
|
* the directory, it will end up properly connected,
|
|
|
|
* which is what we want
|
|
|
|
*
|
|
|
|
* Getting the parent can't be supported generically,
|
|
|
|
* the locking is too icky.
|
|
|
|
*
|
|
|
|
* Instead we just return EACCES. If server reboots
|
|
|
|
* or inodes get flushed, you lose
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2007-07-17 18:04:31 +07:00
|
|
|
struct dentry *ppd = ERR_PTR(-EACCES);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct dentry *npd;
|
|
|
|
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_lock(&pd->d_inode->i_mutex);
|
2007-07-17 18:04:31 +07:00
|
|
|
if (nops->get_parent)
|
|
|
|
ppd = nops->get_parent(pd);
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_unlock(&pd->d_inode->i_mutex);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (IS_ERR(ppd)) {
|
|
|
|
err = PTR_ERR(ppd);
|
|
|
|
dprintk("find_exported_dentry: get_parent of %ld failed, err %d\n",
|
|
|
|
pd->d_inode->i_ino, err);
|
|
|
|
dput(pd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dprintk("find_exported_dentry: find name of %lu in %lu\n", pd->d_inode->i_ino, ppd->d_inode->i_ino);
|
2007-07-17 18:04:31 +07:00
|
|
|
err = exportfs_get_name(ppd, nbuf, pd);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (err) {
|
|
|
|
dput(ppd);
|
|
|
|
dput(pd);
|
|
|
|
if (err == -ENOENT)
|
|
|
|
/* some race between get_parent and
|
|
|
|
* get_name? just try again
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dprintk("find_exported_dentry: found name: %s\n", nbuf);
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_lock(&ppd->d_inode->i_mutex);
|
2005-04-17 05:20:36 +07:00
|
|
|
npd = lookup_one_len(nbuf, ppd, strlen(nbuf));
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_unlock(&ppd->d_inode->i_mutex);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (IS_ERR(npd)) {
|
|
|
|
err = PTR_ERR(npd);
|
|
|
|
dprintk("find_exported_dentry: lookup failed: %d\n", err);
|
|
|
|
dput(ppd);
|
|
|
|
dput(pd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* we didn't really want npd, we really wanted
|
|
|
|
* a side-effect of the lookup.
|
|
|
|
* hopefully, npd == pd, though it isn't really
|
|
|
|
* a problem if it isn't
|
|
|
|
*/
|
|
|
|
if (npd == pd)
|
|
|
|
noprogress = 0;
|
|
|
|
else
|
|
|
|
printk("find_exported_dentry: npd != pd\n");
|
|
|
|
dput(npd);
|
|
|
|
dput(ppd);
|
|
|
|
if (IS_ROOT(pd)) {
|
|
|
|
/* something went wrong, we have to give up */
|
|
|
|
dput(pd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dput(pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target_dir->d_flags & DCACHE_DISCONNECTED) {
|
|
|
|
/* something went wrong - oh-well */
|
|
|
|
if (!err)
|
|
|
|
err = -ESTALE;
|
|
|
|
goto err_target;
|
|
|
|
}
|
|
|
|
/* if we weren't after a directory, have one more step to go */
|
|
|
|
if (result != target_dir) {
|
|
|
|
struct dentry *nresult;
|
2007-07-17 18:04:31 +07:00
|
|
|
err = exportfs_get_name(target_dir, nbuf, result);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!err) {
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_lock(&target_dir->d_inode->i_mutex);
|
2005-04-17 05:20:36 +07:00
|
|
|
nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf));
|
2006-01-10 06:59:24 +07:00
|
|
|
mutex_unlock(&target_dir->d_inode->i_mutex);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!IS_ERR(nresult)) {
|
|
|
|
if (nresult->d_inode) {
|
|
|
|
dput(result);
|
|
|
|
result = nresult;
|
|
|
|
} else
|
|
|
|
dput(nresult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dput(target_dir);
|
|
|
|
/* now result is properly connected, it is our best bet */
|
|
|
|
if (acceptable(context, result))
|
|
|
|
return result;
|
2006-01-19 08:43:52 +07:00
|
|
|
|
|
|
|
alias = find_acceptable_alias(result, acceptable, context);
|
|
|
|
if (alias)
|
|
|
|
return alias;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* drat - I just cannot find anything acceptable */
|
|
|
|
dput(result);
|
|
|
|
/* It might be justifiable to return ESTALE here,
|
|
|
|
* but the filehandle at-least looks reasonable good
|
|
|
|
* and it just be a permission problem, so returning
|
|
|
|
* -EACCESS is safer
|
|
|
|
*/
|
|
|
|
return ERR_PTR(-EACCES);
|
|
|
|
|
|
|
|
err_target:
|
|
|
|
dput(target_dir);
|
|
|
|
err_result:
|
|
|
|
dput(result);
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct getdents_callback {
|
|
|
|
char *name; /* name that was found. It already points to a
|
|
|
|
buffer NAME_MAX+1 is size */
|
|
|
|
unsigned long ino; /* the inum we are looking for */
|
|
|
|
int found; /* inode matched? */
|
|
|
|
int sequence; /* sequence counter */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A rather strange filldir function to capture
|
|
|
|
* the name matching the specified inode number.
|
|
|
|
*/
|
|
|
|
static int filldir_one(void * __buf, const char * name, int len,
|
2006-10-03 15:13:46 +07:00
|
|
|
loff_t pos, u64 ino, unsigned int d_type)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct getdents_callback *buf = __buf;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
buf->sequence++;
|
|
|
|
if (buf->ino == ino) {
|
|
|
|
memcpy(buf->name, name, len);
|
|
|
|
buf->name[len] = '\0';
|
|
|
|
buf->found = 1;
|
|
|
|
result = -1;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get_name - default export_operations->get_name function
|
|
|
|
* @dentry: the directory in which to find a name
|
|
|
|
* @name: a pointer to a %NAME_MAX+1 char buffer to store the name
|
|
|
|
* @child: the dentry for the child directory.
|
|
|
|
*
|
|
|
|
* calls readdir on the parent until it finds an entry with
|
|
|
|
* the same inode number as the child, and returns that.
|
|
|
|
*/
|
|
|
|
static int get_name(struct dentry *dentry, char *name,
|
|
|
|
struct dentry *child)
|
|
|
|
{
|
|
|
|
struct inode *dir = dentry->d_inode;
|
|
|
|
int error;
|
|
|
|
struct file *file;
|
|
|
|
struct getdents_callback buffer;
|
|
|
|
|
|
|
|
error = -ENOTDIR;
|
|
|
|
if (!dir || !S_ISDIR(dir->i_mode))
|
|
|
|
goto out;
|
|
|
|
error = -EINVAL;
|
|
|
|
if (!dir->i_fop)
|
|
|
|
goto out;
|
|
|
|
/*
|
|
|
|
* Open the directory ...
|
|
|
|
*/
|
|
|
|
file = dentry_open(dget(dentry), NULL, O_RDONLY);
|
|
|
|
error = PTR_ERR(file);
|
|
|
|
if (IS_ERR(file))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
error = -EINVAL;
|
|
|
|
if (!file->f_op->readdir)
|
|
|
|
goto out_close;
|
|
|
|
|
|
|
|
buffer.name = name;
|
|
|
|
buffer.ino = child->d_inode->i_ino;
|
|
|
|
buffer.found = 0;
|
|
|
|
buffer.sequence = 0;
|
|
|
|
while (1) {
|
|
|
|
int old_seq = buffer.sequence;
|
|
|
|
|
|
|
|
error = vfs_readdir(file, filldir_one, &buffer);
|
|
|
|
|
|
|
|
if (error < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
if (buffer.found)
|
|
|
|
break;
|
|
|
|
error = -ENOENT;
|
|
|
|
if (old_seq == buffer.sequence)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_close:
|
|
|
|
fput(file);
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* export_encode_fh - default export_operations->encode_fh function
|
|
|
|
* @dentry: the dentry to encode
|
|
|
|
* @fh: where to store the file handle fragment
|
|
|
|
* @max_len: maximum length to store there
|
|
|
|
* @connectable: whether to store parent information
|
|
|
|
*
|
|
|
|
* This default encode_fh function assumes that the 32 inode number
|
|
|
|
* is suitable for locating an inode, and that the generation number
|
|
|
|
* can be used to check that it is still valid. It places them in the
|
|
|
|
* filehandle fragment where export_decode_fh expects to find them.
|
|
|
|
*/
|
|
|
|
static int export_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
|
|
|
|
int connectable)
|
|
|
|
{
|
|
|
|
struct inode * inode = dentry->d_inode;
|
|
|
|
int len = *max_len;
|
|
|
|
int type = 1;
|
|
|
|
|
|
|
|
if (len < 2 || (connectable && len < 4))
|
|
|
|
return 255;
|
|
|
|
|
|
|
|
len = 2;
|
|
|
|
fh[0] = inode->i_ino;
|
|
|
|
fh[1] = inode->i_generation;
|
|
|
|
if (connectable && !S_ISDIR(inode->i_mode)) {
|
|
|
|
struct inode *parent;
|
|
|
|
|
|
|
|
spin_lock(&dentry->d_lock);
|
|
|
|
parent = dentry->d_parent->d_inode;
|
|
|
|
fh[2] = parent->i_ino;
|
|
|
|
fh[3] = parent->i_generation;
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
len = 4;
|
|
|
|
type = 2;
|
|
|
|
}
|
|
|
|
*max_len = len;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* export_decode_fh - default export_operations->decode_fh function
|
|
|
|
* @sb: The superblock
|
|
|
|
* @fh: pointer to the file handle fragment
|
|
|
|
* @fh_len: length of file handle fragment
|
|
|
|
* @acceptable: function for testing acceptability of dentrys
|
|
|
|
* @context: context for @acceptable
|
|
|
|
*
|
|
|
|
* This is the default decode_fh() function.
|
|
|
|
* a fileid_type of 1 indicates that the filehandlefragment
|
|
|
|
* just contains an object identifier understood by get_dentry.
|
|
|
|
* a fileid_type of 2 says that there is also a directory
|
|
|
|
* identifier 8 bytes in to the filehandlefragement.
|
|
|
|
*/
|
|
|
|
static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh_len,
|
|
|
|
int fileid_type,
|
|
|
|
int (*acceptable)(void *context, struct dentry *de),
|
|
|
|
void *context)
|
|
|
|
{
|
|
|
|
__u32 parent[2];
|
|
|
|
parent[0] = parent[1] = 0;
|
|
|
|
if (fh_len < 2 || fileid_type > 2)
|
|
|
|
return NULL;
|
|
|
|
if (fileid_type == 2) {
|
|
|
|
if (fh_len > 2) parent[0] = fh[2];
|
|
|
|
if (fh_len > 3) parent[1] = fh[3];
|
|
|
|
}
|
|
|
|
return find_exported_dentry(sb, fh, parent,
|
|
|
|
acceptable, context);
|
|
|
|
}
|
|
|
|
|
2007-07-17 18:04:30 +07:00
|
|
|
int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
|
|
|
|
int connectable)
|
|
|
|
{
|
2007-07-17 18:04:31 +07:00
|
|
|
struct export_operations *nop = dentry->d_sb->s_export_op;
|
|
|
|
int error;
|
2007-07-17 18:04:30 +07:00
|
|
|
|
2007-07-17 18:04:31 +07:00
|
|
|
if (nop->encode_fh)
|
|
|
|
error = nop->encode_fh(dentry, fh, max_len, connectable);
|
|
|
|
else
|
|
|
|
error = export_encode_fh(dentry, fh, max_len, connectable);
|
|
|
|
|
|
|
|
return error;
|
2007-07-17 18:04:30 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(exportfs_encode_fh);
|
|
|
|
|
|
|
|
struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len,
|
|
|
|
int fileid_type, int (*acceptable)(void *, struct dentry *),
|
|
|
|
void *context)
|
|
|
|
{
|
|
|
|
struct export_operations *nop = mnt->mnt_sb->s_export_op;
|
2007-07-17 18:04:31 +07:00
|
|
|
struct dentry *result;
|
2007-07-17 18:04:30 +07:00
|
|
|
|
2007-07-17 18:04:31 +07:00
|
|
|
if (nop->decode_fh) {
|
|
|
|
result = nop->decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type,
|
2007-07-17 18:04:30 +07:00
|
|
|
acceptable, context);
|
2007-07-17 18:04:31 +07:00
|
|
|
} else {
|
|
|
|
result = export_decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type,
|
|
|
|
acceptable, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2007-07-17 18:04:30 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(exportfs_decode_fh);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
EXPORT_SYMBOL(find_exported_dentry);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|