ext2: add ability to create files
This commit is contained in:
parent
9bcd121d36
commit
19f32aef3f
7 changed files with 357 additions and 11 deletions
27
fs/vfs.c
27
fs/vfs.c
|
|
@ -248,3 +248,30 @@ void vfs_init(const char *rootdev_name)
|
|||
/* init file descriptor slab */
|
||||
fd_slab = slab_create(sizeof(struct file_descriptor), 16 * KB, 0);
|
||||
}
|
||||
|
||||
char *basename(char *path)
|
||||
{
|
||||
char *ret = path;
|
||||
for (int i = 0; path[i]; i++) {
|
||||
if (path[i] == '/')
|
||||
ret = path + i + 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *dirname(char *path)
|
||||
{
|
||||
char *ret = path;
|
||||
for (int i = 0; path[i]; i++) {
|
||||
if (path[i] == '/')
|
||||
ret = path + i;
|
||||
}
|
||||
|
||||
if (ret == path)
|
||||
return NULL;
|
||||
|
||||
*ret = 0;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue