From: Michal Luscon Date: Wed, 8 Feb 2012 15:14:38 +0000 (+0100) Subject: eject: remove MountableDevice function X-Git-Tag: v2.22-rc1~555^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=035ed966a4abe35276c1f60bfea0d31ace667e52;p=thirdparty%2Futil-linux.git eject: remove MountableDevice function Signed-off-by: Michal Luscon --- diff --git a/misc-utils/eject.c b/misc-utils/eject.c index 974e566aa2..8d8a8bf3fc 100644 --- a/misc-utils/eject.c +++ b/misc-utils/eject.c @@ -681,47 +681,6 @@ static int MountedDevice(const char *name, char **mountName, char **deviceName) } -/* - * See if device can be mounted by looking in /etc/fstab. - * If so, set device name and mount point name, and return 1, - * otherwise return 0. - */ -static int MountableDevice(const char *name, char **mountName, char **deviceName) -{ - FILE *fp; - char line[1024]; - char s1[1024]; - char s2[1024]; - int rc; - - fp = fopen("/etc/fstab", "r"); - if (fp == NULL) { -/* - * /etc/fstab may be unreadable in some situations due to passwords in the - * file. - */ -/* fprintf(stderr, _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno)); - exit(1);*/ - if (v_option) { - warn( _("unable to open /etc/fstab") ); - } - return -1; - } - - while (fgets(line, sizeof(line), fp) != 0) { - rc = sscanf(line, "%1023s %1023s", s1, s2); - if (rc >= 2 && s1[0] != '#' && strcmp(s2, name) == 0) { - e_fclose(fp); - *deviceName = strdup(s1); - *mountName = strdup(s2); - return 1; - } - } - e_fclose(fp); - return 0; -} - - /* * Step through mount table and unmount all devices that match a regular * expression. @@ -900,18 +859,6 @@ int main(int argc, char **argv) deviceName = strdup(fullName); } - /* if not currently mounted, see if it is a possible mount point */ - if (!mounted) { - mountable = MountableDevice(fullName, &mountName, &deviceName); - /* if return value -1 then fstab could not be read */ - if (v_option && mountable >= 0) { - if (mountable) - printf(_("%s: `%s' can be mounted at `%s'\n"), programName, deviceName, mountName); - else - printf(_("%s: `%s' is not a mount point\n"), programName, fullName); - } - } - /* handle -n option */ if (n_option) { printf(_("%s: device is `%s'\n"), programName, deviceName);