kernel/vfs: Convert from custom VNodePutter to the generic VnodePutter.
The latter is actually an AutoDeleter based on CObjectDeleter. No functional change intended.
This commit is contained in:
@@ -547,41 +547,6 @@ static struct fd_ops sQueryOps = {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class VNodePutter {
|
|
||||||
public:
|
|
||||||
VNodePutter(struct vnode* vnode = NULL) : fVNode(vnode) {}
|
|
||||||
|
|
||||||
~VNodePutter()
|
|
||||||
{
|
|
||||||
Put();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetTo(struct vnode* vnode)
|
|
||||||
{
|
|
||||||
Put();
|
|
||||||
fVNode = vnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Put()
|
|
||||||
{
|
|
||||||
if (fVNode) {
|
|
||||||
put_vnode(fVNode);
|
|
||||||
fVNode = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct vnode* Detach()
|
|
||||||
{
|
|
||||||
struct vnode* vnode = fVNode;
|
|
||||||
fVNode = NULL;
|
|
||||||
return vnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct vnode* fVNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class FDCloser {
|
class FDCloser {
|
||||||
public:
|
public:
|
||||||
FDCloser() : fFD(-1), fKernel(true) {}
|
FDCloser() : fFD(-1), fKernel(true) {}
|
||||||
@@ -2509,7 +2474,7 @@ get_vnode_name(struct vnode* vnode, struct vnode* parent, struct dirent* buffer,
|
|||||||
|
|
||||||
// See if the vnode is covering another vnode and move to the covered
|
// See if the vnode is covering another vnode and move to the covered
|
||||||
// vnode so we get the underlying file system
|
// vnode so we get the underlying file system
|
||||||
VNodePutter vnodePutter;
|
VnodePutter vnodePutter;
|
||||||
if (Vnode* coveredVnode = get_covered_vnode(vnode)) {
|
if (Vnode* coveredVnode = get_covered_vnode(vnode)) {
|
||||||
vnode = coveredVnode;
|
vnode = coveredVnode;
|
||||||
vnodePutter.SetTo(vnode);
|
vnodePutter.SetTo(vnode);
|
||||||
@@ -2896,7 +2861,7 @@ get_new_fd(int type, struct fs_mount* mount, struct vnode* vnode,
|
|||||||
static status_t
|
static status_t
|
||||||
normalize_path(char* path, size_t pathSize, bool traverseLink, bool kernel)
|
normalize_path(char* path, size_t pathSize, bool traverseLink, bool kernel)
|
||||||
{
|
{
|
||||||
VNodePutter dirPutter;
|
VnodePutter dirPutter;
|
||||||
struct vnode* dir = NULL;
|
struct vnode* dir = NULL;
|
||||||
status_t error;
|
status_t error;
|
||||||
|
|
||||||
@@ -2915,7 +2880,7 @@ normalize_path(char* path, size_t pathSize, bool traverseLink, bool kernel)
|
|||||||
// get file vnode, if we shall resolve links
|
// get file vnode, if we shall resolve links
|
||||||
bool fileExists = false;
|
bool fileExists = false;
|
||||||
struct vnode* fileVnode;
|
struct vnode* fileVnode;
|
||||||
VNodePutter fileVnodePutter;
|
VnodePutter fileVnodePutter;
|
||||||
if (traverseLink) {
|
if (traverseLink) {
|
||||||
inc_vnode_ref_count(dir);
|
inc_vnode_ref_count(dir);
|
||||||
if (vnode_path_to_vnode(dir, path, false, 0, kernel, &fileVnode,
|
if (vnode_path_to_vnode(dir, path, false, 0, kernel, &fileVnode,
|
||||||
@@ -4575,7 +4540,7 @@ vfs_create_special_node(const char* path, fs_vnode* subVnode, mode_t mode,
|
|||||||
inc_vnode_ref_count(dirNode);
|
inc_vnode_ref_count(dirNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
VNodePutter _(dirNode);
|
VnodePutter _(dirNode);
|
||||||
|
|
||||||
// check support for creating special nodes
|
// check support for creating special nodes
|
||||||
if (!HAS_FS_CALL(dirNode, create_special_node))
|
if (!HAS_FS_CALL(dirNode, create_special_node))
|
||||||
@@ -5211,14 +5176,14 @@ vfs_bind_mount_directory(dev_t mountID, ino_t nodeID, dev_t coveredMountID,
|
|||||||
status_t error = get_vnode(mountID, nodeID, &vnode, true, false);
|
status_t error = get_vnode(mountID, nodeID, &vnode, true, false);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
VNodePutter vnodePutter(vnode);
|
VnodePutter vnodePutter(vnode);
|
||||||
|
|
||||||
Vnode* coveredVnode;
|
Vnode* coveredVnode;
|
||||||
error = get_vnode(coveredMountID, coveredNodeID, &coveredVnode, true,
|
error = get_vnode(coveredMountID, coveredNodeID, &coveredVnode, true,
|
||||||
false);
|
false);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
VNodePutter coveredVnodePutter(coveredVnode);
|
VnodePutter coveredVnodePutter(coveredVnode);
|
||||||
|
|
||||||
// establish the covered/covering links
|
// establish the covered/covering links
|
||||||
WriteLocker locker(sVnodeLock);
|
WriteLocker locker(sVnodeLock);
|
||||||
@@ -5435,7 +5400,7 @@ create_vnode(struct vnode* directory, const char* name, int openMode,
|
|||||||
// look the node up
|
// look the node up
|
||||||
status = lookup_dir_entry(directory, name, &vnode);
|
status = lookup_dir_entry(directory, name, &vnode);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
VNodePutter putter(vnode);
|
VnodePutter putter(vnode);
|
||||||
|
|
||||||
if ((openMode & O_EXCL) != 0)
|
if ((openMode & O_EXCL) != 0)
|
||||||
return B_FILE_EXISTS;
|
return B_FILE_EXISTS;
|
||||||
@@ -5443,7 +5408,7 @@ create_vnode(struct vnode* directory, const char* name, int openMode,
|
|||||||
// If the node is a symlink, we have to follow it, unless
|
// If the node is a symlink, we have to follow it, unless
|
||||||
// O_NOTRAVERSE is set.
|
// O_NOTRAVERSE is set.
|
||||||
if (S_ISLNK(vnode->Type()) && traverse) {
|
if (S_ISLNK(vnode->Type()) && traverse) {
|
||||||
putter.Put();
|
putter.Unset();
|
||||||
char clonedName[B_FILE_NAME_LENGTH + 1];
|
char clonedName[B_FILE_NAME_LENGTH + 1];
|
||||||
if (strlcpy(clonedName, name, B_FILE_NAME_LENGTH)
|
if (strlcpy(clonedName, name, B_FILE_NAME_LENGTH)
|
||||||
>= B_FILE_NAME_LENGTH) {
|
>= B_FILE_NAME_LENGTH) {
|
||||||
@@ -9215,8 +9180,8 @@ _user_open_parent_dir(int fd, char* userName, size_t nameLength)
|
|||||||
// get the vnodes
|
// get the vnodes
|
||||||
struct vnode* parentVNode = get_vnode_from_fd(parentFD, kernel);
|
struct vnode* parentVNode = get_vnode_from_fd(parentFD, kernel);
|
||||||
struct vnode* dirVNode = get_vnode_from_fd(fd, kernel);
|
struct vnode* dirVNode = get_vnode_from_fd(fd, kernel);
|
||||||
VNodePutter parentVNodePutter(parentVNode);
|
VnodePutter parentVNodePutter(parentVNode);
|
||||||
VNodePutter dirVNodePutter(dirVNode);
|
VnodePutter dirVNodePutter(dirVNode);
|
||||||
if (!parentVNode || !dirVNode)
|
if (!parentVNode || !dirVNode)
|
||||||
return B_FILE_ERROR;
|
return B_FILE_ERROR;
|
||||||
|
|
||||||
@@ -9558,7 +9523,7 @@ _user_create_fifo(int fd, const char* userPath, mode_t perms)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
VNodePutter _(dir);
|
VnodePutter _(dir);
|
||||||
|
|
||||||
// the underlying FS needs to support creating FIFOs
|
// the underlying FS needs to support creating FIFOs
|
||||||
if (!HAS_FS_CALL(dir, create_special_node))
|
if (!HAS_FS_CALL(dir, create_special_node))
|
||||||
|
|||||||
Reference in New Issue
Block a user