Run through indent, style
This commit is contained in:
parent
acfc0d872e
commit
8042f65398
@ -120,9 +120,9 @@ static const struct mount_options mount_options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_mount(char *specialfile, char *dir, char *filesystemtype,
|
do_mount(char *specialfile, char *dir, char *filesystemtype, long flags,
|
||||||
long flags, void *string_flags, int useMtab, int fakeIt,
|
void *string_flags, int useMtab, int fakeIt, char *mtab_opts,
|
||||||
char *mtab_opts, int mount_all)
|
int mount_all)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
@ -158,8 +158,9 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
|
|||||||
MS_RDONLY, string_flags);
|
MS_RDONLY, string_flags);
|
||||||
}
|
}
|
||||||
/* Don't whine about already mounted filesystems when mounting all. */
|
/* Don't whine about already mounted filesystems when mounting all. */
|
||||||
if (status < 0 && errno == EBUSY && mount_all)
|
if (status < 0 && errno == EBUSY && mount_all) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,8 +205,9 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
|
|||||||
char *comma = strchr(options, ',');
|
char *comma = strchr(options, ',');
|
||||||
const struct mount_options *f = mount_options;
|
const struct mount_options *f = mount_options;
|
||||||
|
|
||||||
if (comma)
|
if (comma) {
|
||||||
*comma = '\0';
|
*comma = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
while (f->name != 0) {
|
while (f->name != 0) {
|
||||||
if (strcasecmp(f->name, options) == 0) {
|
if (strcasecmp(f->name, options) == 0) {
|
||||||
@ -224,8 +226,10 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!gotone) {
|
if (!gotone) {
|
||||||
if (**strflags) /* have previous parsed options */
|
if (**strflags) {
|
||||||
|
/* have previous parsed options */
|
||||||
paste_str(strflags, ",");
|
paste_str(strflags, ",");
|
||||||
|
}
|
||||||
paste_str(strflags, options);
|
paste_str(strflags, options);
|
||||||
}
|
}
|
||||||
if (comma) {
|
if (comma) {
|
||||||
@ -237,10 +241,10 @@ static void parse_mount_options(char *options, int *flags, char **strflags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mount_one(char *blockDevice, char *directory, char *filesystemType,
|
||||||
mount_one(char *blockDevice, char *directory, char *filesystemType,
|
unsigned long flags, char *string_flags, int useMtab,
|
||||||
unsigned long flags, char *string_flags, int useMtab, int fakeIt,
|
int fakeIt, char *mtab_opts, int whineOnErrors,
|
||||||
char *mtab_opts, int whineOnErrors, int mount_all)
|
int mount_all)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
@ -265,11 +269,13 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!*noauto_fstype) {
|
if (!*noauto_fstype) {
|
||||||
status = do_mount(blockDevice, directory, filesystemType,
|
status =
|
||||||
flags | MS_MGC_VAL, string_flags,
|
do_mount(blockDevice, directory, filesystemType,
|
||||||
useMtab, fakeIt, mtab_opts, mount_all);
|
flags | MS_MGC_VAL, string_flags, useMtab,
|
||||||
if (status)
|
fakeIt, mtab_opts, mount_all);
|
||||||
|
if (status) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,16 +289,17 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
|
|||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
while (fgets(buf, sizeof(buf), f)) {
|
while (fgets(buf, sizeof(buf), f)) {
|
||||||
if (*buf == '*')
|
if (*buf == '*') {
|
||||||
read_proc = 1;
|
read_proc = 1;
|
||||||
else if (*buf == '#')
|
} else if (*buf == '#') {
|
||||||
continue;
|
continue;
|
||||||
else {
|
} else {
|
||||||
filesystemType = buf;
|
filesystemType = buf;
|
||||||
|
|
||||||
/* Add NULL termination to each line */
|
/* Add NULL termination to each line */
|
||||||
while (*filesystemType && !isspace(*filesystemType))
|
while (*filesystemType && !isspace(*filesystemType)) {
|
||||||
filesystemType++;
|
filesystemType++;
|
||||||
|
}
|
||||||
*filesystemType = '\0';
|
*filesystemType = '\0';
|
||||||
|
|
||||||
filesystemType = buf;
|
filesystemType = buf;
|
||||||
@ -302,8 +309,9 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
|
|||||||
do_mount(blockDevice, directory, filesystemType,
|
do_mount(blockDevice, directory, filesystemType,
|
||||||
flags | MS_MGC_VAL, string_flags,
|
flags | MS_MGC_VAL, string_flags,
|
||||||
useMtab, fakeIt, mtab_opts, mount_all);
|
useMtab, fakeIt, mtab_opts, mount_all);
|
||||||
if (status)
|
if (status) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -319,18 +327,21 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
|
|||||||
if (*filesystemType == '\t') { /* Not a nodev filesystem */
|
if (*filesystemType == '\t') { /* Not a nodev filesystem */
|
||||||
|
|
||||||
/* Add NULL termination to each line */
|
/* Add NULL termination to each line */
|
||||||
while (*filesystemType && *filesystemType != '\n')
|
while (*filesystemType && *filesystemType != '\n') {
|
||||||
filesystemType++;
|
filesystemType++;
|
||||||
|
}
|
||||||
*filesystemType = '\0';
|
*filesystemType = '\0';
|
||||||
|
|
||||||
filesystemType = buf;
|
filesystemType = buf;
|
||||||
filesystemType++; /* hop past tab */
|
filesystemType++; /* hop past tab */
|
||||||
|
|
||||||
status = do_mount(blockDevice, directory, filesystemType,
|
status =
|
||||||
flags | MS_MGC_VAL, string_flags,
|
do_mount(blockDevice, directory, filesystemType,
|
||||||
useMtab, fakeIt, mtab_opts, mount_all);
|
flags | MS_MGC_VAL, string_flags, useMtab,
|
||||||
if (status)
|
fakeIt, mtab_opts, mount_all);
|
||||||
|
if (status) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,9 +349,10 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
status = do_mount(blockDevice, directory, filesystemType,
|
status =
|
||||||
flags | MS_MGC_VAL, string_flags, useMtab,
|
do_mount(blockDevice, directory, filesystemType,
|
||||||
fakeIt, mtab_opts, mount_all);
|
flags | MS_MGC_VAL, string_flags, useMtab, fakeIt,
|
||||||
|
mtab_opts, mount_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -361,20 +373,23 @@ static void show_mounts(char *onlytype)
|
|||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
fd = open(device, O_RDONLY);
|
fd = open(device, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
perror_msg_and_die("open failed for `%s'", device);
|
perror_msg_and_die("open failed for `%s'", device);
|
||||||
|
}
|
||||||
|
|
||||||
/* How many mounted filesystems? We need to know to
|
/* How many mounted filesystems? We need to know to
|
||||||
* allocate enough space for later... */
|
* allocate enough space for later... */
|
||||||
numfilesystems = ioctl(fd, DEVMTAB_COUNT_MOUNTS);
|
numfilesystems = ioctl(fd, DEVMTAB_COUNT_MOUNTS);
|
||||||
if (numfilesystems < 0)
|
if (numfilesystems < 0) {
|
||||||
perror_msg_and_die("\nDEVMTAB_COUNT_MOUNTS");
|
perror_msg_and_die("\nDEVMTAB_COUNT_MOUNTS");
|
||||||
|
}
|
||||||
mntentlist =
|
mntentlist =
|
||||||
(struct k_mntent *) xcalloc(numfilesystems, sizeof(struct k_mntent));
|
(struct k_mntent *) xcalloc(numfilesystems, sizeof(struct k_mntent));
|
||||||
|
|
||||||
/* Grab the list of mounted filesystems */
|
/* Grab the list of mounted filesystems */
|
||||||
if (ioctl(fd, DEVMTAB_GET_MOUNTS, mntentlist) < 0)
|
if (ioctl(fd, DEVMTAB_GET_MOUNTS, mntentlist) < 0) {
|
||||||
perror_msg_and_die("\nDEVMTAB_GET_MOUNTS");
|
perror_msg_and_die("\nDEVMTAB_GET_MOUNTS");
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < numfilesystems; i++) {
|
for (i = 0; i < numfilesystems; i++) {
|
||||||
if (!onlytype || (strcmp(mntentlist[i].mnt_type, onlytype) == 0)) {
|
if (!onlytype || (strcmp(mntentlist[i].mnt_type, onlytype) == 0)) {
|
||||||
@ -408,8 +423,9 @@ static void show_mounts(char *onlytype)
|
|||||||
m->mnt_type, m->mnt_opts);
|
m->mnt_type, m->mnt_opts);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||||
if (blockDevice != m->mnt_fsname)
|
if (blockDevice != m->mnt_fsname) {
|
||||||
free(blockDevice);
|
free(blockDevice);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
endmntent(mountTable);
|
endmntent(mountTable);
|
||||||
@ -470,8 +486,9 @@ extern int mount_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!all && optind == argc)
|
if (!all && (optind == argc)) {
|
||||||
show_mounts(got_filesystemType ? filesystemType : 0);
|
show_mounts(got_filesystemType ? filesystemType : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
/* if device is a filename get its real path */
|
/* if device is a filename get its real path */
|
||||||
@ -494,10 +511,9 @@ extern int mount_main(int argc, char **argv)
|
|||||||
perror_msg_and_die("\nCannot read /etc/fstab");
|
perror_msg_and_die("\nCannot read /etc/fstab");
|
||||||
|
|
||||||
while ((m = getmntent(f)) != NULL) {
|
while ((m = getmntent(f)) != NULL) {
|
||||||
if (!all && optind + 1 == argc && ((strcmp(device, m->mnt_fsname)
|
if (!all && (optind + 1 == argc)
|
||||||
!= 0)
|
&& ((strcmp(device, m->mnt_fsname) != 0)
|
||||||
&& (strcmp(device, m->mnt_dir)
|
&& (strcmp(device, m->mnt_dir) != 0))) {
|
||||||
!= 0))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,27 +539,29 @@ extern int mount_main(int argc, char **argv)
|
|||||||
#ifdef CONFIG_NFSMOUNT
|
#ifdef CONFIG_NFSMOUNT
|
||||||
if (strchr(device, ':') != NULL) {
|
if (strchr(device, ':') != NULL) {
|
||||||
filesystemType = "nfs";
|
filesystemType = "nfs";
|
||||||
if (nfsmount(device, directory, &flags, &extra_opts,
|
if (nfsmount
|
||||||
&string_flags, 1)) {
|
(device, directory, &flags, &extra_opts, &string_flags,
|
||||||
|
1)) {
|
||||||
perror_msg("nfsmount failed");
|
perror_msg("nfsmount failed");
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!mount_one(device, directory, filesystemType, flags,
|
if (!mount_one
|
||||||
string_flags, useMtab, fakeIt, extra_opts, TRUE,
|
(device, directory, filesystemType, flags, string_flags,
|
||||||
all))
|
useMtab, fakeIt, extra_opts, TRUE, all)) {
|
||||||
rc = EXIT_FAILURE;
|
rc = EXIT_FAILURE;
|
||||||
|
}
|
||||||
if (!all)
|
if (!all) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (f)
|
if (f) {
|
||||||
endmntent(f);
|
endmntent(f);
|
||||||
|
}
|
||||||
if (!all && f && m == NULL)
|
if (!all && f && m == NULL) {
|
||||||
fprintf(stderr, "Can't find %s in /etc/fstab\n", device);
|
fprintf(stderr, "Can't find %s in /etc/fstab\n", device);
|
||||||
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user