/* Pilote de systeme de fichiers FAT */ /* 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 . */ /* Code teste uniquement avec une disquette de 1,44 Mo. En particulier, * la FAT32 est non testee. */ /* Le pilote est actuellement limite aux volumes de 128 Go. */ #include "file_system_struct.h" #include "vfat_instance.h" #include "vfat_instance_struct.h" #include "device_struct.h" #include #include #include #include #include /* vfat */ static int vfat_mount(const struct device_struct *device, void **data) { int retval; if (!(*data = kmalloc(sizeof (struct vfat_instance_struct)))) { retval = -ENOMEM; goto error; } if ((retval = vfat_instance_init(*data, device)) < 0) goto error_free; return 0; error_free: kfree(*data, sizeof (struct vfat_instance_struct)); error: return retval; } static void vfat_umount(void *data) { vfat_instance_destroy(data); kfree(data, sizeof (struct vfat_instance_struct)); } static int vfat_find(void *data, unsigned long dir_id, const char *fs_basename, unsigned long *id, int *type) { return vfat_instance_find(data, dir_id, fs_basename, id, type); } static int vfat_get_name(void *data, unsigned long id, char name[]) { return vfat_instance_get_name(data, id, name); } static int vfat_get_size(void *data, unsigned long reg_id, unsigned long *size) { return vfat_instance_get_size(data, reg_id, size); } static int vfat_stat(void *data, unsigned long id, struct stat_struct *fs_buf) { return vfat_instance_stat(data, id, fs_buf); } static int vfat_read_dir(void *data, unsigned long dir_id, unsigned long pos, char *fs_buf, unsigned int count) { return vfat_instance_read_dir(data, dir_id, pos, fs_buf, count); } static int vfat_read(void *data, unsigned long leaf_id, unsigned long pos, char *fs_buf, unsigned int count) { return vfat_instance_read(data, leaf_id, pos, fs_buf, count); } static int vfat_write(void *data, unsigned long leaf_id, unsigned long pos, const char *fs_buf, unsigned int count) { return vfat_instance_write(data, leaf_id, pos, fs_buf, count); } static int vfat_create(void *data, unsigned long dir_id, const char *fs_basename) { return vfat_instance_create(data, dir_id, fs_basename); } static int vfat_mkdir(void *data, unsigned long dir_id, const char *fs_basename) { return vfat_instance_mkdir(data, dir_id, fs_basename); } static int vfat_can_remove(void *data, unsigned long leaf_id) { return vfat_instance_can_remove(data, leaf_id); } static int vfat_remove(void *data, unsigned long leaf_id, unsigned long parent_dir_id) { return vfat_instance_remove(data, leaf_id, parent_dir_id); } static int vfat_rmdir(void *data, unsigned long dir_id, unsigned long parent_dir_id) { return vfat_instance_rmdir(data, dir_id, parent_dir_id); } static int vfat_rename(void *data, unsigned long old_id, unsigned long old_parent_dir_id, unsigned long new_dir_id, const char *fs_basename) { return vfat_instance_rename(data, old_id, old_parent_dir_id, new_dir_id, fs_basename); } const struct file_system_struct vfat = { .name = "vfat", .type = FT_BLK, .mount = vfat_mount, .umount = vfat_umount, .find = vfat_find, .get_name = vfat_get_name, .get_device = NULL, .get_size = vfat_get_size, .stat = vfat_stat, .read_dir = vfat_read_dir, .read = vfat_read, .write = vfat_write, .ioctl = NULL, .create = vfat_create, .mkdir = vfat_mkdir, .can_remove = vfat_can_remove, .remove = vfat_remove, .rmdir = vfat_rmdir, .rename = vfat_rename };