* Solaris Porting Layer (SPL) Vnode Implementation.
\*****************************************************************************/
-#include <sys/sysmacros.h>
#include <sys/vnode.h>
+#include <spl-debug.h>
-
-#ifdef DEBUG_SUBSYSTEM
-#undef DEBUG_SUBSYSTEM
+#ifdef SS_DEBUG_SUBSYS
+#undef SS_DEBUG_SUBSYS
#endif
-#define DEBUG_SUBSYSTEM S_VNODE
+#define SS_DEBUG_SUBSYS SS_VNODE
vnode_t *rootdir = (vnode_t *)0xabcd1234;
EXPORT_SYMBOL(rootdir);
vn_alloc(int flag)
{
vnode_t *vp;
- ENTRY;
+ SENTRY;
vp = kmem_cache_alloc(vn_cache, flag);
if (vp != NULL) {
vp->v_type = 0;
}
- RETURN(vp);
+ SRETURN(vp);
} /* vn_alloc() */
EXPORT_SYMBOL(vn_alloc);
void
vn_free(vnode_t *vp)
{
- ENTRY;
+ SENTRY;
kmem_cache_free(vn_cache, vp);
- EXIT;
+ SEXIT;
} /* vn_free() */
EXPORT_SYMBOL(vn_free);
struct kstat stat;
int rc, saved_umask = 0;
vnode_t *vp;
- ENTRY;
+ SENTRY;
ASSERT(flags & (FWRITE | FREAD));
ASSERT(seg == UIO_SYSSPACE);
(void)xchg(¤t->fs->umask, saved_umask);
if (IS_ERR(fp))
- RETURN(-PTR_ERR(fp));
+ SRETURN(-PTR_ERR(fp));
rc = vfs_getattr(fp->f_vfsmnt, fp->f_dentry, &stat);
if (rc) {
filp_close(fp, 0);
- RETURN(-rc);
+ SRETURN(-rc);
}
vp = vn_alloc(KM_SLEEP);
if (!vp) {
filp_close(fp, 0);
- RETURN(ENOMEM);
+ SRETURN(ENOMEM);
}
mutex_enter(&vp->v_lock);
*vpp = vp;
mutex_exit(&vp->v_lock);
- RETURN(0);
+ SRETURN(0);
} /* vn_open() */
EXPORT_SYMBOL(vn_open);
{
char *realpath;
int len, rc;
- ENTRY;
+ SENTRY;
ASSERT(vp == rootdir);
len = strlen(path) + 2;
realpath = kmalloc(len, GFP_KERNEL);
if (!realpath)
- RETURN(ENOMEM);
+ SRETURN(ENOMEM);
(void)snprintf(realpath, len, "/%s", path);
rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2);
kfree(realpath);
- RETURN(rc);
+ SRETURN(rc);
} /* vn_openat() */
EXPORT_SYMBOL(vn_openat);
mm_segment_t saved_fs;
struct file *fp;
int rc;
- ENTRY;
+ SENTRY;
ASSERT(uio == UIO_WRITE || uio == UIO_READ);
ASSERT(vp);
set_fs(saved_fs);
if (rc < 0)
- RETURN(-rc);
+ SRETURN(-rc);
if (residp) {
*residp = len - rc;
} else {
if (rc != len)
- RETURN(EIO);
+ SRETURN(EIO);
}
- RETURN(0);
+ SRETURN(0);
} /* vn_rdwr() */
EXPORT_SYMBOL(vn_rdwr);
vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
{
int rc;
- ENTRY;
+ SENTRY;
ASSERT(vp);
ASSERT(vp->v_file);
rc = filp_close(vp->v_file, 0);
vn_free(vp);
- RETURN(-rc);
+ SRETURN(-rc);
} /* vn_close() */
EXPORT_SYMBOL(vn_close);
static struct dentry *
vn_lookup_hash(struct nameidata *nd)
{
- return lookup_one_len(nd->last.name, nd->nd_dentry, nd->last.len);
+ return lookup_one_len((const char *)nd->last.name,
+ nd->nd_dentry, nd->last.len);
} /* lookup_hash() */
static void
struct nameidata nd;
struct inode *inode = NULL;
int rc = 0;
- ENTRY;
+ SENTRY;
ASSERT(seg == UIO_SYSSPACE);
ASSERT(flags == RMFILE);
rc = path_lookup(path, LOOKUP_PARENT, &nd);
if (rc)
- GOTO(exit, rc);
+ SGOTO(exit, rc);
rc = -EISDIR;
if (nd.last_type != LAST_NORM)
- GOTO(exit1, rc);
+ SGOTO(exit1, rc);
#ifdef HAVE_INODE_I_MUTEX
mutex_lock_nested(&nd.nd_dentry->d_inode->i_mutex, I_MUTEX_PARENT);
if (!IS_ERR(dentry)) {
/* Why not before? Because we want correct rc value */
if (nd.last.name[nd.last.len])
- GOTO(slashes, rc);
+ SGOTO(slashes, rc);
inode = dentry->d_inode;
if (inode)
exit1:
vn_path_release(&nd);
exit:
- RETURN(-rc);
+ SRETURN(-rc);
slashes:
rc = !dentry->d_inode ? -ENOENT :
S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;
- GOTO(exit2, rc);
+ SGOTO(exit2, rc);
} /* vn_remove() */
EXPORT_SYMBOL(vn_remove);
struct dentry *trap;
struct nameidata oldnd, newnd;
int rc = 0;
- ENTRY;
+ SENTRY;
rc = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
if (rc)
- GOTO(exit, rc);
+ SGOTO(exit, rc);
rc = path_lookup(newname, LOOKUP_PARENT, &newnd);
if (rc)
- GOTO(exit1, rc);
+ SGOTO(exit1, rc);
rc = -EXDEV;
if (oldnd.nd_mnt != newnd.nd_mnt)
- GOTO(exit2, rc);
+ SGOTO(exit2, rc);
old_dir = oldnd.nd_dentry;
rc = -EBUSY;
if (oldnd.last_type != LAST_NORM)
- GOTO(exit2, rc);
+ SGOTO(exit2, rc);
new_dir = newnd.nd_dentry;
if (newnd.last_type != LAST_NORM)
- GOTO(exit2, rc);
+ SGOTO(exit2, rc);
trap = lock_rename(new_dir, old_dir);
rc = PTR_ERR(old_dentry);
if (IS_ERR(old_dentry))
- GOTO(exit3, rc);
+ SGOTO(exit3, rc);
/* source must exist */
rc = -ENOENT;
if (!old_dentry->d_inode)
- GOTO(exit4, rc);
+ SGOTO(exit4, rc);
/* unless the source is a directory trailing slashes give -ENOTDIR */
if (!S_ISDIR(old_dentry->d_inode->i_mode)) {
rc = -ENOTDIR;
if (oldnd.last.name[oldnd.last.len])
- GOTO(exit4, rc);
+ SGOTO(exit4, rc);
if (newnd.last.name[newnd.last.len])
- GOTO(exit4, rc);
+ SGOTO(exit4, rc);
}
/* source should not be ancestor of target */
rc = -EINVAL;
if (old_dentry == trap)
- GOTO(exit4, rc);
+ SGOTO(exit4, rc);
new_dentry = vn_lookup_hash(&newnd);
rc = PTR_ERR(new_dentry);
if (IS_ERR(new_dentry))
- GOTO(exit4, rc);
+ SGOTO(exit4, rc);
/* target should not be an ancestor of source */
rc = -ENOTEMPTY;
if (new_dentry == trap)
- GOTO(exit5, rc);
+ SGOTO(exit5, rc);
#ifdef HAVE_4ARGS_VFS_RENAME
rc = vfs_rename(old_dir->d_inode, old_dentry,
exit1:
vn_path_release(&oldnd);
exit:
- RETURN(-rc);
+ SRETURN(-rc);
}
EXPORT_SYMBOL(vn_rename);
struct file *fp;
struct kstat stat;
int rc;
- ENTRY;
+ SENTRY;
ASSERT(vp);
ASSERT(vp->v_file);
rc = vfs_getattr(fp->f_vfsmnt, fp->f_dentry, &stat);
if (rc)
- RETURN(-rc);
+ SRETURN(-rc);
vap->va_type = vn_get_sol_type(stat.mode);
vap->va_mode = stat.mode;
vap->va_rdev = stat.rdev;
vap->va_blocks = stat.blocks;
- RETURN(0);
+ SRETURN(0);
}
EXPORT_SYMBOL(vn_getattr);
int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4)
{
int datasync = 0;
- ENTRY;
+ SENTRY;
ASSERT(vp);
ASSERT(vp->v_file);
if (flags & FDSYNC)
datasync = 1;
- RETURN(-file_fsync(vp->v_file, vp->v_file->f_dentry, datasync));
+ SRETURN(-spl_filp_fsync(vp->v_file, datasync));
} /* vn_fsync() */
EXPORT_SYMBOL(vn_fsync);
file_t *fp;
vnode_t *vp;
int rc = 0;
- ENTRY;
+ SENTRY;
/* Already open just take an extra reference */
spin_lock(&vn_file_lock);
if (fp) {
atomic_inc(&fp->f_ref);
spin_unlock(&vn_file_lock);
- RETURN(fp);
+ SRETURN(fp);
}
spin_unlock(&vn_file_lock);
/* File was not yet opened create the object and setup */
fp = kmem_cache_alloc(vn_file_cache, KM_SLEEP);
if (fp == NULL)
- GOTO(out, rc);
+ SGOTO(out, rc);
mutex_enter(&fp->f_lock);
lfp = fget(fd);
if (lfp == NULL)
- GOTO(out_mutex, rc);
+ SGOTO(out_mutex, rc);
vp = vn_alloc(KM_SLEEP);
if (vp == NULL)
- GOTO(out_fget, rc);
+ SGOTO(out_fget, rc);
if (vfs_getattr(lfp->f_vfsmnt, lfp->f_dentry, &stat))
- GOTO(out_vnode, rc);
+ SGOTO(out_vnode, rc);
mutex_enter(&vp->v_lock);
vp->v_type = vn_get_sol_type(stat.mode);
spin_unlock(&vn_file_lock);
mutex_exit(&fp->f_lock);
- RETURN(fp);
+ SRETURN(fp);
out_vnode:
vn_free(vp);
mutex_exit(&fp->f_lock);
kmem_cache_free(vn_file_cache, fp);
out:
- RETURN(NULL);
+ SRETURN(NULL);
} /* getf() */
EXPORT_SYMBOL(getf);
vn_releasef(int fd)
{
file_t *fp;
- ENTRY;
+ SENTRY;
spin_lock(&vn_file_lock);
fp = file_find(fd);
atomic_dec(&fp->f_ref);
if (atomic_read(&fp->f_ref) > 0) {
spin_unlock(&vn_file_lock);
- EXIT;
+ SEXIT;
return;
}
}
spin_unlock(&vn_file_lock);
- EXIT;
+ SEXIT;
return;
} /* releasef() */
EXPORT_SYMBOL(releasef);
#endif /* HAVE_2ARGS_SET_FS_PWD */
mm_segment_t saved_fs;
int rc;
- ENTRY;
+ SENTRY;
/*
* user_path_dir() and __user_walk() both expect 'filename' to be
# ifdef HAVE_USER_PATH_DIR
rc = user_path_dir(filename, &path);
if (rc)
- GOTO(out, rc);
+ SGOTO(out, rc);
rc = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
if (rc)
- GOTO(dput_and_out, rc);
+ SGOTO(dput_and_out, rc);
set_fs_pwd(current->fs, &path);
rc = __user_walk(filename,
LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
if (rc)
- GOTO(out, rc);
+ SGOTO(out, rc);
rc = vfs_permission(&nd, MAY_EXEC);
if (rc)
- GOTO(dput_and_out, rc);
+ SGOTO(dput_and_out, rc);
set_fs_pwd(current->fs, &nd.path);
rc = __user_walk(filename,
LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
if (rc)
- GOTO(out, rc);
+ SGOTO(out, rc);
rc = vfs_permission(&nd, MAY_EXEC);
if (rc)
- GOTO(dput_and_out, rc);
+ SGOTO(dput_and_out, rc);
set_fs_pwd(current->fs, nd.nd_mnt, nd.nd_dentry);
out:
set_fs(saved_fs);
- RETURN(-rc);
+ SRETURN(-rc);
} /* vn_set_pwd() */
EXPORT_SYMBOL(vn_set_pwd);
int
vn_init(void)
{
- ENTRY;
+ SENTRY;
vn_cache = kmem_cache_create("spl_vn_cache",
sizeof(struct vnode), 64,
vn_cache_constructor,
vn_file_cache_constructor,
vn_file_cache_destructor,
NULL, NULL, NULL, 0);
- RETURN(0);
+ SRETURN(0);
} /* vn_init() */
void
{
file_t *fp, *next_fp;
int leaked = 0;
- ENTRY;
+ SENTRY;
spin_lock(&vn_file_lock);
spin_unlock(&vn_file_lock);
if (leaked > 0)
- CWARN("Warning %d files leaked\n", leaked);
+ SWARN("Warning %d files leaked\n", leaked);
kmem_cache_destroy(vn_cache);
- EXIT;
+ SEXIT;
return;
} /* vn_fini() */