diff --git a/haggis.c b/haggis.c index 660e8ac..9ab43e1 100644 --- a/haggis.c +++ b/haggis.c @@ -39,6 +39,7 @@ #include // PATH_MAX #include // size_t #include // uint_t +#include #if defined(__FreeBSD__) || defined(__DragonFly__) #include @@ -886,11 +887,16 @@ int haggis_extract_node(char *basedir, haggis_node *node, haggis_mq *mq) { switch (node->filetype.tag) { case block: case character: - if (geteuid() == 0) + if (geteuid() == 0) { ret = haggis_extract_dev(node, basedir); - // todo: Add message type for skipped file and add it to queue if we're - // not root when calling this. We want this to be a warning, but not a - // fatal error. + } else { + ret = -1; + msg = calloc(1, sizeof(haggis_msg)); + if (msg == NULL) return 2; + msg->tag = DevNodeSkipped; + msg->body.f_name = strndup(node->name.name, PATH_MAX); + haggis_mq_push(mq, msg); + } break; case fifo: ret = haggis_extract_fifo(node, basedir); diff --git a/include/haggis.h b/include/haggis.h index b089e56..78ccc79 100644 --- a/include/haggis.h +++ b/include/haggis.h @@ -135,6 +135,7 @@ typedef struct { } haggis_linkmap; typedef enum { + DevNodeSkipped, NodeCreated, NodeExtracted, EndOfArchive, diff --git a/include/mq.h b/include/mq.h index d4d94c0..13a810d 100644 --- a/include/mq.h +++ b/include/mq.h @@ -37,6 +37,7 @@ #include "haggis.h" haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body); +void haggis_msg_deinit(haggis_msg *msg); int haggis_mq_init(haggis_mq *mq); int haggis_mq_push(haggis_mq *queue, haggis_msg *msg); haggis_msg* haggis_mq_pop(haggis_mq *queue); diff --git a/mq.c b/mq.c index b3d25e5..a41af1c 100644 --- a/mq.c +++ b/mq.c @@ -48,6 +48,7 @@ haggis_msg* haggis_msg_init(haggis_message_type tag, haggis_message_body body) { void haggis_msg_deinit(haggis_msg *msg) { switch (msg->tag) { + case DevNodeSkipped: case NodeCreated: case NodeExtracted: free(msg->body.f_name);