{
int error;
struct nameidata nd;
+ char * pathname;
struct dentry *dentry;
struct presto_file_set *fset;
ENTRY;
+ pathname = getname(name);
+ error = PTR_ERR(pathname);
+ if (IS_ERR(pathname)) {
+ EXIT;
+ goto exit;
+ }
+
/* this looks up the parent */
- error = __user_walk(name, LOOKUP_PARENT, &nd);
+ error = path_lookup(pathname, LOOKUP_PARENT, &nd);
if (error) {
EXIT;
goto exit;
path_release (&nd);
dput(dentry);
up(&dentry->d_parent->d_inode->i_sem);
+ putname(pathname);
exit:
return error;
}
struct lento_vfs_context *info)
{
int error;
- struct presto_file_set *fset;
struct dentry *new_dentry;
struct nameidata nd, old_nd;
+ char * to;
+ struct presto_file_set *fset;
- error = __user_walk(from, 0, &old_nd);
+ to = getname(newname);
+ if(IS_ERR(to))
+ return PTR_ERR(to);
+
+ error = __user_walk(oldname, 0, &old_nd);
if (error)
goto exit;
- error = __user_walk(newname, LOOKUP_PARENT, &nd);
+ error = path_lookup(to, LOOKUP_PARENT, &nd);
if (error)
goto out;
error = -EXDEV;
out:
path_release(&old_nd);
exit:
+ putname(to);
+
return error;
}
int lento_unlink(const char *pathname, struct lento_vfs_context *info)
{
int error = 0;
+ char * name;
struct dentry *dentry;
struct nameidata nd;
struct presto_file_set *fset;
ENTRY;
- error = __user_walk(pathname, LOOKUP_PARENT, &nd);
+ name = getname(pathname);
+ if(IS_ERR(name))
+ return PTR_ERR(name);
+
+ error = path_lookup(name, LOOKUP_PARENT, &nd))
if (error)
goto exit;
error = -EISDIR;
exit1:
path_release(&nd);
exit:
+ putname(name);
+
return error;
slashes:
{
int error;
char *from;
+ char *to;
struct dentry *dentry;
struct presto_file_set *fset;
struct nameidata nd;
goto exit;
}
- error = __user_walk(newname, LOOKUP_PARENT, &nd);
+ to = getname(newname);
+ error = PTR_ERR(to);
+ if (IS_ERR(to)) {
+ EXIT;
+ goto exit_from;
+ }
+
+ error = path_lookup(to, LOOKUP_PARENT, &nd);
if (error) {
EXIT;
goto exit_to;
goto exit_lock;
}
error = presto_do_symlink(fset, nd.dentry,
- dentry, from, info);
+ dentry, oldname, info);
path_release(&nd);
EXIT;
exit_lock:
up(&nd.dentry->d_inode->i_sem);
dput(dentry);
exit_to:
+ putname(to);
exit_from:
putname(from);
exit:
int lento_mkdir(const char *name, int mode, struct lento_vfs_context *info)
{
int error;
+ char *pathname;
struct dentry *dentry;
struct presto_file_set *fset;
struct nameidata nd;
ENTRY;
CDEBUG(D_PIOCTL, "name: %s, mode %o, offset %d, recno %d, flags %x\n",
name, mode, info->slot_offset, info->recno, info->flags);
- error = __user_walk(pathname, LOOKUP_PARENT, &nd);
+ pathname = getname(name);
+ error = PTR_ERR(pathname);
+ if (IS_ERR(pathname)) {
+ EXIT;
+ return error;
+ }
+
+ error = path_lookup(pathname, LOOKUP_PARENT, &nd);
if (error)
goto out_name;
path_release(&nd);
out_name:
EXIT;
+ putname(pathname);
CDEBUG(D_PIOCTL, "error: %d\n", error);
return error;
}
int lento_rmdir(const char *pathname, struct lento_vfs_context *info)
{
int error = 0;
+ char * name;
struct dentry *dentry;
struct presto_file_set *fset;
struct nameidata nd;
ENTRY;
- error = __user_walk(pathname, LOOKUP_PARENT, &nd))
+ name = getname(pathname);
+ if(IS_ERR(name))
+ return PTR_ERR(name);
+
+ error = path_lookup(name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
path_release(&nd);
exit:
EXIT;
+ putname(name);
return error;
}
struct lento_vfs_context *info)
{
int error = 0;
+ char * tmp;
struct dentry * dentry;
struct nameidata nd;
struct presto_file_set *fset;
if (S_ISDIR(mode))
return -EPERM;
+ tmp = getname(filename);
+ if (IS_ERR(tmp))
+ return PTR_ERR(tmp);
- error = __user_walk(filename, LOOKUP_PARENT, &nd);
+ error = path_lookup(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
dentry = lookup_create(&nd, 0);
up(&nd.dentry->d_inode->i_sem);
path_release(&nd);
out:
+ putname(tmp);
+
return error;
}
asmlinkage long sys_mknod(const char * filename, int mode, dev_t dev)
{
+ int error = 0;
+ char * tmp;
struct dentry * dentry;
struct nameidata nd;
- int error;
if (S_ISDIR(mode))
return -EPERM;
+ tmp = getname(filename);
+ if (IS_ERR(tmp))
+ return PTR_ERR(tmp);
- error = __user_walk(filename, LOOKUP_PARENT, &nd);
+ error = path_lookup(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
dentry = lookup_create(&nd, 0);
up(&nd.dentry->d_inode->i_sem);
path_release(&nd);
out:
+ putname(tmp);
+
return error;
}
asmlinkage long sys_mkdir(const char * pathname, int mode)
{
- struct nameidata nd;
- struct dentry *dentry;
- int error;
+ int error = 0;
+ char * tmp;
- error = __user_walk(pathname, LOOKUP_PARENT, &nd);
- if (error)
- goto out;
- dentry = lookup_create(&nd, 1);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- error = vfs_mkdir(nd.dentry->d_inode, dentry,
- mode & ~current->fs->umask);
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
+ tmp = getname(pathname);
+ error = PTR_ERR(tmp);
+ if (!IS_ERR(tmp)) {
+ struct dentry *dentry;
+ struct nameidata nd;
+
+ error = path_lookup(tmp, LOOKUP_PARENT, &nd);
+ if (error)
+ goto out;
+ dentry = lookup_create(&nd, 1);
+ error = PTR_ERR(dentry);
+ if (!IS_ERR(dentry)) {
+ error = vfs_mkdir(nd.dentry->d_inode, dentry,
+ mode & ~current->fs->umask);
+ dput(dentry);
+ }
+ up(&nd.dentry->d_inode->i_sem);
+ path_release(&nd);
out:
+ putname(tmp);
+ }
+
return error;
}
asmlinkage long sys_rmdir(const char * pathname)
{
+ int error = 0;
+ char * name;
struct dentry *dentry;
struct nameidata nd;
- int error;
- error = __user_walk(pathname, LOOKUP_PARENT, &nd);
+ name = getname(pathname);
+ if(IS_ERR(name))
+ return PTR_ERR(name);
+
+ error = path_lookup(name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
exit1:
path_release(&nd);
exit:
+ putname(name);
return error;
}
asmlinkage long sys_unlink(const char * pathname)
{
+ int error = 0;
+ char * name;
struct dentry *dentry;
struct nameidata nd;
- int error;
- error = __user_walk(pathname, LOOKUP_PARENT, &nd);
+ name = getname(pathname);
+ if(IS_ERR(name))
+ return PTR_ERR(name);
+
+ error = path_lookup(name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
error = -EISDIR;
exit1:
path_release(&nd);
exit:
+ putname(name);
+
return error;
slashes:
asmlinkage long sys_symlink(const char * oldname, const char * newname)
{
- struct dentry *dentry;
- char *from = getname(oldname);
- struct nameidata nd;
- int error;
+ int error = 0;
+ char * from;
+ char * to;
- if (IS_ERR(from))
+ from = getname(oldname);
+ if(IS_ERR(from))
return PTR_ERR(from);
+ to = getname(newname);
+ error = PTR_ERR(to);
+ if (!IS_ERR(to)) {
+ struct dentry *dentry;
+ struct nameidata nd;
- error = __user_walk(newname, LOOKUP_PARENT, &nd);
- if (error)
- goto out;
- dentry = lookup_create(&nd, 0);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- error = vfs_symlink(nd.dentry->d_inode, dentry, from);
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
+ error = path_lookup(to, LOOKUP_PARENT, &nd);
+ if (error)
+ goto out;
+ dentry = lookup_create(&nd, 0);
+ error = PTR_ERR(dentry);
+ if (!IS_ERR(dentry)) {
+ error = vfs_symlink(nd.dentry->d_inode, dentry, from);
+ dput(dentry);
+ }
+ up(&nd.dentry->d_inode->i_sem);
+ path_release(&nd);
out:
+ putname(to);
+ }
putname(from);
return error;
}
struct dentry *new_dentry;
struct nameidata nd, old_nd;
int error;
+ char * to;
+
+ to = getname(newname);
+ if (IS_ERR(to))
+ return PTR_ERR(to);
error = __user_walk(oldname, 0, &old_nd);
if (error)
goto exit;
- error = __user_walk(newname, LOOKUP_PARENT, &nd);
+ error = path_lookup(to, 0, &nd);
if (error)
goto out;
error = -EXDEV;
out:
path_release(&old_nd);
exit:
+ putname(to);
+
return error;
}
return error;
}
-asmlinkage long sys_rename(const char * oldname, const char * newname)
+static inline int do_rename(const char * oldname, const char * newname)
{
int error = 0;
struct dentry * old_dir, * new_dir;
struct dentry * trap;
struct nameidata oldnd, newnd;
- error = __user_walk(oldname, LOOKUP_PARENT, &oldnd);
+ error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
if (error)
goto exit;
- error = __user_walk(newname, LOOKUP_PARENT, &newnd);
+ error = path_lookup(newname, LOOKUP_PARENT, &newnd);
if (error)
goto exit1;
return error;
}
+asmlinkage long sys_rename(const char * oldname, const char * newname)
+{
+ int error;
+ char * from;
+ char * to;
+
+ from = getname(oldname);
+ if(IS_ERR(from))
+ return PTR_ERR(from);
+ to = getname(newname);
+ error = PTR_ERR(to);
+ if (!IS_ERR(to)) {
+ error = do_rename(from,to);
+ putname(to);
+ }
+ putname(from);
+ return error;
+}
+
int vfs_readlink(struct dentry *dentry, char *buffer, int buflen, const char *link)
{
int len;