Lines 16-26
Link Here
|
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 |
*/ |
17 |
*/ |
18 |
|
18 |
|
19 |
#define ustat __kernel_ustat |
|
|
20 |
#include <mntent.h> |
19 |
#include <mntent.h> |
21 |
#include <sys/stat.h> |
20 |
#include <sys/stat.h> |
22 |
#undef ustat |
|
|
23 |
#include <sys/ustat.h> |
24 |
#include <sys/mount.h> |
21 |
#include <sys/mount.h> |
25 |
#include <sys/ioctl.h> |
22 |
#include <sys/ioctl.h> |
26 |
#include <sys/sysinfo.h> |
23 |
#include <sys/sysinfo.h> |
Lines 51-59
static int max_block_alignment;
Link Here
|
51 |
int |
48 |
int |
52 |
platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) |
49 |
platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose) |
53 |
{ |
50 |
{ |
54 |
/* Pad ust; pre-2.6.28 linux copies out too much in 32bit compat mode */ |
51 |
FILE *f; |
55 |
struct ustat ust[2]; |
52 |
struct stat64 st, mst; |
56 |
struct stat64 st; |
53 |
struct mntent *mnt; |
|
|
54 |
char mounts[MAXPATHLEN]; |
57 |
|
55 |
|
58 |
if (!s) { |
56 |
if (!s) { |
59 |
if (stat64(block, &st) < 0) |
57 |
if (stat64(block, &st) < 0) |
Lines 63-76
platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
Link Here
|
63 |
s = &st; |
61 |
s = &st; |
64 |
} |
62 |
} |
65 |
|
63 |
|
66 |
if (ustat(s->st_rdev, ust) >= 0) { |
64 |
strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED); |
|
|
65 |
if ((f = setmntent(mounts, "r")) == NULL) { |
66 |
fprintf(stderr, |
67 |
_("%s: %s possibly contains a mounted filesystem\n"), |
68 |
progname, name); |
69 |
return 1; |
70 |
} |
71 |
while ((mnt = getmntent(f)) != NULL) { |
72 |
if (stat64(mnt->mnt_dir, &mst) < 0) |
73 |
continue; |
74 |
if (mst.st_dev != s->st_rdev) |
75 |
continue; |
76 |
|
67 |
if (verbose) |
77 |
if (verbose) |
68 |
fprintf(stderr, |
78 |
fprintf(stderr, |
69 |
_("%s: %s contains a mounted filesystem\n"), |
79 |
_("%s: %s contains a mounted filesystem\n"), |
70 |
progname, name); |
80 |
progname, name); |
71 |
return 1; |
81 |
break; |
72 |
} |
82 |
} |
73 |
return 0; |
83 |
endmntent(f); |
|
|
84 |
return mnt == NULL; |
74 |
} |
85 |
} |
75 |
|
86 |
|
76 |
int |
87 |
int |