Реализация базовой c Linux файловой системы в C с использованием связанных списков - PullRequest
0 голосов
/ 14 марта 2020

У меня есть 2 структуры для реализации файловой системы, которую я не могу изменить, за исключением части TODO (запрошено в моей домашней работе)

структура для каталогов:

 typedef struct Directory {
char *name;

// TODO: The list of files of the current directory
File *fileList;
// TODO: The list of directories of the current directory
Directory *dirList;
// The parent directory of the current directory (NULL for the root directory)
struct Directory *parentDir;
} Directory;

и один для файлов:

typedef struct File {
// The name of the file
char *name;

// The size of the file
int size;

// The content of the file
char *data;

// The directory in which the file is located
Directory *dir;
} File;

У меня вопрос: как мне сохранить ссылки на мои файлы и каталоги, чтобы они были связаны, поскольку у меня нет указателя File/Directory *next в моих структурах? Я определяю различные структуры, в которых я храню свои ссылки? Я извиняюсь, если это глупый вопрос, но я что-то здесь серьезно упускаю.

...