Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

Commit f0e5e8e

Browse files
committed
delete old vfs(fs.c)
1 parent 91c4959 commit f0e5e8e

9 files changed

Lines changed: 213 additions & 509 deletions

File tree

src/kernel/fs/fat/fat16.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,25 @@ int fat16_get_file_size(struct fat16_super *sb, const char *name,
483483
return 0;
484484
}
485485

486+
int fat16_is_dir(struct fat16_super *sb, const char *path) {
487+
if (!sb || !path)
488+
return 0;
489+
if (path[0] == '/' && (path[1] == '\0' || path[1] == '/'))
490+
return 1; /* root */
491+
uint8_t *ent = NULL;
492+
uint8_t *free_slot = NULL;
493+
uint16_t parent = 0;
494+
if (path[0] == '/') {
495+
resolve_path(sb, path, &ent, &free_slot, &parent);
496+
} else {
497+
find_root_entry(sb, path, &ent, &free_slot);
498+
}
499+
if (!ent)
500+
return 0;
501+
uint8_t attr = ent[11];
502+
return (attr & 0x10) ? 1 : 0;
503+
}
504+
486505
/* ルートディレクトリ内のエントリ位置を探す (見つかれば ent_out にポインタを返す) */
487506
static uint8_t *find_root_entry(struct fat16_super *sb, const char *name,
488507
uint8_t **ent_out, uint8_t **free_out) {

src/kernel/fs/fat/fat16.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ int fat16_get_file_size(struct fat16_super *sb, const char *name,
2929
int fat16_write_file(struct fat16_super *sb, const char *name, const void *buf,
3030
size_t len);
3131
int fat16_create_file(struct fat16_super *sb, const char *name);
32+
int fat16_is_dir(struct fat16_super *sb, const char *path);
3233

3334
#endif

0 commit comments

Comments
 (0)