cluster/gfs/gfs_mkfs main.c
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rohara at sourceware.org 2007-07-10 18:01:05
Modified files:
gfs/gfs_mkfs : main.c
Log message:
BZ 240584 - Check to see if device is mounted before creating filesystem.
gfs/gfs_mkfs/main.c +36 -0
@@ -22,6 +22,7 @@#include <sys/ioctl.h> #include <assert.h> #include <time.h> +#include <mntent.h> #include "global.h" #include "gfs_ondisk.h"
@@ -243,6 +244,39 @@/** +* check_mount - +* @ +* +*/ + +void check_mount (char *device) +{ +struct mntent *mnt; +FILE *fp; + +if ((fp =setmntent ("/proc/mounts" ,"r" )) ==NULL ) { +die ("error opening /proc/mounts" ); + } + +while ((mnt =getmntent (fp)) !=NULL ) { +if (strcmp (device, mnt->mnt_fsname) ==0 ) { +printf ("cannot create filesystem: " ); +printf ("%s appears to be mounted\n" , device); +break ; + } + } + +endmntent (fp); + +if (fp !=NULL ) { +exit (EXIT_FAILURE ); + } + +return ; +} + + +/** * print_results - print out summary information * @comline: the command line *
@@ -307,6 +341,8 @@decode_arguments (argc, argv, &comline); +check_mount (comline.device); +if (!comline.expert) {char buf[256 ];if (test_locking (comline.lockproto, comline.locktable, buf,256 ))