vfs: add FILE_NAME_MAX_LEN
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
841c00fad1
commit
f9a94f76dc
2 changed files with 6 additions and 4 deletions
|
|
@ -45,11 +45,11 @@ static int next_level(const char *path, dirent_t *dent, dirent_t **out_dirent)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
char *build = kzalloc(256, ALLOC_KERN);
|
char *build = kzalloc(FILE_NAME_MAX_LEN + 1, ALLOC_KERN);
|
||||||
if (!build)
|
if (!build)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (int i = 0; i < 255; i++) {
|
for (int i = 0; i < FILE_NAME_MAX_LEN; i++) {
|
||||||
char c = path[i];
|
char c = path[i];
|
||||||
|
|
||||||
if (c == '/' || c == '\0') {
|
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;
|
inode_t *ino = parent->inode;
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
if (len > 255)
|
if (len > FILE_NAME_MAX_LEN)
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
|
|
||||||
if ((ino->mode & S_IFMT) != S_IFDIR)
|
if ((ino->mode & S_IFMT) != S_IFDIR)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include <lib/rwlock.h>
|
#include <lib/rwlock.h>
|
||||||
#include <lib/list.h>
|
#include <lib/list.h>
|
||||||
|
|
||||||
|
#define FILE_NAME_MAX_LEN 255
|
||||||
|
|
||||||
#define S_IFMT 0xF000
|
#define S_IFMT 0xF000
|
||||||
#define S_IFREG 0x8000
|
#define S_IFREG 0x8000
|
||||||
#define S_IFDIR 0x4000
|
#define S_IFDIR 0x4000
|
||||||
|
|
@ -30,7 +32,7 @@
|
||||||
#define FS_RDONLY 0x00000001
|
#define FS_RDONLY 0x00000001
|
||||||
|
|
||||||
struct fs_driver {
|
struct fs_driver {
|
||||||
char name[256];
|
char name[FILE_NAME_MAX_LEN + 1];
|
||||||
int (*init)(int flags, inode_t *inode, fs_t **out);
|
int (*init)(int flags, inode_t *inode, fs_t **out);
|
||||||
int (*deinit)(fs_t *fs);
|
int (*deinit)(fs_t *fs);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue