diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 065d428d45..469315a514 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1003,7 +1003,7 @@ Inode::CreateAttribute(Transaction &transaction, const char *name, uint32 type, // Inode::Create() locks the inode for us return Inode::Create(transaction, attributes, name, - S_ATTR | S_REGULAR | 0666, 0, type, NULL, attribute); + S_ATTR | S_FILE | 0666, 0, type, NULL, attribute); } @@ -2244,7 +2244,7 @@ Inode::Create(Transaction &transaction, Inode *parent, const char *name, int32 m inode->UpdateOldLastModified(); // The "size" & "last_modified" indices don't contain directories - if ((mode & (S_FILE | S_SYMLINK)) != 0) { + if (inode->IsFile() || inode->IsSymLink()) { // if adding to these indices fails, the inode creation will not be harmed; // they are considered less important than the "name" index if (inode->IsFile()) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.h b/src/add-ons/kernel/file_systems/bfs/Inode.h index c66d4d8171..8554480738 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.h +++ b/src/add-ons/kernel/file_systems/bfs/Inode.h @@ -40,7 +40,6 @@ enum inode_type { S_FILE = S_IFREG, S_SYMLINK = S_IFLNK, - S_REGULAR = (S_DIRECTORY | S_FILE | S_SYMLINK), S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX | S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX | S_FLOAT_INDEX | S_DOUBLE_INDEX) }; @@ -68,11 +67,11 @@ class Inode { bool IsAttributeDirectory() const { return (Mode() & S_ATTR_DIR) != 0; } bool IsAttribute() const { return (Mode() & S_ATTR) != 0; } - bool IsFile() const { return S_ISREG(Mode()); } + bool IsFile() const { return (Mode() & (S_IFMT | S_ATTR)) == S_FILE; } bool IsRegularNode() const { return (Mode() & (S_ATTR_DIR | S_INDEX_DIR | S_ATTR)) == 0; } // a regular node in the standard namespace (i.e. not an index or attribute) bool IsSymLink() const { return S_ISLNK(Mode()); } - bool HasUserAccessableStream() const { return S_ISREG(Mode()); } + bool HasUserAccessableStream() const { return IsFile(); } // currently only files can be accessed with bfs_read()/bfs_write() bool IsDeleted() const { return (Flags() & INODE_DELETED) != 0; } diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp index 6ff9221a3d..d08232c868 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp @@ -965,7 +965,7 @@ Inode::CreateAttribute(Transaction *transaction, const char *name, uint32 type, // Inode::Create() locks the inode for us return Inode::Create(transaction, attributes, name, - S_ATTR | S_REGULAR | 0666, 0, type, NULL, attribute); + S_ATTR | S_FILE | 0666, 0, type, NULL, attribute); } @@ -2064,7 +2064,7 @@ Inode::Create(Transaction *transaction, Inode *parent, const char *name, int32 m inode->UpdateOldLastModified(); // The "size" & "last_modified" indices don't contain directories - if ((mode & (S_FILE | S_SYMLINK)) != 0) { + if (inode->IsFile() || inode->IsSymLink()) { // if adding to these indices fails, the inode creation will not be harmed; // they are considered less important than the "name" index if (inode->IsFile()) diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h index ad90148d0f..4d27860340 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h @@ -35,7 +35,6 @@ enum inode_type { S_FILE = S_IFREG, S_SYMLINK = S_IFLNK, - S_REGULAR = (S_DIRECTORY | S_FILE | S_SYMLINK), S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX | S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX | S_FLOAT_INDEX | S_DOUBLE_INDEX) }; @@ -101,11 +100,11 @@ class Inode : public CachedBlock { bool IsAttributeDirectory() const { return (Mode() & S_ATTR_DIR) != 0; } bool IsAttribute() const { return Mode() & S_ATTR; } - bool IsFile() const { return Mode() & S_IFREG; } + bool IsFile() const { return (Mode() & (S_IFMT | S_ATTR)) == S_FILE; } bool IsRegularNode() const { return (Mode() & (S_ATTR_DIR | S_INDEX_DIR | S_ATTR)) == 0; } // a regular node in the standard namespace (i.e. not an index or attribute) bool IsSymLink() const { return S_ISLNK(Mode()); } - bool HasUserAccessableStream() const { return S_ISREG(Mode()); } + bool HasUserAccessableStream() const { return IsFile(); } // currently only files can be accessed with bfs_read()/bfs_write() off_t Size() const { return Node()->data.Size(); }