#include <string.h>
#include <stdio.h>
#include <mntent.h>
-#include <sys/mount.h>
#include <ctype.h>
#if defined BB_FEATURE_USE_DEVPS_PATCH
-#include <linux/devmtab.h>
-#endif
-#ifndef MS_RDONLY
-#include <linux/fs.h>
+#include <linux/devmtab.h> /* For Erik's nifty devmtab device driver */
#endif
+#define MS_MGC_VAL 0xc0ed0000 /* Magic number indicatng "new" flags */
+#define MS_RDONLY 1 /* Mount read-only */
+#define MS_NOSUID 2 /* Ignore suid and sgid bits */
+#define MS_NODEV 4 /* Disallow access to device special files */
+#define MS_NOEXEC 8 /* Disallow program execution */
+#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
+#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
+#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
+#define S_QUOTA 128 /* Quota initialized for file/directory/symlink */
+#define S_APPEND 256 /* Append-only file */
+#define S_IMMUTABLE 512 /* Immutable file */
+#define MS_NOATIME 1024 /* Do not update access times. */
+#define MS_NODIRATIME 2048 /* Do not update directory access times */
+
+
+
#if defined BB_FEATURE_MOUNT_LOOP
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <linux/loop.h>
-
-
static int use_loop = FALSE;
#endif
-extern const char mtab_file[]; /* Defined in utility.c */
+extern int mount (__const char *__special_file, __const char *__dir,
+ __const char *__fstype, unsigned long int __rwflag,
+ __const void *__data);
+extern int umount (__const char *__special_file);
+extern int umount2 (__const char *__special_file, int __flags);
-static const char mount_usage[] =
- "mount [flags] device directory [-o options,more-options]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
- "\nMount a filesystem\n\n"
- "Flags:\n"
- "\t-a:\t\tMount all filesystems in fstab.\n"
-#ifdef BB_MTAB
- "\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
- "\t-n:\t\tDon't write a mount table entry.\n"
-#endif
- "\t-o option:\tOne of many filesystem options, listed below.\n"
- "\t-r:\t\tMount the filesystem read-only.\n"
- "\t-t fs-type:\tSpecify the filesystem type.\n"
- "\t-w:\t\tMount for reading and writing (default).\n"
- "\n"
- "Options for use with the \"-o\" flag:\n"
- "\tasync/sync:\tWrites are asynchronous / synchronous.\n"
- "\tatime/noatime:\tEnable / disable updates to inode access times.\n"
- "\tdev/nodev:\tAllow use of special device files / disallow them.\n"
- "\texec/noexec:\tAllow use of executable files / disallow them.\n"
-#if defined BB_FEATURE_MOUNT_LOOP
- "\tloop:\t\tMounts a file via loop device.\n"
-#endif
- "\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
- "\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
- "\tro/rw:\t\tMount for read-only / read-write.\n"
- "\nThere are EVEN MORE flags that are specific to each filesystem.\n"
- "You'll have to see the written documentation for those.\n"
-#endif
- ;
+extern const char mtab_file[]; /* Defined in utility.c */
struct mount_options {
const char *name;
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
- fprintf(stderr, "Could not find a spare loop device\n");
+ errorMsg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
- fprintf(stderr, "Could not setup loop device\n");
+ errorMsg("Could not setup loop device\n");
return (FALSE);
}
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
- fprintf(stderr, "WARNING: loop device is read-only\n");
+ errorMsg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY;
}
}
#endif
if (errno == EPERM) {
- fatalError("mount: permission denied. Are you root?\n");
+ fatalError("permission denied. Are you root?\n");
}
return (FALSE);
/* Seperate standard mount options from the nonstandard string options */
static void
-parse_mount_options(char *options, unsigned long *flags, char *strflags)
+parse_mount_options(char *options, int *flags, char *strflags)
{
while (options) {
int gotone = FALSE;
if (status == FALSE) {
if (whineOnErrors == TRUE) {
- fprintf(stderr, "Mounting %s on %s failed: %s\n",
+ errorMsg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
char string_flags_buf[1024] = "";
char *string_flags = string_flags_buf;
char *extra_opts = string_flags_buf;
- unsigned long flags = 0;
+ int flags = 0;
char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
mntentlist[i].mnt_passno);
}
+#ifdef BB_FEATURE_CLEAN_UP
/* Don't bother to close files or free memory. Exit
* does that automagically, so we can save a few bytes */
-#if 0
free( mntentlist);
close(fd);
#endif