1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
* Copyright (c) 1997, 1998, 1999 The University of Utah and the Flux Group.
*
* This file is part of the OSKit Linux Glue Libraries, which are free
* software, also known as "open source;" you can redistribute them and/or
* modify them under the terms of the GNU General Public License (GPL),
* version 2, as published by the Free Software Foundation (FSF).
*
* The OSKit 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 GPL for more details. You should have
* received a copy of the GPL along with the OSKit; see the file COPYING. If
* not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA.
*/
/*
* The definitions of types derived from the oskit_filesystem_t,
* oskit_file_t, oskit_dir_t, types.
* They are prefixed with a `g' for `glue'.
*/
#ifndef _LINUX_FS_TYPES_H_
#define _LINUX_FS_TYPES_H_
#include <oskit/fs/filesystem.h>
#include <oskit/fs/file.h>
#include <oskit/fs/dir.h>
#include <oskit/fs/openfile.h>
#include <oskit/io/absio.h>
#include <linux/fs.h>
/*
* Our filesystem representation, "inherited" from oskit_filesystem_t.
*/
struct gfilesystem {
oskit_filesystem_t fsi; /* COM filesystem inteface */
unsigned count; /* ref count */
struct super_block *sb; /* Linux super block representation */
};
typedef struct gfilesystem gfilesystem_t;
/*
* This is to emphasize that gdir_t is a subset of gfile_t.
*/
#define __COMMON_FILE_GLUE \
oskit_absio_t absioi; /* COM absio interface */ \
unsigned count; /* ref count */ \
struct dentry *dentry; /* Linux cache entry */ \
gfilesystem_t *fs; /* containing filesytem */
/*
* Our file representation, "inherited" from oskit_file_t.
*/
struct gfile {
oskit_file_t filei; /* COM file interface */
__COMMON_FILE_GLUE
};
typedef struct gfile gfile_t;
extern oskit_error_t gfile_create(gfilesystem_t *fs, struct dentry *dentry,
gfile_t **out_file);
/*
* Our directory representation, "inherited" from oskit_dir_t.
* This must be a subset of gfile_t.
*/
struct gdir {
oskit_dir_t diri; /* COM directory interface */
__COMMON_FILE_GLUE
oskit_dir_t *vparent; /* virtual parent dir; NULL if
haven't been reparented */
};
typedef struct gdir gdir_t;
/*
* Our openfile representation, "inherited" from oskit_openfile_t.
*/
struct gopenfile {
oskit_openfile_t ofilei; /* COM openfile interface */
oskit_absio_t absioi; /* COM absio interface */
unsigned count; /* ref count */
gfile_t *gf; /* associated gfile */
struct file *filp; /* Linux file representation */
};
typedef struct gopenfile gopenfile_t;
extern oskit_error_t gopenfile_create(gfile_t *file, struct file *f,
gopenfile_t **out_openfile);
/*
* Handy macros for testing objects.
*/
#define VERIFY_OR_PANIC(obj, name) ({ \
if ((obj) == NULL) \
panic(__FUNCTION__": null " #name); \
if ((obj)->count == 0) \
panic(__FUNCTION__": bad count"); \
})
#define VERIFY1(obj, non_null_data) ({ \
if ((obj) == NULL || (obj)->count == 0 || (non_null_data) == NULL) \
return OSKIT_E_INVALIDARG; \
})
#define VERIFY2(obj, non_null_data1, non_null_data2) ({ \
if ((obj) == NULL || (obj)->count == 0 || \
(non_null_data1) == NULL || (non_null_data2) == NULL) \
return OSKIT_E_INVALIDARG; \
})
#endif /* _LINUX_FS_TYPES_H_ */
|