1 |
786 |
skrzyp |
#ifndef CYGONCE_IO_FILEIO_INODE_H
|
2 |
|
|
#define CYGONCE_IO_FILEIO_INODE_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// inode.h
|
6 |
|
|
//
|
7 |
|
|
// Header describing eCos inodes
|
8 |
|
|
//
|
9 |
|
|
//=============================================================================
|
10 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): jlarmour
|
45 |
|
|
// Contributors:
|
46 |
|
|
// Date: 2002-01-18
|
47 |
|
|
// Purpose: Describe inodes
|
48 |
|
|
// Description: This header contains the definitions that may be useful to a
|
49 |
|
|
// filesystem implementation with the concept of inodes.
|
50 |
|
|
// There should remain no *requirement* for a FS to use inodes.
|
51 |
|
|
// Instead these are just useful functions and definitions.
|
52 |
|
|
//
|
53 |
|
|
// Usage:
|
54 |
|
|
// #include <cyg/fileio/inode.h>
|
55 |
|
|
// ...
|
56 |
|
|
//
|
57 |
|
|
//
|
58 |
|
|
//####DESCRIPTIONEND####
|
59 |
|
|
//
|
60 |
|
|
//=============================================================================
|
61 |
|
|
|
62 |
|
|
#include <cyg/infra/cyg_type.h>
|
63 |
|
|
#include <sys/types.h>
|
64 |
|
|
#include <time.h> // time_t
|
65 |
|
|
#include <cyg/fileio/fileio.h>
|
66 |
|
|
#include <cyg/io/io.h>
|
67 |
|
|
#include <limits.h>
|
68 |
|
|
|
69 |
|
|
// some members are named for compatibility for Linux inodes
|
70 |
|
|
typedef struct CYG_INODE_TAG {
|
71 |
|
|
cyg_uint32 i_ino; // inode number
|
72 |
|
|
mode_t i_mode; // mode
|
73 |
|
|
nlink_t i_nlink; // number of (hard) links
|
74 |
|
|
uid_t i_uid; // UID
|
75 |
|
|
gid_t i_gid; // GID
|
76 |
|
|
cyg_io_handle_t i_device; // underlying device
|
77 |
|
|
off_t i_size; // file size
|
78 |
|
|
time_t i_atime; // file access time
|
79 |
|
|
time_t i_mtime; // file modification time
|
80 |
|
|
time_t i_ctime; // file metadata change time
|
81 |
|
|
struct CYG_INODE_TAG *i_parent; // parent inode
|
82 |
|
|
|
83 |
|
|
// these duplicate the contents of a cyg_file, but that's okay
|
84 |
|
|
cyg_mtab_entry* i_mte; // mount table entry
|
85 |
|
|
struct CYG_FILEOPS_TAG *i_fop; // file operations
|
86 |
|
|
|
87 |
|
|
// inode cache related members
|
88 |
|
|
cyg_atomic i_count; // number of references to this inode
|
89 |
|
|
struct CYG_INODE_TAG *i_cache_prev; // previous in icache
|
90 |
|
|
struct CYG_INODE_TAG *i_cache_next; // next in icache
|
91 |
|
|
|
92 |
|
|
// This allows us to use a GCC extension to extend the size as appropriate
|
93 |
|
|
// for individual FS's requirements.
|
94 |
|
|
// Obviously anything here cannot be shared between FSs.
|
95 |
|
|
CYG_ADDRWORD i_private[];
|
96 |
|
|
} cyg_inode;
|
97 |
|
|
|
98 |
|
|
// There should be one cyg_inodecache per FS instance (to preserve inode number
|
99 |
|
|
// uniqueness)
|
100 |
|
|
typedef void (*cyg_inodecache_freecallback_t)( cyg_inode *);
|
101 |
|
|
typedef struct {
|
102 |
|
|
cyg_inode *head;
|
103 |
|
|
#if CYGNUM_IO_FILEIO_MAX_INODE_CACHE_DEAD > 0
|
104 |
|
|
cyg_inode *freeable;
|
105 |
|
|
cyg_atomic freeablelistlen;
|
106 |
|
|
#endif
|
107 |
|
|
cyg_inodecache_freecallback_t freecallback;
|
108 |
|
|
size_t privatespace;
|
109 |
|
|
// should be some locking eventually
|
110 |
|
|
} cyg_inodecache;
|
111 |
|
|
|
112 |
|
|
static __inline__ int
|
113 |
|
|
cyg_inodecache_init( cyg_inodecache *ic, size_t extraprivatespace,
|
114 |
|
|
cyg_inodecache_freecallback_t freecb )
|
115 |
|
|
{
|
116 |
|
|
ic->head = NULL;
|
117 |
|
|
#if CYGNUM_IO_FILEIO_MAX_INODE_CACHE_DEAD > 0
|
118 |
|
|
ic->freeable = NULL;
|
119 |
|
|
ic->freeablelistlen = 0;
|
120 |
|
|
#endif
|
121 |
|
|
ic->privatespace = extraprivatespace;
|
122 |
|
|
ic->freecallback = freecb;
|
123 |
|
|
return 0;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
// Create an inode, with extra private space. Returns NULL on error.
|
127 |
|
|
__externC cyg_inode *
|
128 |
|
|
cyg_inode_create( cyg_inodecache *ic );
|
129 |
|
|
|
130 |
|
|
__externC cyg_inode *
|
131 |
|
|
cyg_inode_get( cyg_inodecache *ic, cyg_uint32 ino );
|
132 |
|
|
|
133 |
|
|
__externC void
|
134 |
|
|
cyg_inode_put( cyg_inodecache *ic, cyg_inode *ino );
|
135 |
|
|
|
136 |
|
|
__externC void
|
137 |
|
|
cyg_inodecache_destroy( cyg_inodecache *ic );
|
138 |
|
|
|
139 |
|
|
#endif // CYGONCE_IO_FILEIO_INODE_H
|
140 |
|
|
|
141 |
|
|
// EOF inode.h
|