diff --git a/README.md b/README.md index c7c3a7a..dd9329f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ the `Destdir` pattern for ease of packaging. There is a simple test harness which can be invoked via `make test`. If you wish to port this software to an untested platform the tests will greatly assist in that process. +> Note: if your OS uses **dash** as `/bin/sh` then the builtin echo command will not +> be up to the task of printing the escape sequences used by the test runner. If this +> bothers you, you can call `make` with the `SHELL` environment variable overridden +> by calling `make SHELL=/bin/bash all test`. ## Contributing Contributions are always welcome and can be made via pull request or `git send-email`, diff --git a/haggis.c b/haggis.c index 6d963f7..46d6a70 100644 --- a/haggis.c +++ b/haggis.c @@ -355,8 +355,6 @@ int haggis_load_file(FILE *stream, haggis_file *f) { return -1; int res = fread(f->data, 1, (size_t)f->len.val, stream); if (res != (size_t)f->len.val) { - fprintf(stderr, "Error reading file:\n length: %i\n expected: %lu\n", - res, f->len.val); free(f->data); return 1; } @@ -751,6 +749,8 @@ int haggis_extract_dev(haggis_node *node, char *basedir) { } else if (node->filetype.tag == character) { mode = (mode_t)node->mode.val | S_IFCHR; } + if (access(path, F_OK) == 0) + unlink(path); ret = mknod(path, mode, dev); free(path); return ret; @@ -782,6 +782,7 @@ int haggis_extract_fifo(haggis_node *node, char *basedir) { int haggis_extract_symlink(haggis_node *node, char *basedir) { char *path, *target; int ret; + struct stat st; assert(node->filetype.tag == softlink); path = get_full_path(&node->name, basedir); @@ -792,7 +793,7 @@ int haggis_extract_symlink(haggis_node *node, char *basedir) { return 2; } target = node->filetype.target.name; - if (access(path, F_OK) == 0) + if (lstat(path, &st) == 0) unlink(path); ret = symlink(target, path); free(path); @@ -870,7 +871,7 @@ char* haggis_extract_file(haggis_node *node, char *basedir) { free(path); return NULL; } - fd = fopen(path, "w"); + fd = fopen(path, "w+"); if (fd == NULL) { free(path); return NULL; @@ -938,7 +939,8 @@ int haggis_extract_node(haggis_node *self, char *basedir, haggis_mq *mq) { return errno; } } - ret = chmod(path, (mode_t)self->mode.val); + if (self->filetype.tag != softlink) + ret = chmod(path, (mode_t)self->mode.val); if (ret) return ret; msg = calloc(1, sizeof(haggis_msg)); if (msg == NULL)