Commit Graph

50 Commits

Author SHA1 Message Date
Michael Forney 3a5939e810 mount: Don't pass {,no}auto to kernel 2017-08-22 13:36:28 +02:00
FRIGN 4c33cf2a98 Use estrlcat where possible 2016-02-11 14:36:54 +00:00
Brad Barden 4dbd00fc94 mount: fix mount helper fs option handling
If a mount helper is used, only argopts (given on commandline) are
passed to the helper via -o parameter. Option strings from fstab are
ignored.

This patch replaces global argopts pointer with a character array
fsopts. A maximum length for filesytem options is #defined (used by
fsopts and data), and argument/mntent options are length-checked to fit.
A filesystem with too long an option string will print an error, cause
mount to exit with an error status, and not attempt to mount the
filesystem. This obviates the need for overflow checking of data in
parseopts(), though it hasn't been removed.
2016-02-11 10:16:41 +00:00
Hiltjo Posthuma 71da5628d1 mount: helper support + improvements
- helper support (mount.type).
  - helpers need to be in $PATH, if needed we can add a check for
    /sbin/mount.XXXX
  - pass -B, -M, -R to helper, its more reliable to pass these named
    options with -o however.
- allow prefix "no" for which type no action should be taken:
  mount -a -t nonfs,ext4

fix bugs:
- dont modify me->mnt_opts (used strtok).
2015-05-11 23:35:54 +01:00
Hiltjo Posthuma 9455f51dd8 mount: use libutil/concat instead of custom catfile
this trivializes the code some more
2015-02-22 11:34:37 +00:00
Hiltjo Posthuma 43327506b6 mount: support "noauto" in /etc/fstab 2015-02-20 15:36:33 +00:00
Hiltjo Posthuma 710081b07a mount: change mounted() check
- use getmntent_r instead of getmntent: because getmntent was nested it
  overwrote the previous internal mntent structure.
- check mounted() first, if not try to mount: this also makes sure filesystems
  were not mounted multiple times (like tmpfs) and errno is not overwritten in
  mounted(). For this reason also mount() errno EBUSY can't be used (tested).
2015-02-20 15:36:33 +00:00
Hiltjo Posthuma a248370eb6 mount: catfile: return 0 or -1 2015-02-20 15:36:33 +00:00
Hiltjo Posthuma 7e394bd70f code-style: cleanup
- move main() at the bottom.
- put global variables at the top.
- improve usage() lines (consistent with man page).
2015-02-06 15:16:24 +00:00
sin 6f7f387352 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:47:39 +01:00
Hiltjo Posthuma 291aedb875 code consistency fixes 2014-07-09 15:08:01 +01:00
sin 86060b535c Fix includes across all tools 2014-06-30 19:04:47 +01:00
Hiltjo Posthuma 1abf7518ad mount: remove stat, not needed since we use realpath 2014-06-07 19:16:50 +01:00
Hiltjo Posthuma 01bbe2820a mount: resolve path given
this allows: cd /mnt; mount somename.
2014-06-07 19:16:42 +01:00
Hiltjo Posthuma acdac11285 mount: style for loop in catfile()
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-05 18:56:08 +01:00
Hiltjo Posthuma ef1ab48699 mount: loop until no opt options
values can be specified as 0 to ignore them

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-05 18:55:56 +01:00
Hiltjo Posthuma 3c47a9a9d6 mount: rename bufsiz to datasiz for clarity
datasiz relates to the size of data

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-04 20:09:44 +01:00
Hiltjo Posthuma 5f4d18d4fa mount: cat /proc/mounts if no arguments given
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-04 20:09:37 +01:00
Hiltjo Posthuma e71d009bd1 mount: add defaults option, it does nothing
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-04 20:09:26 +01:00
Hiltjo Posthuma 9031fcfd29 mount: mounted(): dont exit on non-fatal things
this fixes mount -a. proceed iterating fstab entries even if an error occurs with some entry.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-22 22:18:52 +00:00
Hiltjo Posthuma f1a747a0ca mount: use simple error status codes for now
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-22 22:18:37 +00:00
sin 6505db4709 Don't print errors for already mounted filesystems 2014-03-18 14:46:35 +00:00
sin e91b3d9e71 Fix indentation for mount(8)
No functional change intended.
2014-03-17 12:49:05 +00:00
Hiltjo Posthuma 55fa13016c mount: only use source if not set
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-16 04:04:10 +00:00
sin df9e438843 Only complain for a missing /etc/fstab
Avoids complaining for /proc/mounts while mounting procfs.
2014-03-15 19:30:43 +00:00
Hiltjo Posthuma 023c8e0414 mount: use mount error status code when mount failed
this matches other mount implementations

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 19:30:20 +00:00
Hiltjo Posthuma bd994c3a50 mount: fix bug where target mountpoint would not be used
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 19:30:03 +00:00
Hiltjo Posthuma a056e2aa54 mount: match mountpoint error message with util-linux
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 19:29:40 +00:00
Hiltjo Posthuma 9af24d8a29 mount: show devicename in error output for clarity
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 19:29:21 +00:00
Hiltjo Posthuma 7569fd3805 mount: match on source rule too if argument is set
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 17:52:10 +00:00
Hiltjo Posthuma 5b5cb8447e mount: if no options flag given, use matched mount rule options
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 17:52:02 +00:00
Hiltjo Posthuma 781cf0ed52 mount: implement some error status codes for mount -a
see mount man page:
32: all failed.
64: some failed.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 17:51:46 +00:00
Hiltjo Posthuma c444139aea mount: just set data empty in declaration
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-03-15 17:51:32 +00:00
sin 6c926cd1d4 Use weprintf() instead of fprintf() for mount(8) 2014-03-15 14:01:59 +00:00
Hiltjo Posthuma 35e3f401ab Major mount(8) refactor 2014-03-15 13:27:02 +00:00
sin 4879ea07b4 Implement mount -a
This code needs refactoring.
2014-03-11 19:47:08 +00:00
sin d0dc4dc2b7 Fix some more instances of enprintf(EXIT_FAILURE, ...); 2014-02-27 15:10:39 +00:00
sin 3f98a7abc8 Convert mount(8) to mntent and kill grabmntinfo.[ch] 2014-02-24 13:44:15 +00:00
Hiltjo Posthuma f8f4a96cc1 mount: siz variable can potentially be used uninitialized
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-02-14 14:10:45 +00:00
sin 5b0d03acc6 Free minfo table 2014-01-25 22:34:30 +00:00
sin 0476f601b2 Fix alignment for table `optnames[]' 2013-10-28 16:53:21 +00:00
s-p-k e340e1373e exit with EXIT_SUCCESS/EXIT_FAILURE 2013-10-07 19:15:00 +01:00
sin 713f1cfdb2 Handle correctly the -n option for mount and umount 2013-09-06 11:01:03 +01:00
sin 65e02d66b5 We do not update /etc/mtab for mount/umount - update usage 2013-09-04 10:55:44 +01:00
sin 80c3bdae3d Keep a list of all mount options
This makes it easier to parse all other options as well.
2013-09-03 14:34:15 +01:00
sin 818794af45 Set target to argv[0] - this is a bit more clear 2013-09-03 14:01:01 +01:00
sin 7afa5b8791 Make mount(8) work based on device id and inode number 2013-08-31 17:39:17 +01:00
sin f6cf690aa2 Fix usage lines 2013-08-14 14:40:49 +01:00
sin 97cbad7eef Remove OpenBSD support
This is becoming a nightmare.  Just support Linux.
2013-08-14 14:40:47 +01:00
sin 92c3390657 Add mount(8) 2013-08-14 13:51:50 +01:00