1 /* vi: set sw=4 ts=4: */
3 * mountpoint implementation for busybox
5 * Copyright (C) 2005 Bernhard Fischer
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 * Based on sysvinit's mountpoint
14 int mountpoint_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
15 int mountpoint_main(int argc
, char **argv
)
19 int opt
= getopt32(argv
, "qdx");
24 if (optind
!= argc
- 1)
29 if ( (opt
& OPT_x
&& stat(arg
, &st
) == 0) || (lstat(arg
, &st
) == 0) ) {
31 if (S_ISBLK(st
.st_mode
)) {
32 printf("%u:%u\n", major(st
.st_rdev
),
39 bb_error_msg("%s: not a block device", arg
);
43 if (S_ISDIR(st
.st_mode
)) {
44 dev_t st_dev
= st
.st_dev
;
45 ino_t st_ino
= st
.st_ino
;
46 char *p
= xasprintf("%s/..", arg
);
48 if (stat(p
, &st
) == 0) {
49 int ret
= (st_dev
!= st
.st_dev
) ||
50 (st_dev
== st
.st_dev
&& st_ino
== st
.st_ino
);
52 printf("%u:%u\n", major(st_dev
), minor(st_dev
));
53 else if (!(opt
& OPT_q
))
54 printf("%s is %sa mountpoint\n", arg
, ret
?"":"not ");
59 bb_error_msg("%s: not a directory", arg
);
64 bb_simple_perror_msg(arg
);