}
-/*
- * 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.
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);