Prevent creation of entries in unlinked directories.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37563 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -546,6 +546,10 @@ checksumfs_create_symlink(fs_volume* fsVolume, fs_vnode* parent,
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
// don't create an entry in an unlinked directory
|
||||||
|
if (directory->HardLinks() == 0)
|
||||||
|
RETURN_ERROR(B_ENTRY_NOT_FOUND);
|
||||||
|
|
||||||
// create a symlink node
|
// create a symlink node
|
||||||
SymLink* newSymLink;
|
SymLink* newSymLink;
|
||||||
error = volume->CreateSymLink(mode, transaction, newSymLink);
|
error = volume->CreateSymLink(mode, transaction, newSymLink);
|
||||||
@@ -849,13 +853,16 @@ checksumfs_create(fs_volume* fsVolume, fs_vnode* parent, const char* name,
|
|||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
|
||||||
// The entry doesn't exist yet. We have to create a new file.
|
// The entry doesn't exist yet. We have to create a new file.
|
||||||
// TODO: Don't do that in an unlinked directory!
|
|
||||||
|
|
||||||
// check the directory write permission
|
// check the directory write permission
|
||||||
error = check_access(directory, W_OK);
|
error = check_access(directory, W_OK);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
// don't create an entry in an unlinked directory
|
||||||
|
if (directory->HardLinks() == 0)
|
||||||
|
RETURN_ERROR(B_ENTRY_NOT_FOUND);
|
||||||
|
|
||||||
// start a transaction and attach the directory
|
// start a transaction and attach the directory
|
||||||
Transaction transaction(volume);
|
Transaction transaction(volume);
|
||||||
error = transaction.StartAndAddNode(directory,
|
error = transaction.StartAndAddNode(directory,
|
||||||
@@ -1121,6 +1128,10 @@ checksumfs_create_dir(fs_volume* fsVolume, fs_vnode* parent, const char* name,
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
// don't create an entry in an unlinked directory
|
||||||
|
if (directory->HardLinks() == 0)
|
||||||
|
RETURN_ERROR(B_ENTRY_NOT_FOUND);
|
||||||
|
|
||||||
// create a directory node
|
// create a directory node
|
||||||
Directory* newDirectory;
|
Directory* newDirectory;
|
||||||
error = volume->CreateDirectory(perms, transaction, newDirectory);
|
error = volume->CreateDirectory(perms, transaction, newDirectory);
|
||||||
|
|||||||
Reference in New Issue
Block a user