diff --git a/fs/vfs/vfs.c b/fs/vfs/vfs.c index f7428b1..9ad19c7 100644 --- a/fs/vfs/vfs.c +++ b/fs/vfs/vfs.c @@ -45,11 +45,11 @@ static int next_level(const char *path, dirent_t *dent, dirent_t **out_dirent) return -EINVAL; int res; - char *build = kzalloc(256, ALLOC_KERN); + char *build = kzalloc(FILE_NAME_MAX_LEN + 1, ALLOC_KERN); if (!build) return -ENOMEM; - for (int i = 0; i < 255; i++) { + for (int i = 0; i < FILE_NAME_MAX_LEN; i++) { char c = path[i]; if (c == '/' || c == '\0') { @@ -174,7 +174,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t inode_t *ino = parent->inode; size_t len = strlen(name); - if (len > 255) + if (len > FILE_NAME_MAX_LEN) return -ENAMETOOLONG; if ((ino->mode & S_IFMT) != S_IFDIR) diff --git a/include/fs/vfs.h b/include/fs/vfs.h index 0880061..d9e04fe 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -8,6 +8,8 @@ #include #include +#define FILE_NAME_MAX_LEN 255 + #define S_IFMT 0xF000 #define S_IFREG 0x8000 #define S_IFDIR 0x4000 @@ -30,7 +32,7 @@ #define FS_RDONLY 0x00000001 struct fs_driver { - char name[256]; + char name[FILE_NAME_MAX_LEN + 1]; int (*init)(int flags, inode_t *inode, fs_t **out); int (*deinit)(fs_t *fs); };