/* 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 . */
#ifndef FILE_STRUCT_H
#define FILE_STRUCT_H
#include
#include
/* Un fichier ayant une entree dans l'arborescence est uniquement determine par
* son instance de systeme de fichiers et son id. La racine est le seul fichier
* egal a son parent.
* Les tubes n'ont pas d'entree dans l'arborescence.
* Lorsqu'un systeme de fichiers est monte sur un repertoire, il masque le
* systeme de fichier definissant le repertoire. Ce dernier est memorise dans
* le champ master_file_system_instance. */
/* La classification logique des fichiers est la suivante :
*
* file
* node
* dir (FT_DIR)
* leaf
* reg (FT_REG)
* spec
* block (FT_BLK)
* char (FT_CHR)
* pipe (FT_PIPE)
*/
struct file_struct;
struct stat_struct;
struct device_struct;
struct file_operations_struct {
int (*read)(struct file_struct *, unsigned long, char *, unsigned int);
int (*write)(struct file_struct *, unsigned long, const char *, unsigned int);
long (*seek)(const struct file_struct *, unsigned long, long, int);
int (*stat)(const struct file_struct *, struct stat_struct *);
int (*ioctl)(const struct file_struct *, int, void *);
union {
/* fichiers ayant une entree dans l'arborescence */
struct {
int (*get_device)(const struct file_struct *, struct device_struct **);
};
};
};
struct file_struct {
const struct file_operations_struct *file_operations;
union {
/* fichiers ayant une entree dans l'arborescence */
struct {
unsigned int count; /* nombre de references */
int write_access_count; /* nombre d'acces en ecriture */
struct mapping_struct mapping; /* projection en memoire */
struct file_struct *parent; /* repertoire parent */
struct file_struct *next_entry; /* prochaine entree de meme parent */
struct file_system_instance_struct *file_system_instance; /* systeme de fichiers operant */
unsigned long id; /* identifiant dans le systeme de fichier */
int is_dir; /* indicateur de repertoire */
union {
/* repertoires */
struct {
struct file_struct *first_entry; /* premiere entree */
struct file_system_instance_struct *master_file_system_instance; /* systeme de fichier proprietaire */
};
/* fichiers reguliers, fichiers speciaux */
struct {
unsigned to_remove : 1; /* indicateur de suppression */
};
};
};
/* tubes */
struct {
unsigned int read_count;
unsigned int write_count;
char *buffer; /* tampon */
unsigned long size; /* taille des donnees dans le tampon */
long mtime; /* heure de dernier acces en ecriture */
struct condition_struct condition; /* condition pour la communication inter-processus */
};
};
};
#endif