summaryrefslogtreecommitdiff
path: root/ulfs.h
blob: 532e3c746cab1186aef8b43795bab54efa8b851c (plain)
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
/* Hurd unionfs
   Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
   Written by Moritz Schulte <moritz@duesseldorf.ccc.de>.

   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 2 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, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.  */

/* Underlying filesystem management.  */

#ifndef INCLUDED_ULFS_H
#define INCLUDED_ULFS_H

/* The structure for each registered underlying filesystem.  */
typedef struct ulfs
{
  char *path;
  int flags;
  int priority;
  struct ulfs *next, *prev;
} ulfs_t;

/* Flags.  */

/* The according ulfs is marked writable.  */
#define FLAG_ULFS_WRITABLE 0x00000001

/* The start of the ulfs chain.  */
extern ulfs_t *ulfs_chain_start;

/* The end of the ulfs chain, we need this, to go through the chain in
   reversed order.  */
extern ulfs_t *ulfs_chain_end;

/* Number of registered underlying filesystems.  */
extern unsigned int ulfs_num;

/* The lock protecting the ulfs data structures.  */
extern struct mutex ulfs_lock;

/* Register a new underlying filesystem.  */
error_t ulfs_register (char *path, int flags, int priority);

/* Unregister an underlying filesystem.  */
error_t ulfs_unregister (char *path);

/* Get an ULFS element by it's index.  */
error_t ulfs_get_num (int num, ulfs_t **ulfs);

/* Removes invalid ulfs entries.  */
void ulfs_check (void);

#define ulfs_iterate                             \
  for (ulfs_t *ulfs = (mutex_lock (&ulfs_lock),  \
		       ulfs_chain_start);          \
       ulfs || (mutex_unlock (&ulfs_lock), 0);   \
       ulfs = ulfs->next) 

#define ulfs_iterate_unlocked                    \
  for (ulfs_t *ulfs = ulfs_chain_start;            \
       ulfs;                                     \
       ulfs = ulfs->next)

#endif