/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "file_system_struct.h" #include #include #include #include #include #include #include /* Les noms de systemes de fichiers doivent etre plus courts que cette limite. */ #define FILESYSTEM_NAME_MAX 32 extern const struct file_system_struct rootfs; extern const struct file_system_struct devfs; extern const struct file_system_struct procfs; extern const struct file_system_struct vfat; extern const struct file_system_struct ramfs; /* table des systemes de fichiers */ static const struct file_system_struct *file_system_table[] = { &rootfs, &devfs, &procfs, &vfat, &ramfs }; static const unsigned int file_system_table_size = sizeof file_system_table / sizeof *file_system_table; /* Fontions utilitaires */ static inline int fs_strcmp(const char *fs_s1, const char *s2) { char c; while ((c = get_fs_byte(fs_s1)) && c == *s2) fs_s1++, s2++; return c - *s2; } /* file_systems */ int get_file_system(const char *fs_type, const struct file_system_struct **file_system) { const struct file_system_struct **fs; if (!verify_str(fs_type, FILESYSTEM_NAME_MAX, NULL)) return -EFAULT; for (fs = &file_system_table[0]; fs < &file_system_table[file_system_table_size]; fs++) if (!fs_strcmp(fs_type, (*fs)->name)) { *file_system = *fs; return 0; } return -ENODEV; } /* procfs */ int print_file_systems(char *buf, unsigned int size) { char *s; const struct file_system_struct **fs; unsigned int n; s = buf; for (fs = &file_system_table[0]; fs < &file_system_table[file_system_table_size]; fs++) { n = snprintf(s, size, "%-8s%s\n", (*fs)->type == FT_BLK ? "" : "nodev", (*fs)->name); s += n; size = size > n ? size - n : 0; } return s - buf; }