]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - shlibs/mount/src/mountP.h
2 * mountP.h - private library header file
4 * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
6 * This file may be redistributed under the terms of the
7 * GNU Lesser General Public License.
10 #ifndef _LIBMOUNT_PRIVATE_H
11 #define _LIBMOUNT_PRIVATE_H
13 #include <sys/types.h>
17 #define USE_UNSTABLE_LIBMOUNT_API
23 #define CONFIG_LIBMOUNT_ASSERT
24 #define CONFIG_LIBMOUNT_DEBUG
26 #ifdef CONFIG_LIBMOUNT_ASSERT
33 #if defined(TEST_PROGRAM) && !defined(LIBMOUNT_DEBUG)
34 #define CONFIG_LIBMOUNT_DEBUG
37 #define MNT_DEBUG_INIT (1 << 1)
38 #define MNT_DEBUG_CACHE (1 << 2)
39 #define MNT_DEBUG_OPTIONS (1 << 3)
40 #define MNT_DEBUG_LOCKS (1 << 4)
41 #define MNT_DEBUG_TAB (1 << 5)
42 #define MNT_DEBUG_FS (1 << 6)
43 #define MNT_DEBUG_OPTS (1 << 7)
44 #define MNT_DEBUG_UPDATE (1 << 8)
45 #define MNT_DEBUG_UTILS (1 << 9)
46 #define MNT_DEBUG_CXT (1 << 10)
47 #define MNT_DEBUG_ALL 0xFFFF
49 #ifdef CONFIG_LIBMOUNT_DEBUG
53 # define DBG(m,x) do { \
54 if ((MNT_DEBUG_ ## m) & libmount_debug_mask) {\
55 fprintf(stderr, "libmount: %s: ", # m); \
60 extern int libmount_debug_mask
;
62 static inline void mnt_debug(const char *mesg
, ...)
66 vfprintf(stderr
, mesg
, ap
);
71 static inline void mnt_debug_h(void *handler
, const char *mesg
, ...)
75 fprintf(stderr
, "[%p]: ", handler
);
77 vfprintf(stderr
, mesg
, ap
);
82 #else /* !CONFIG_LIBMOUNT_DEBUG */
86 /* extension for files in the /etc/fstab.d directory */
87 #define MNT_MNTTABDIR_EXT ".fstab"
89 /* library private paths */
90 #define MNT_PATH_RUNDIR "/var/run/mount"
91 #define MNT_PATH_MOUNTINFO MNT_PATH_RUNDIR "/mountinfo"
96 int (*body
)(struct mtest
*ts
, int argc
, char *argv
[]);
101 extern int mnt_run_test(struct mtest
*tests
, int argc
, char *argv
[]);
105 extern char *mnt_getenv_safe(const char *arg
);
106 extern int endswith(const char *s
, const char *sx
);
107 extern int startswith(const char *s
, const char *sx
);
109 extern char *mnt_get_username(const uid_t uid
);
110 extern int mnt_get_uid(const char *username
, uid_t
*uid
);
111 extern int mnt_get_gid(const char *groupname
, gid_t
*gid
);
112 extern int mnt_in_group(gid_t gid
);
114 extern int mnt_has_regular_mtab(void);
116 extern char *mnt_get_mountpoint(const char *path
);
117 extern char *mnt_get_fs_root(const char *path
, const char *mountpoint
);
123 struct list_head
*p
; /* current position */
124 struct list_head
*head
; /* start position */
125 int direction
; /* MNT_ITER_{FOR,BACK}WARD */
128 #define IS_ITER_FORWARD(_i) ((_i)->direction == MNT_ITER_FORWARD)
129 #define IS_ITER_BACKWARD(_i) ((_i)->direction == MNT_ITER_BACKWARD)
131 #define MNT_ITER_INIT(itr, list) \
133 (itr)->p = IS_ITER_FORWARD(itr) ? \
134 (list)->next : (list)->prev; \
135 (itr)->head = (list); \
138 #define MNT_ITER_ITERATE(itr, res, restype, member) \
140 res = list_entry((itr)->p, restype, member); \
141 (itr)->p = IS_ITER_FORWARD(itr) ? \
142 (itr)->p->next : (itr)->p->prev; \
147 * This struct represents one entry in mtab/fstab/mountinfo file.
150 struct list_head ents
;
152 int id
; /* mountinfo[1]: ID */
153 int parent
; /* moutninfo[2]: parent */
154 dev_t devno
; /* moutninfo[3]: st_dev */
156 char *source
; /* fstab[1]: mountinfo[10]:
157 * source dev, file, dir or TAG */
158 char *tagname
; /* fstab[1]: tag name - "LABEL", "UUID", ..*/
159 char *tagval
; /* tag value */
161 char *root
; /* mountinfo[4]: root of the mount within the FS */
162 char *target
; /* mountinfo[5], fstab[2]: mountpoint */
163 char *fstype
; /* mountinfo[9], fstab[3]: filesystem type */
165 char *optstr
; /* mountinfo[6,11], fstab[4]: option string */
166 char *vfs_optstr
; /* mountinfo[6]: fs-independent (VFS) options */
167 char *fs_optstr
; /* mountinfo[11]: fs-depend options */
169 int freq
; /* fstab[5]: dump frequency in days */
170 int passno
; /* fstab[6]: pass number on parallel fsck */
172 int flags
; /* MNT_FS_* flags */
174 void *userdata
; /* library independent data */
180 #define MNT_FS_PSEUDO (1 << 1) /* pseudo filesystem */
181 #define MNT_FS_NET (1 << 2) /* network filesystem */
182 #define MNT_FS_SWAP (1 << 3) /* swap device */
185 * mtab/fstab/mountinfo file
188 int fmt
; /* MNT_FMT_* file format */
189 int nents
; /* number of valid entries */
191 mnt_cache
*cache
; /* canonicalized paths/tags cache */
193 int (*errcb
)(mnt_tab
*tb
, const char *filename
,
196 struct list_head ents
; /* list of entries (mentry) */
201 extern const struct mnt_optmap
*mnt_optmap_get_entry(struct mnt_optmap
const **maps
,
202 int nmaps
, const char *name
,
203 size_t namelen
, const struct mnt_optmap
**mapent
);
204 extern int mnt_optmap_enum_to_number(const struct mnt_optmap
*mapent
,
205 const char *rawdata
, size_t len
);
206 extern const char *mnt_optmap_get_type(const struct mnt_optmap
*mapent
);
207 extern int mnt_optmap_require_value(const struct mnt_optmap
*mapent
);
210 extern int mnt_optstr_remove_option_at(char **optstr
, char *begin
, char *end
);
213 extern int __mnt_fs_set_source_ptr(mnt_fs
*fs
, char *source
);
214 extern int __mnt_fs_set_fstype_ptr(mnt_fs
*fs
, char *fstype
);
215 extern int __mnt_fs_set_optstr_ptr(mnt_fs
*fs
, char *optstr
, int split
);
216 extern int __mnt_fs_set_optstr(mnt_fs
*fs
, const char *optstr
, int split
);
218 #endif /* _LIBMOUNT_PRIVATE_H */