]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libdisk/mountinfo.c
a639447dae97a1b57e22f0082ca77972c30c17d7
[thirdparty/xfsprogs-dev.git] / libdisk / mountinfo.c
1 /*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33 #include <stdio.h>
34 #include <fcntl.h>
35 #include <mntent.h>
36 #include <unistd.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <sys/stat.h>
40 #include <sys/param.h>
41 #include "mountinfo.h"
42
43 int
44 mnt_check_init(mnt_check_state_t **check_state)
45 {
46 return(0);
47 }
48
49 int
50 mnt_find_mount_conflicts(mnt_check_state_t *check_state, char *devname)
51 {
52 #define PROC_MOUNTED "/proc/mounts"
53 int sts = 0;
54 FILE *f;
55 struct mntent *mnt;
56 struct stat64 ns, ms;
57 char mounts[MAXPATHLEN];
58
59 if (stat64(devname, &ns) < 0)
60 return sts;
61
62 strcpy(mounts, access(PROC_MOUNTED, R_OK)? PROC_MOUNTED : MOUNTED);
63 if ((f = setmntent(mounts, "r")) == NULL)
64 return sts;
65 while ((mnt = getmntent(f)) != NULL) {
66 if (stat64(mnt->mnt_fsname, &ms) < 0)
67 continue;
68 if (S_ISBLK(ms.st_mode) && ns.st_rdev == ms.st_rdev)
69 break;
70 if (!S_ISBLK(ms.st_mode) && !strcmp(devname, mnt->mnt_fsname))
71 break;
72 }
73 endmntent(f);
74 if (mnt)
75 sts = 1;
76 return sts;
77 }
78
79 int
80 mnt_find_mounted_partitions(mnt_check_state_t *check_state, char *devname)
81 {
82 return 0;
83 }
84
85 int
86 mnt_causes_test(mnt_check_state_t *check_state, int cause)
87 {
88 switch(cause) {
89 case MNT_CAUSE_MOUNTED:
90 return(1);
91
92 default:
93 fprintf(stderr, "mnt_causes_test: unknown cause %d\n", cause);
94 exit(99);
95 }
96 }
97
98 void
99 mnt_causes_show(mnt_check_state_t *check_state, FILE *fp, char *prefix)
100 {
101 fprintf(fp, "mnt_causes_show: not implemented. Called with %s\n",
102 prefix);
103 exit(98);
104 }
105
106 void
107 mnt_plist_show(mnt_check_state_t *check_state, FILE *fp, char *prefix)
108 {
109 /*
110 * Need to do some work for volume mgmt.
111 */
112 }
113
114 int
115 mnt_check_end(mnt_check_state_t *check_state)
116 {
117 return(0);
118 }