summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2009-11-19 10:14:30 +0100
committerAles Kozumplik <akozumpl@redhat.com>2009-11-19 10:16:34 +0100
commit436da6753f80dfafcfc242a2b08fccb81bf83ab9 (patch)
treea8271fc3c4fadfa4f388c4b05244f3e3a0488840 /isys
parent46312dc05b61d7fd18fe9710461eb9b0a9118607 (diff)
downloadanaconda-436da6753f80dfafcfc242a2b08fccb81bf83ab9.tar.gz
anaconda-436da6753f80dfafcfc242a2b08fccb81bf83ab9.tar.xz
anaconda-436da6753f80dfafcfc242a2b08fccb81bf83ab9.zip
Sleep if the kickstart file read fails (#537361)
If a read from a block device (like USB key) or a cdrom (USB cdrom) fails, sleep a bit to give the device some time to initialize. Return status of the mount command is checked so waiting occurs only if there is a reasonable chance that the device might eventually come online. This required extending our existing mounting methods to report the correct mount error code. I tested that * the installer still runs * reading the kickstart from a usb works * starting the installer with no USB key inserted but a command line argument pointing to a USB drive will trigger the waiting cycle and that when the key is inserted while waiting the kickstart is eventually found on the key.
Diffstat (limited to 'isys')
-rw-r--r--isys/imount.c41
-rw-r--r--isys/imount.h14
2 files changed, 50 insertions, 5 deletions
diff --git a/isys/imount.c b/isys/imount.c
index a62e22398..13dca03e0 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -189,8 +189,29 @@ int mountCommandWrapper(int mode, char *dev, char *where, char *fs,
free(device);
}
- if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status)))
- return IMOUNT_ERR_OTHER;
+ if (!WIFEXITED(status))
+ return IMOUNT_ERR_OTHER;
+ else if ( (rc = WEXITSTATUS(status)) ) {
+ /* Refer to 'man mount' for the meaning of the error codes. */
+ switch (rc) {
+ case 1:
+ return IMOUNT_ERR_PERMISSIONS;
+ case 2:
+ return IMOUNT_ERR_SYSTEM;
+ case 4:
+ return IMOUNT_ERR_MOUNTINTERNAL;
+ case 8:
+ return IMOUNT_ERR_USERINTERRUPT;
+ case 16:
+ return IMOUNT_ERR_MTAB;
+ case 32:
+ return IMOUNT_ERR_MOUNTFAILURE;
+ case 64:
+ return IMOUNT_ERR_PARTIALSUCC;
+ default:
+ return IMOUNT_ERR_OTHER;
+ }
+ }
return 0;
}
@@ -230,6 +251,22 @@ int mkdirChain(char * origChain) {
return 0;
}
+/* Returns true iff it is possible that the mount command that have returned
+ * 'errno' might succeed at a later time (think e.g. not yet initialized USB
+ * device, etc.) */
+int mountMightSucceedLater(int mountRc)
+{
+ int rc;
+ switch (mountRc) {
+ case IMOUNT_ERR_MOUNTFAILURE:
+ rc = 1;
+ break;
+ default:
+ rc = 0;
+ }
+ return rc;
+}
+
static int mkdirIfNone(char * directory) {
int rc, mkerr;
char * chptr;
diff --git a/isys/imount.h b/isys/imount.h
index 95cca38d5..9fa67698a 100644
--- a/isys/imount.h
+++ b/isys/imount.h
@@ -20,9 +20,16 @@
#ifndef H_IMOUNT
#define H_IMOUNT
-#define IMOUNT_ERR_ERRNO 1
-#define IMOUNT_ERR_OTHER 2
-#define IMOUNT_ERR_MODE 3
+#define IMOUNT_ERR_ERRNO 1
+#define IMOUNT_ERR_OTHER 2
+#define IMOUNT_ERR_MODE 3
+#define IMOUNT_ERR_PERMISSIONS 4
+#define IMOUNT_ERR_SYSTEM 5
+#define IMOUNT_ERR_MOUNTINTERNAL 6
+#define IMOUNT_ERR_USERINTERRUPT 7
+#define IMOUNT_ERR_MTAB 8
+#define IMOUNT_ERR_MOUNTFAILURE 9
+#define IMOUNT_ERR_PARTIALSUCC 10
#include <sys/mount.h> /* for umount() */
@@ -36,5 +43,6 @@
int doPwMount(char *dev, char *where, char *fs, char *options, char **err);
int doPwUmount(char *where, char **err);
int mkdirChain(char * origChain);
+int mountMightSucceedLater(int mountRc);
#endif