summaryrefslogtreecommitdiffstats
path: root/isys/imount.c
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-05-05 17:17:58 +0000
committerErik Troan <ewt@redhat.com>1999-05-05 17:17:58 +0000
commit79ebb2cf474e61eebc6074752a95f072bc99c86f (patch)
tree1cc3192c7daeb644768e9deaa3516373e95da4b4 /isys/imount.c
parentea77c9194962d9ba82b8a9f95de5ec4c24a6b612 (diff)
downloadanaconda-79ebb2cf474e61eebc6074752a95f072bc99c86f.tar.gz
anaconda-79ebb2cf474e61eebc6074752a95f072bc99c86f.tar.xz
anaconda-79ebb2cf474e61eebc6074752a95f072bc99c86f.zip
added lilo, filesystem magic
Diffstat (limited to 'isys/imount.c')
-rw-r--r--isys/imount.c66
1 files changed, 58 insertions, 8 deletions
diff --git a/isys/imount.c b/isys/imount.c
index fb2c9bae2..0d7e24d26 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -3,11 +3,15 @@
#include <string.h>
#include <sys/errno.h>
#include <sys/mount.h>
+#include <unistd.h>
#include "imount.h"
#define _(foo) foo
+static int mkdirChain(char * chain);
+static int mkdirIfNone(char * directory);
+
int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
char * acct, char * pw) {
char * buf = NULL;
@@ -22,7 +26,7 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
if (!strcmp(fs, "smb")) {
#if 0 /* disabled for now */
- /*mkdirChain(where);*/
+ mkdirChain(where);
if (!acct) acct = "guest";
if (!pw) pw = "";
@@ -33,7 +37,7 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
while (*chptr && *chptr != ':') chptr++;
if (!*chptr) {
/*logMessage("bad smb mount point %s", where);*/
- return 0;
+ return IMOUNT_ERR_OTHER;
}
*chptr = '\0';
@@ -48,7 +52,8 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
#endif
#endif /* disabled */
} else {
- /*mkdirChain(where);*/
+ if (mkdirChain(where))
+ return IMOUNT_ERR_ERRNO;
if (!isnfs && *dev == '/') {
buf = dev;
@@ -67,9 +72,9 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
if (nfsmount(buf, where, &flags, &extra_opts, &mount_opt)) {
/*logMessage("\tnfsmount returned non-zero");*/
- fprintf(stderr, "nfs mount failed: %s\n",
- nfs_error());
- return 1;
+ /*fprintf(stderr, "nfs mount failed: %s\n",
+ nfs_error());*/
+ return IMOUNT_ERR_OTHER;
}
#endif
}
@@ -84,11 +89,56 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
flag, mount_opt);*/
if (mount(buf, where, fs, flag, mount_opt)) {
- fprintf(stderr, "mount failed: %s\n", strerror(errno));
- return 1;
+ return IMOUNT_ERR_ERRNO;
}
}
return 0;
}
+static int mkdirChain(char * origChain) {
+ char * chain;
+ char * chptr;
+
+ chain = alloca(strlen(origChain) + 1);
+ strcpy(chain, origChain);
+ chptr = chain;
+
+ while ((chptr = strchr(chptr, '/'))) {
+ *chptr = '\0';
+ if (mkdirIfNone(chain)) {
+ *chptr = '/';
+ return IMOUNT_ERR_ERRNO;
+ }
+
+ *chptr = '/';
+ chptr++;
+ }
+
+ if (mkdirIfNone(chain))
+ return IMOUNT_ERR_ERRNO;
+
+ return 0;
+}
+
+static int mkdirIfNone(char * directory) {
+ int rc, mkerr;
+ char * chptr;
+
+ /* If the file exists it *better* be a directory -- I'm not going to
+ actually check or anything */
+ if (!access(directory, X_OK)) return 0;
+
+ /* if the path is '/' we get ENOFILE not found" from mkdir, rather
+ then EEXIST which is weird */
+ for (chptr = directory; *chptr; chptr++)
+ if (*chptr != '/') break;
+ if (!*chptr) return 0;
+
+ rc = mkdir(directory, 0755);
+ mkerr = errno;
+
+ if (!rc || mkerr == EEXIST) return 0;
+
+ return IMOUNT_ERR_ERRNO;
+}