Fix mkdir not to overwrite an existing dir

This commit is contained in:
Gary Talent 2017-07-02 00:42:48 -05:00
parent 57fe7aafc5
commit afe2148a17

View File

@ -368,8 +368,12 @@ int FileSystemTemplate<FileStore, FS_TYPE>::stripDirectories() {
template<typename FileStore, FsType FS_TYPE>
int FileSystemTemplate<FileStore, FS_TYPE>::mkdir(const char *path) {
Directory<typename FileStore::InodeId_t, typename FileStore::FsSize_t> dir;
return write(path, &dir, sizeof(dir), FileType::FileType_Directory);
if (!stat(path).inode) {
Directory<typename FileStore::InodeId_t, typename FileStore::FsSize_t> dir;
return write(path, &dir, sizeof(dir), FileType::FileType_Directory);
} else {
return 1;
}
}
template<typename FileStore, FsType FS_TYPE>