@@ -159,6 +159,10 @@ btrfs-select-super: $(objects) $(libs)
btrfs-select-super.o
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o btrfs-select-super $(objects)
btrfs-select-super.o $(LDFLAGS) $(LIBS)
+check-mounted: $(objects) $(libs) check-mounted.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o check-mounted $(objects) check-mounted.o
$(LDFLAGS) $(LIBS)
+
btrfstune: $(objects) $(libs) btrfstune.o
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o
$(LDFLAGS) $(LIBS)
@@ -205,7 +209,7 @@ clean :
@echo "Cleaning"
$(Q)rm -f $(progs) cscope.out *.o .*.d btrfs-convert
btrfs-image btrfs-select-super \
btrfs-zero-log btrfstune dir-test ioctl-test quick-test
send-test btrfs.static btrfsck \
- version.h \
+ version.h check-mounted\
$(libs) $(lib_links)
$(Q)$(MAKE) $(MAKEOPTS) -C man $@
new file mode 100644
@@ -0,0 +1,31 @@
+
+#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE 1
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include "kerncompat.h"
+#include "ctree.h"
+#include "disk-io.h"
+#include "print-tree.h"
+#include "transaction.h"
+#include "list.h"
+#include "version.h"
+#include "utils.h"
+
+int main(int ac, char **av)
+{
+ int ret;
+
+ if((ret = check_mounted(av[optind])) < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
strerror(-ret));
+ return ret;
+ } else if(ret) {
+ fprintf(stderr, "%s is currently mounted. Aborting.\n",
av[optind]);
+ return -EBUSY;
+ }
+ printf("Not mounted\n");