mirror of
https://github.com/troglobit/finit.git
synced 2026-10-23 11:44:37 +00:00
Add makepath() to avoid forking mkdir
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
145da5712c
commit
7c3e97c18b
2 files changed
+23
-12
No files matched your search
@@ -9,15 +9,7 @@ LIBS =
|
|||||||
|
|
||||||
all: finit finit-mod finit-mdv
|
all: finit finit-mod finit-mdv
|
||||||
|
|
||||||
finit: finit.o
|
%: %.o
|
||||||
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
|
||||||
strip $@
|
|
||||||
|
|
||||||
finit-mod: finit-mod.o
|
|
||||||
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
|
||||||
strip $@
|
|
||||||
|
|
||||||
finit-mdv: finit-mdv.o
|
|
||||||
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
$(LD) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||||
strip $@
|
strip $@
|
||||||
|
|
||||||
|
|||||||
+22
-3
@@ -27,7 +27,9 @@ THE SOFTWARE.
|
|||||||
Changelog from the original Eeepc fastinit:
|
Changelog from the original Eeepc fastinit:
|
||||||
|
|
||||||
- Use mknod() instead of close(creat()) call to create empty file
|
- Use mknod() instead of close(creat()) call to create empty file
|
||||||
|
- Fix random seed initialization
|
||||||
|
- Don't try to handle signal 0
|
||||||
|
- Implement makepath() to avoid system("mkdir -p")
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -61,6 +63,23 @@ Changelog from the original Eeepc fastinit:
|
|||||||
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
#define touch(x) mknod((x), S_IFREG|0644, 0)
|
||||||
|
|
||||||
|
|
||||||
|
int makepath(char *p)
|
||||||
|
{
|
||||||
|
char *x, path[PATH_MAX];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
x = path;
|
||||||
|
|
||||||
|
do {
|
||||||
|
do { *x++ = *p++; } while (*p && *p != '/');
|
||||||
|
ret = mkdir(path, 0777);
|
||||||
|
} while (*p && (*p != '/' || *(p + 1))); /* ignore trailing slash */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void shutdown(int);
|
void shutdown(int);
|
||||||
void signal_handler(int);
|
void signal_handler(int);
|
||||||
void chld_handler(int);
|
void chld_handler(int);
|
||||||
@@ -145,8 +164,8 @@ int main()
|
|||||||
/*
|
/*
|
||||||
* Network stuff
|
* Network stuff
|
||||||
*/
|
*/
|
||||||
system("mkdir -p /dev/shm/network");
|
makepath("/dev/shm/network");
|
||||||
system("mkdir -p /dev/shm/resolvconf/interface");
|
makepath("/dev/shm/resolvconf/interface");
|
||||||
|
|
||||||
if ((dir = opendir("/etc/resolvconf/run/interface")) != NULL) {
|
if ((dir = opendir("/etc/resolvconf/run/interface")) != NULL) {
|
||||||
while ((d = readdir(dir)) != NULL) {
|
while ((d = readdir(dir)) != NULL) {
|
||||||
|
|||||||
Reference in new issue
Block a user