Lumiera  0.pre.03
»edityourfreedom«
filedescriptor.h
Go to the documentation of this file.
1 /*
2  FILEDESCRIPTOR.h - file handling
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 
22 
28 #ifndef BACKEND_FILEDESCRIPTOR_H
29 #define BACKEND_FILEDESCRIPTOR_H
30 
31 #include "lib/mutex.h"
32 #include "lib/rwlock.h"
33 #include "lib/psplay.h"
34 #include "lib/llist.h"
35 
36 
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <fcntl.h>
40 
41 typedef struct lumiera_filedescriptor_struct lumiera_filedescriptor;
42 typedef lumiera_filedescriptor* LumieraFiledescriptor;
43 
44 
45 #include "backend/filehandle.h"
46 #include "backend/file.h"
47 #include "backend/mmapings.h"
48 
49 
51 {
53  psplaynode node;
54 
56  struct stat stat;
57 
62  off_t realsize;
63 
65  int flags;
66 
68  lumiera_mutex lock;
69 
72 
75 
77  llist files;
78 
80  lumiera_rwlock filelock;
81 
83  int lock_cnt;
84  RESOURCE_USER (filelock_rh);
85 };
86 
87 
95 lumiera_filedescriptor_acquire (const char* name, int flags, LList filenode);
96 
97 
103 void
104 lumiera_filedescriptor_release (LumieraFiledescriptor self, const char* name, LList filenode);
105 
106 int
108 
109 void
111 
112 const char*
114 
115 int
117 
118 int
120 
128 
134 void
136 
137 
138 
141 
142 
145 
146 
149 
150 
151 
152 
153 #endif /*BACKEND_FILEDESCRIPTOR_H*/
int lumiera_filedescriptor_handle_acquire(LumieraFiledescriptor self)
LumieraFiledescriptor lumiera_filedescriptor_wrlock(LumieraFiledescriptor self)
lumiera_mutex lock
locks operations on this file descriptor
LumieraMMapings mmapings
established memory mappings
File management.
psplaynode node
node for the lookup tree
int lumiera_filedescriptor_samestat(LumieraFiledescriptor self, struct stat *stat)
lumiera_filehandle * LumieraFilehandle
Definition: filehandle.h:38
void lumiera_filedescriptor_delete(LumieraFiledescriptor self, const char *name)
Delete a filedescriptor Called whenever its reference count drops to zero.
Manage the mmap objects of a file.
const char * lumiera_filedescriptor_name(LumieraFiledescriptor self)
llist files
list of all attached &#39;file&#39; structures, that are the names of the files
LumieraFiledescriptor lumiera_filedescriptor_rdlock(LumieraFiledescriptor self)
void lumiera_filedescriptor_release(LumieraFiledescriptor self, const char *name, LList filenode)
Release a filedescriptor.
Probabilistic splay tree.
int lumiera_filedescriptor_flags(LumieraFiledescriptor self)
Filehandles manage the underlying POSIX filehandle for a file descriptor.
lumiera_rwlock filelock
file locking, a rwlock for thread locking
struct stat stat
create after first open, maintained metadata
Mutual exclusion locking, header.
lumiera_filedescriptor * LumieraFiledescriptor
LumieraFilehandle handle
Associated posix filehandle.
Intrusive cyclic double linked list There is only one node type which contains a forward and a backwa...
LumieraFiledescriptor lumiera_filedescriptor_acquire(const char *name, int flags, LList filenode)
Find existing filedescriptor or create one.
lumiera_mmapings * LumieraMMapings
Definition: mmapings.h:35
LumieraFiledescriptor lumiera_filedescriptor_new(LumieraFiledescriptor template)
Allocate a new filedescriptor cloned from a template.
LumieraFiledescriptor lumiera_filedescriptor_unlock(LumieraFiledescriptor self)
void lumiera_filedescriptor_handle_release(LumieraFiledescriptor self)
int flags
open flags, must be masked for reopen
Read/write locks, header.
int lock_cnt
readlock counter for releasing the file lock, -1 for write lock, 0 = unlocked
off_t realsize
files which are written are rounded up to the next chunk boundary by the mmaping backend and will be ...
llist * LList
Definition: llist.h:91