summaryrefslogtreecommitdiffstats
path: root/main/alpine-baselayout/mkmntdirs.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-07-12 11:19:01 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-07-12 11:19:01 +0000
commite1a9254211b885e6e44538e53dc3f9f341f261f0 (patch)
tree55f5de017ec0f440b692f459910c405f2d3bedc3 /main/alpine-baselayout/mkmntdirs.c
parentc38530c6e97a0b879b3a5d9a4c5d5dc39e592cbc (diff)
downloadaports-e1a9254211b885e6e44538e53dc3f9f341f261f0.tar.bz2
aports-e1a9254211b885e6e44538e53dc3f9f341f261f0.tar.xz
main/alpine-baselayout: upgrade to 2.3.0 and refactor
- host the entire project in aports directly. We will most likely have any changes directly so it does not make sense to host it in separate git repository - set permissions on /etc/shadow on post-install/upgrade - remove floppy and /proc/bus/usb from /etc/fstab - remove qmail user and group. we dont have qmail
Diffstat (limited to 'main/alpine-baselayout/mkmntdirs.c')
-rw-r--r--main/alpine-baselayout/mkmntdirs.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/main/alpine-baselayout/mkmntdirs.c b/main/alpine-baselayout/mkmntdirs.c
new file mode 100644
index 000000000..6e3a3ef21
--- /dev/null
+++ b/main/alpine-baselayout/mkmntdirs.c
@@ -0,0 +1,66 @@
+/*
+ * Create mount directories in fstab
+ *
+ * Copyright(c) 2008 Natanael Copa <natanael.copa@gmail.com>
+ * May be distributed under the terms of GPL-2
+ *
+ * usage: mkmntdirs [fstab]
+ *
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <err.h>
+#include <mntent.h>
+#include <stdio.h>
+
+
+#ifdef DEBUG
+#define mkdir_recursive(p) puts((p))
+#else
+static void mkdir_recursive(char *path)
+{
+ char *s = path;
+ while (1) {
+ int c = '\0';
+ while (*s) {
+ if (*s == '/') {
+ do {
+ ++s;
+ } while (*s == '/');
+ c = *s; /* Save the current char */
+ *s = '\0'; /* and replace it with nul. */
+ break;
+ }
+ ++s;
+ }
+ mkdir(path, 0755);
+ if (c == '\0')
+ return;
+ *s = c;
+ }
+}
+#endif
+
+int main(int argc, const char *argv[])
+{
+ const char *filename = "/etc/fstab";
+ FILE *f;
+ struct mntent *ent;
+ if (argc == 2)
+ filename = argv[1];
+
+ f = setmntent(filename, "r");
+ if (f == NULL)
+ err(1, "%s", filename);
+
+ while ((ent = getmntent(f)) != NULL) {
+ if (strcmp(ent->mnt_dir, "none") != 0)
+ mkdir_recursive(ent->mnt_dir);
+ }
+
+ endmntent(f);
+ return 0;
+}
+