diff --git a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp index a98ca4c67b..4b179c5ef8 100644 --- a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -267,10 +268,16 @@ Inode::Link(Inode* dir, const char* name) status_t Inode::Remove(const char* name, FileType type) { + MemoryDeleter nameDeleter; if (type == NF4NAMEDATTR) { status_t result = LoadAttrDirHandle(); if (result != B_OK) return result; + + name = AttrToFileName(name); + if (name == NULL) + return B_NO_MEMORY; + nameDeleter.SetTo(const_cast(name)); } ChangeInfo changeInfo; @@ -311,6 +318,8 @@ Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName, if (from->fFileSystem != to->fFileSystem) return B_DONT_DO_THAT; + MemoryDeleter fromNameDeleter; + MemoryDeleter toNameDeleter; if (attribute) { status_t result = from->LoadAttrDirHandle(); if (result != B_OK) @@ -319,6 +328,14 @@ Inode::Rename(Inode* from, Inode* to, const char* fromName, const char* toName, result = to->LoadAttrDirHandle(); if (result != B_OK) return result; + + fromName = from->AttrToFileName(fromName); + toName = to->AttrToFileName(toName); + + fromNameDeleter.SetTo(const_cast(fromName)); + toNameDeleter.SetTo(const_cast(toName)); + if (fromName == NULL || toName == NULL) + return B_NO_MEMORY; } ChangeInfo fromChange, toChange; diff --git a/src/add-ons/kernel/file_systems/nfs4/Inode.h b/src/add-ons/kernel/file_systems/nfs4/Inode.h index 7497fa5fd2..3815e9741e 100644 --- a/src/add-ons/kernel/file_systems/nfs4/Inode.h +++ b/src/add-ons/kernel/file_systems/nfs4/Inode.h @@ -132,6 +132,8 @@ protected: status_t GetStat(struct stat* st, OpenAttrCookie* attr = NULL); + char* AttrToFileName(const char* path); + static inline status_t CheckLockType(short ltype, uint32 mode); private: diff --git a/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp b/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp index 65f735aa79..5633fba537 100644 --- a/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp @@ -85,11 +85,11 @@ Inode::LoadAttrDirHandle() return B_UNSUPPORTED; char* attrDir - = reinterpret_cast(malloc(strlen(fInfo.fName) + 32)); + = reinterpret_cast(malloc(strlen(Name()) + 32)); if (attrDir == NULL) return B_NO_MEMORY; strcpy(attrDir, "."); - strcat(attrDir, fInfo.fName); + strcat(attrDir, Name()); strcat(attrDir, "-haiku-attrs"); result = NFS4Inode::LookUp(attrDir, NULL, NULL, &handle, true); diff --git a/src/add-ons/kernel/file_systems/nfs4/InodeRegular.cpp b/src/add-ons/kernel/file_systems/nfs4/InodeRegular.cpp index 4d1b943e4e..b677477963 100644 --- a/src/add-ons/kernel/file_systems/nfs4/InodeRegular.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/InodeRegular.cpp @@ -40,12 +40,15 @@ Inode::CreateState(const char* name, int mode, int perms, OpenState* state, fi.fParent = fInfo.fHandle; fi.fName = strdup(name); - char* path = reinterpret_cast(malloc(strlen(name) + 2 + - strlen(fInfo.fPath))); - strcpy(path, fInfo.fPath); - strcat(path, "/"); - strcat(path, name); - fi.fPath = path; + if (fInfo.fPath != NULL) { + char* path = reinterpret_cast(malloc(strlen(name) + 2 + + strlen(fInfo.fPath))); + strcpy(path, fInfo.fPath); + strcat(path, "/"); + strcat(path, name); + fi.fPath = path; + } else + fi.fPath = strdup(name); fFileSystem->InoIdMap()->AddEntry(fi, FileIdToInoT(fileID)); @@ -193,8 +196,8 @@ Inode::Close(OpenFileCookie* cookie) } -static char* -AttrToFileName(const char* path) +char* +Inode::AttrToFileName(const char* path) { char* name = strdup(path); if (name == NULL) diff --git a/src/add-ons/kernel/file_systems/nfs4/RootInode.cpp b/src/add-ons/kernel/file_systems/nfs4/RootInode.cpp index 4ca51e2021..65fbd73247 100644 --- a/src/add-ons/kernel/file_systems/nfs4/RootInode.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/RootInode.cpp @@ -126,7 +126,13 @@ RootInode::_UpdateInfo(bool force) break; } while (true); - fInfoCache.flags = 0; + fInfoCache.flags = B_FS_IS_PERSISTENT | B_FS_IS_SHARED + | B_FS_SUPPORTS_NODE_MONITORING; + + if (fFileSystem->NamedAttrs() + || fFileSystem->GetConfiguration().fEmulateNamedAttrs) + fInfoCache.flags |= B_FS_HAS_MIME | B_FS_HAS_ATTR; + strncpy(fInfoCache.volume_name, fName, B_FILE_NAME_LENGTH); fInfoCacheExpire = time(NULL) + MetadataCache::kExpirationTime;