]> git.ipfire.org Git - thirdparty/util-linux.git/blame - shlibs/mount/src/fs.c
findmnt: add support for fs-root (subvolumes and bind mounts)
[thirdparty/util-linux.git] / shlibs / mount / src / fs.c
CommitLineData
d115ee9b
KZ
1/*
2 * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
3 *
4 * This file may be redistributed under the terms of the
5 * GNU Lesser General Public License.
d115ee9b
KZ
6 */
7
192c6aad
KZ
8/**
9 * SECTION: fs
10 * @title: Filesystem
3d735589 11 * @short_description: mnt_fs represents one entry in fstab/mtab/mountinfo
192c6aad
KZ
12 *
13 */
d115ee9b
KZ
14#include <stdio.h>
15#include <string.h>
16#include <stdlib.h>
17#include <ctype.h>
3fca8422 18#include <errno.h>
8e368761 19#include <blkid.h>
9ecdf48f 20#include <stddef.h>
d115ee9b
KZ
21
22#include "nls.h"
23#include "mountP.h"
24
25/**
26 * mnt_new_fs:
27 *
192c6aad 28 * Returns: newly allocated mnt_file fs.
d115ee9b
KZ
29 */
30mnt_fs *mnt_new_fs(void)
31{
32 mnt_fs *fs = calloc(1, sizeof(struct _mnt_fs));
33 if (!fs)
34 return NULL;
35
36 INIT_LIST_HEAD(&fs->ents);
37 return fs;
38}
39
40/**
41 * mnt_free_fs:
42 * @fs: fs pointer
43 *
44 * Deallocates the fs.
45 */
46void mnt_free_fs(mnt_fs *fs)
47{
48 if (!fs)
49 return;
50 list_del(&fs->ents);
51
52 free(fs->source);
53 free(fs->tagname);
54 free(fs->tagval);
0b3953a3 55 free(fs->root);
d115ee9b
KZ
56 free(fs->target);
57 free(fs->fstype);
58 free(fs->optstr);
59 free(fs->vfs_optstr);
60 free(fs->fs_optstr);
61
62 free(fs);
63}
64
9ecdf48f
KZ
65static inline int cpy_str_item(void *new, void *old, size_t offset)
66{
67 char **o = (char **) (old + offset);
68 char **n = (char **) (new + offset);
69
70 if (!*o)
71 return 0; /* source (old) is empty */
72
73 *n = strdup(*o);
74 if (!*n)
75 return -1;
76 return 0;
77}
78
79/**
80 * mnt_copy_fs:
81 * @fs: source FS
82 *
83 * This function does not copy userdata (se mnt_fs_set_userdata()). A new copy is
84 * not linked with any existing mnt_tab.
85 *
86 * Returns: copy of @fs
87 */
88mnt_fs *mnt_copy_fs(mnt_fs *fs)
89{
90 mnt_fs *n = mnt_new_fs();
91
92 if (!n)
93 return NULL;
94
95 n->id = fs->id;
96 n->parent = fs->parent;
97 n->devno = fs->devno;
98
99 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, source)))
100 goto err;
101 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, tagname)))
102 goto err;
103 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, tagval)))
104 goto err;
105 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, root)))
106 goto err;
107 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, target)))
108 goto err;
109 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, fstype)))
110 goto err;
111 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, optstr)))
112 goto err;
113 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, vfs_optstr)))
114 goto err;
115 if (cpy_str_item(n, fs, offsetof(struct _mnt_fs, fs_optstr)))
116 goto err;
117 n->freq = fs->freq;
118 n->passno = fs->passno;
119 n->flags = fs->flags;
120
121 return n;
122err:
123 mnt_free_fs(n);
124 return NULL;
125}
126
26b4f9e4
KZ
127/**
128 * mnt_fs_get_userdata:
129 * @fs: mnt_file instance
130 *
192c6aad 131 * Returns: private data set by mnt_fs_set_userdata() or NULL.
26b4f9e4
KZ
132 */
133void *mnt_fs_get_userdata(mnt_fs *fs)
134{
135 return fs ? fs->userdata : NULL;
136}
137
138/**
139 * mnt_fs_set_userdata:
140 * @fs: mnt_file instance
141 *
142 * The "userdata" are library independent data.
143 *
192c6aad 144 * Returns: 0 or -1 in case of error (if @fs is NULL).
26b4f9e4
KZ
145 */
146int mnt_fs_set_userdata(mnt_fs *fs, void *data)
147{
148 if (!fs)
149 return -1;
150 fs->userdata = data;
151 return 0;
152}
153
d115ee9b
KZ
154/**
155 * mnt_fs_get_srcpath:
156 * @fs: mnt_file (fstab/mtab/mountinfo) fs
157 *
158 * The mount "source path" is:
192c6aad
KZ
159 * - a directory for 'bind' mounts (in fstab or mtab only)
160 * - a device name for standard mounts
d115ee9b
KZ
161 *
162 * See also mnt_fs_get_tag() and mnt_fs_get_source().
163 *
192c6aad 164 * Returns: mount source path or NULL in case of error or when the path
d115ee9b 165 * is not defined.
d115ee9b
KZ
166 */
167const char *mnt_fs_get_srcpath(mnt_fs *fs)
168{
169 assert(fs);
170 if (!fs)
171 return NULL;
172
173 /* fstab-like fs */
174 if (fs->tagname)
175 return NULL; /* the source contains a "NAME=value" */
176 return fs->source;
177}
178
179/**
3d735589 180 * mnt_fs_get_source:
d115ee9b
KZ
181 * @fs: mnt_file (fstab/mtab/mountinfo) fs
182 *
192c6aad 183 * Returns: mount source. Note that the source could be unparsed TAG
d115ee9b
KZ
184 * (LABEL/UUID). See also mnt_fs_get_srcpath() and mnt_fs_get_tag().
185 */
186const char *mnt_fs_get_source(mnt_fs *fs)
187{
188 return fs ? fs->source : NULL;
189}
190
191/* Used by parser mnt_file ONLY (@source has to be allocated) */
192int __mnt_fs_set_source(mnt_fs *fs, char *source)
193{
194 assert(fs);
195
196 if (!source)
197 return -1;
198
199 if (strchr(source, '=')) {
200 char *name, *val;
201
202 if (blkid_parse_tag_string(source, &name, &val) != 0)
203 return -1;
204
205 fs->tagval = val;
206 fs->tagname = name;
207 }
208
209 fs->source = source;
210 return 0;
211}
212
213/**
214 * mnt_fs_set_source:
215 * @fs: fstab/mtab/mountinfo entry
216 * @source: new source
217 *
192c6aad
KZ
218 * This function creates a private copy (strdup()) of @source.
219 *
220 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
221 */
222int mnt_fs_set_source(mnt_fs *fs, const char *source)
223{
224 char *p;
225
226 if (!fs && !source)
227 return -1;
228
229 p = strdup(source);
230 if (!p)
231 return -1;
232
233 free(fs->tagval);
234 free(fs->tagname);
235 free(fs->source);
236 fs->tagval = fs->tagname = fs->source = NULL;
237
238 return __mnt_fs_set_source(fs, p);
239}
240
241/**
242 * mnt_fs_get_tag:
243 * @fs: fs
244 * @name: returns pointer to NAME string
245 * @value: returns pointer to VALUE string
246 *
247 * "TAG" is NAME=VALUE (e.g. LABEL=foo)
248 *
192c6aad
KZ
249 * The TAG is the first column in the fstab file. The TAG or "srcpath" has to
250 * be always set for all entries.
d115ee9b
KZ
251 *
252 * See also mnt_fs_get_source().
253 *
192c6aad
KZ
254 * <informalexample>
255 * <programlisting>
d115ee9b 256 * char *src;
192c6aad 257 * mnt_fs *fs = mnt_tab_find_target(tb, "/home", MNT_ITER_FORWARD);
d115ee9b
KZ
258 *
259 * if (!fs)
260 * goto err;
261 *
262 * src = mnt_fs_get_srcpath(fs);
263 * if (!src) {
264 * char *tag, *val;
265 * if (mnt_fs_get_tag(fs, &tag, &val) == 0)
266 * printf("%s: %s\n", tag, val); // LABEL or UUID
267 * } else
268 * printf("device: %s\n", src); // device or bind path
192c6aad
KZ
269 * </programlisting>
270 * </informalexample>
d115ee9b 271 *
192c6aad 272 * Returns: 0 on success or -1 in case that a TAG is not defined.
d115ee9b
KZ
273 */
274int mnt_fs_get_tag(mnt_fs *fs, const char **name, const char **value)
275{
276 if (fs == NULL || !fs->tagname)
277 return -1;
278 if (name)
279 *name = fs->tagname;
280 if (value)
281 *value = fs->tagval;
282 return 0;
283}
284
285/**
286 * mnt_fs_get_target:
287 * @fs: fstab/mtab/mountinfo entry pointer
288 *
192c6aad 289 * Returns: pointer to mountpoint path or NULL
d115ee9b
KZ
290 */
291const char *mnt_fs_get_target(mnt_fs *fs)
292{
293 assert(fs);
294 return fs ? fs->target : NULL;
295}
296
297/**
298 * mnt_fs_set_target:
299 * @fs: fstab/mtab/mountinfo entry
300 * @target: mountpoint
301 *
192c6aad
KZ
302 * This function creates a private copy (strdup()) of @target.
303 *
304 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
305 */
306int mnt_fs_set_target(mnt_fs *fs, const char *target)
307{
308 char *p;
309
310 assert(fs);
311
312 if (!fs || !target)
313 return -1;
314
315 p = strdup(target);
316 if (!p)
317 return -1;
318 free(fs->target);
319 fs->target = p;
320
321 return 0;
322}
323
324/**
325 * mnt_fs_get_fstype:
326 * @fs: fstab/mtab/mountinfo entry pointer
327 *
192c6aad 328 * Returns: pointer to filesystem type.
d115ee9b
KZ
329 */
330const char *mnt_fs_get_fstype(mnt_fs *fs)
331{
332 assert(fs);
333 return fs ? fs->fstype : NULL;
334}
335
336/* Used by mnt_file parser only */
337int __mnt_fs_set_fstype(mnt_fs *fs, char *fstype)
338{
339 assert(fs);
340
341 if (!fstype)
342 return -1;
343
344 fs->fstype = fstype;
345 fs->flags &= ~MNT_FS_PSEUDO;
346 fs->flags &= ~MNT_FS_NET;
347
348 /* save info about pseudo filesystems */
349 if (mnt_fstype_is_pseudofs(fs->fstype))
350 fs->flags |= MNT_FS_PSEUDO;
351 else if (mnt_fstype_is_netfs(fs->fstype))
352 fs->flags |= MNT_FS_NET;
353
354 return 0;
355}
356
357/**
358 * mnt_fs_set_fstype:
359 * @fs: fstab/mtab/mountinfo entry
360 * @fstype: filesystem type
361 *
192c6aad
KZ
362 * This function creates a private copy (strdup()) of @fstype.
363 *
364 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
365 */
366int mnt_fs_set_fstype(mnt_fs *fs, const char *fstype)
367{
368 char *p;
369
370 if (!fs || !fstype)
371 return -1;
372
373 p = strdup(fstype);
374 if (!p)
375 return -1;
376 free(fs->fstype);
377
378 return __mnt_fs_set_fstype(fs, p);
379}
380
381/**
382 * mnt_fs_get_optstr:
383 * @fs: fstab/mtab/mountinfo entry pointer
384 *
192c6aad 385 * Returns: pointer to mount option string with all options (FS and VFS)
d115ee9b
KZ
386 */
387const char *mnt_fs_get_optstr(mnt_fs *fs)
388{
389 assert(fs);
390 return fs ? fs->optstr : NULL;
391}
392
393/**
394 * mnt_fs_set_optstr:
395 * @fs: fstab/mtab/mountinfo entry
396 * @optstr: options string
397 *
3661b841 398 * This function creates a private copy of @optstr.
192c6aad
KZ
399 *
400 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
401 */
402int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr)
403{
3661b841 404 char *p, *v, *f;
192c6aad 405
d115ee9b
KZ
406 assert(fs);
407
408 if (!fs || !optstr)
409 return -1;
f309b8a7 410 if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0))
3661b841
KZ
411 return -1;
412
192c6aad 413 p = strdup(optstr);
3661b841
KZ
414 if (!p) {
415 free(v);
416 free(f);
192c6aad 417 return -1;
3661b841 418 }
192c6aad 419
d115ee9b
KZ
420 free(fs->optstr);
421 free(fs->fs_optstr);
422 free(fs->vfs_optstr);
d6fead1e 423
192c6aad 424 fs->optstr = p;
3661b841
KZ
425 fs->fs_optstr = f;
426 fs->vfs_optstr = v;
192c6aad 427 return 0;
d115ee9b
KZ
428}
429
3661b841
KZ
430/**
431 * mnt_fs_append_optstr:
432 * @fs: fstab/mtab/mountinfo entry
433 * @optstr: options string (usually userspace specific options)
434 *
435 * This function appends @optstr to the current list of the mount options. The
436 * VFS and FS specific lists are not modified -- so then the
437 * mnt_fs_get_optstr() function returns VFS + FS + userspace mount options.
438 *
439 * Returns: 0 on success or -1 in case of error.
440 */
441int mnt_fs_append_optstr(mnt_fs *fs, const char *optstr)
442{
443 assert(fs);
444
445 if (!fs || !optstr)
446 return -1;
0532ba1d 447
3661b841
KZ
448 return mnt_optstr_append_option(&fs->optstr, optstr, NULL);
449}
450
d115ee9b
KZ
451/**
452 * mnt_fs_get_fs_optstr:
453 * @fs: fstab/mtab/mountinfo entry pointer
454 *
455 * This function works for "mountinfo" files only.
456 *
192c6aad 457 * Returns: pointer to superblock (fs-depend) mount option string or NULL.
d115ee9b
KZ
458 */
459const char *mnt_fs_get_fs_optstr(mnt_fs *fs)
460{
461 assert(fs);
462 return fs ? fs->fs_optstr : NULL;
463}
464
465/**
466 * mnt_fs_get_vfs_optstr:
efe73c3e 467 * @fs: fstab/mtab entry pointer
d115ee9b
KZ
468 *
469 * This function works for "mountinfo" files only.
470 *
192c6aad 471 * Returns: pointer to fs-independent (VFS) mount option string or NULL.
d115ee9b
KZ
472 */
473const char *mnt_fs_get_vfs_optstr(mnt_fs *fs)
474{
475 assert(fs);
476 return fs ? fs->vfs_optstr : NULL;
477}
478
479
480/**
481 * mnt_fs_get_freq:
482 * @fs: fstab/mtab/mountinfo entry pointer
483 *
3d735589 484 * Returns: dump frequency in days.
d115ee9b
KZ
485 */
486int mnt_fs_get_freq(mnt_fs *fs)
487{
488 assert(fs);
489 return fs ? fs->freq : 0;
490}
491
492/**
493 * mnt_fs_set_freq:
efe73c3e 494 * @fs: fstab/mtab entry pointer
d115ee9b
KZ
495 * @freq: dump frequency in days
496 *
192c6aad 497 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
498 */
499int mnt_fs_set_freq(mnt_fs *fs, int freq)
500{
501 assert(fs);
d115ee9b
KZ
502 if (!fs)
503 return -1;
504 fs->freq = freq;
505 return 0;
506}
507
508/**
509 * mnt_fs_get_passno:
efe73c3e 510 * @fs: fstab/mtab entry pointer
d115ee9b 511 *
192c6aad 512 * Returns: "pass number on parallel fsck".
d115ee9b
KZ
513 */
514int mnt_fs_get_passno(mnt_fs *fs)
515{
516 assert(fs);
517 return fs ? fs->passno: 0;
518}
519
520/**
521 * mnt_fs_set_passno:
efe73c3e 522 * @fs: fstab/mtab entry pointer
d115ee9b
KZ
523 * @passno: pass number
524 *
192c6aad 525 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
526 */
527int mnt_fs_set_passno(mnt_fs *fs, int passno)
528{
529 assert(fs);
d115ee9b
KZ
530 if (!fs)
531 return -1;
532 fs->passno = passno;
533 return 0;
534}
535
0b3953a3
KZ
536/**
537 * mnt_fs_get_root:
538 * @fs: /proc/self/mountinfo entry
539 *
540 * Returns: root of the mount within the filesystem or NULL
541 */
542const char *mnt_fs_get_root(mnt_fs *fs)
543{
544 assert(fs);
545 return fs ? fs->root : NULL;
546}
547
9ecdf48f
KZ
548/**
549 * mnt_fs_set_root:
550 * @fs: mountinfo entry
551 * @root: path
552 *
553 * Returns: 0 on success or -1 in case of error.
554 */
555int mnt_fs_set_root(mnt_fs *fs, const char *root)
556{
557 char *p = NULL;
558
559 assert(fs);
560 if (!fs)
561 return -1;
562 if (root) {
563 p = strdup(root);
564 if (!p)
565 return -1;
566 }
567 free(fs->root);
568 fs->root = p;
569 return 0;
570}
571
efe73c3e
KZ
572/**
573 * mnt_fs_get_id:
574 * @fs: /proc/self/mountinfo entry
575 *
576 * Returns: mount ID (unique identifier of the mount) or -1 if ID undefined
577 * (for example if @fs is not mountinfo entry).
578 */
579int mnt_fs_get_id(mnt_fs *fs)
580{
581 assert(fs);
582 return fs ? fs->id : -1;
583}
584
585/**
586 * mnt_fs_get_parent_id:
587 * @fs: /proc/self/mountinfo entry
588 *
589 * Returns: parent mount ID or -1 if ID undefined (for example if @fs is not
590 * mountinfo entry).
591 */
592int mnt_fs_get_parent_id(mnt_fs *fs)
593{
594 assert(fs);
595 return fs ? fs->parent : -1;
596}
597
598/**
599 * mnt_fs_get_devno:
0b3953a3 600 * @fs: /proc/self/mountinfo entry
efe73c3e
KZ
601 *
602 * Returns: value of st_dev for files on filesystem or 0 in case of error.
603 */
604dev_t mnt_fs_get_devno(mnt_fs *fs)
605{
606 assert(fs);
607 return fs ? fs->devno : 0;
608}
609
d115ee9b
KZ
610/**
611 * mnt_fs_get_option:
612 * @fs: fstab/mtab/mountinfo entry pointer
613 * @name: option name
614 * @value: returns pointer to the begin of the value (e.g. name=VALUE) or NULL
615 * @valsz: returns size of options value or 0
616 *
192c6aad 617 * Returns: 0 on success, 1 when not found the @name or -1 in case of error.
d115ee9b
KZ
618 */
619int mnt_fs_get_option(mnt_fs *fs, const char *name,
620 char **value, size_t *valsz)
621{
622 char *optstr = (char *) mnt_fs_get_optstr(fs);
623 return optstr ? mnt_optstr_get_option(optstr, name, value, valsz) : 1;
624}
625
3fca8422
KZ
626/**
627 * mnt_fs_match_target:
628 * @fs: filesystem
629 * @target: mountpoint path
630 * @cache: tags/paths cache or NULL
631 *
632 * Possible are three attempts:
633 * 1) compare @target with @fs->target
634 * 2) realpath(@target) with @fs->target
635 * 3) realpath(@target) with realpath(@fs->target).
636 *
637 * The 2nd and 3rd attempts are not performed when @cache is NULL.
638 *
192c6aad 639 * Returns: 1 if @fs target is equal to @target else 0.
3fca8422
KZ
640 */
641int mnt_fs_match_target(mnt_fs *fs, const char *target, mnt_cache *cache)
642{
643 int rc = 0;
644
645 if (!fs || !target || !fs->target)
646 return 0;
647
648 /* 1) native paths */
649 rc = !strcmp(target, fs->target);
650
651 if (!rc && cache) {
652 /* 2) - canonicalized and non-canonicalized */
653 char *cn = mnt_resolve_path(target, cache);
654 rc = (cn && strcmp(cn, fs->target) == 0);
655
656 /* 3) - canonicalized and canonicalized */
657 if (!rc && cn) {
658 char *tcn = mnt_resolve_path(fs->target, cache);
659 rc = (tcn && strcmp(cn, tcn) == 0);
660 }
661 }
662
663 return rc;
664}
665
666/**
667 * mnt_fs_match_source:
668 * @fs: filesystem
669 * @source: tag or path (device or so)
670 * @cache: tags/paths cache or NULL
671 *
672 * Possible are four attempts:
673 * 1) compare @source with @fs->source
674 * 2) compare realpath(@source) with @fs->source
675 * 3) compare realpath(@source) with realpath(@fs->source)
676 * 4) compare realpath(@source) with evaluated tag from @fs->source
677 *
678 * The 2nd, 3rd and 4th attempts are not performed when @cache is NULL. The
679 * 2nd and 3rd attempts are not performed if @fs->source is tag.
680 *
192c6aad 681 * Returns: 1 if @fs source is equal to @source else 0.
3fca8422
KZ
682 */
683int mnt_fs_match_source(mnt_fs *fs, const char *source, mnt_cache *cache)
684{
3fca8422
KZ
685 char *cn;
686 const char *src, *t, *v;
687
688 if (!fs || !source || !fs->source)
689 return 0;
690
691 /* 1) native paths/tags */
3ef87248
KZ
692 if (!strcmp(source, fs->source))
693 return 1;
3fca8422 694
3ef87248
KZ
695 if (!cache)
696 return 0;
3fca8422
KZ
697 if (fs->flags & (MNT_FS_NET | MNT_FS_PSEUDO))
698 return 0;
699
700 cn = mnt_resolve_spec(source, cache);
701 if (!cn)
702 return 0;
703
704 /* 2) canonicalized and native */
705 src = mnt_fs_get_srcpath(fs);
3ef87248
KZ
706 if (src && !strcmp(cn, src))
707 return 1;
3fca8422
KZ
708
709 /* 3) canonicalized and canonicalized */
3ef87248 710 if (src) {
3fca8422 711 src = mnt_resolve_path(src, cache);
3ef87248
KZ
712 if (src && !strcmp(cn, src))
713 return 1;
3fca8422 714 }
3ef87248
KZ
715 if (src || mnt_fs_get_tag(fs, &t, &v))
716 /* src path does not match and tag is not defined */
3fca8422
KZ
717 return 0;
718
719 /* read @source's tags to the cache */
ba7232a1 720 if (mnt_cache_read_tags(cache, cn) < 0) {
3fca8422
KZ
721 if (errno == EACCES) {
722 /* we don't have permissions to read TAGs from
723 * @source, but can translate @fs tag to devname.
724 *
725 * (because libblkid uses udev symlinks and this is
726 * accessible for non-root uses)
727 */
728 char *x = mnt_resolve_tag(t, v, cache);
729 if (x && !strcmp(x, cn))
730 return 1;
731 }
732 return 0;
733 }
734
735 /* 4) has the @source a tag that matches with tag from @fs ? */
3ef87248
KZ
736 if (mnt_cache_device_has_tag(cache, cn, t, v))
737 return 1;
3fca8422 738
3ef87248 739 return 0;
3fca8422
KZ
740}
741
742/**
743 * mnt_fs_match_fstype:
744 * @fs: filesystem
745 * @types: filesystem name or comma delimited list of filesystems
746 *
747 * For more details see mnt_match_fstype().
748 *
192c6aad 749 * Returns: 1 if @fs type is matching to @types else 0. The function returns
3fca8422
KZ
750 * 0 when types is NULL.
751 */
752int mnt_fs_match_fstype(mnt_fs *fs, const char *types)
753{
754 return mnt_match_fstype(fs->fstype, types);
755}
756
757/**
758 * mnt_fs_match_options:
759 * @fs: filesystem
760 * @options: comma delimited list of options (and nooptions)
761 *
762 * For more details see mnt_match_options().
763 *
192c6aad 764 * Returns: 1 if @fs type is matching to @options else 0. The function returns
3fca8422
KZ
765 * 0 when types is NULL.
766 */
767int mnt_fs_match_options(mnt_fs *fs, const char *options)
768{
769 return mnt_match_options(fs->optstr, options);
770}
771
d115ee9b
KZ
772/**
773 * mnt_fs_print_debug
774 * @fs: fstab/mtab/mountinfo entry
775 * @file: output
776 *
192c6aad 777 * Returns: 0 on success or -1 in case of error.
d115ee9b
KZ
778 */
779int mnt_fs_print_debug(mnt_fs *fs, FILE *file)
780{
781 if (!fs)
782 return -1;
783 fprintf(file, "------ fs: %p\n", fs);
784 fprintf(file, "source: %s\n", mnt_fs_get_source(fs));
785 fprintf(file, "target: %s\n", mnt_fs_get_target(fs));
786 fprintf(file, "fstype: %s\n", mnt_fs_get_fstype(fs));
787 fprintf(file, "optstr: %s\n", mnt_fs_get_optstr(fs));
788 fprintf(file, "freq: %d\n", mnt_fs_get_freq(fs));
789 fprintf(file, "pass: %d\n", mnt_fs_get_passno(fs));
efe73c3e
KZ
790 fprintf(file, "id: %d\n", mnt_fs_get_id(fs));
791 fprintf(file, "parent: %d\n", mnt_fs_get_parent_id(fs));
792 fprintf(file, "devno: %d:%d\n", major(mnt_fs_get_devno(fs)),
793 minor(mnt_fs_get_devno(fs)));
794
d115ee9b
KZ
795
796 return 0;
797}