summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2012-08-07 22:48:58 +0200
committerAndreas Gruenbacher <agruen@linbit.com>2012-08-08 13:10:41 +0200
commite294241b865ed2262ba84ebfc0ac982cdf33c479 (patch)
tree32cf265d4663ce56ad30915b912b101600748a71
parent3980c923dce77f63cf6653b5941e0500bed48447 (diff)
downloadpatch-e294241b865ed2262ba84ebfc0ac982cdf33c479.tar.gz
In the file id cache, allow to flag files in the output queue
* src/util.c (file_id): Add queued_output field. (__insert_file_id): Initialize queued_output. (set_queued_output, has_queued_output): New functions. * src/util.h (set_queued_output, has_queued_output): Declare.
-rw-r--r--src/util.c20
-rw-r--r--src/util.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 9177fda..1bd41b8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -58,6 +58,7 @@ typedef struct
dev_t dev;
ino_t ino;
enum file_id_type type;
+ bool queued_output;
char *sha1;
} file_id;
@@ -104,6 +105,7 @@ __insert_file_id (struct stat const *st, enum file_id_type type)
next_slot = xmalloc (sizeof *next_slot);
next_slot->dev = st->st_dev;
next_slot->ino = st->st_ino;
+ next_slot->queued_output = false;
next_slot->sha1 = 0;
p = hash_insert (file_id_table, next_slot);
if (!p)
@@ -145,6 +147,24 @@ lookup_file_id (struct stat const *st)
}
void
+set_queued_output (struct stat const *st, bool queued_output)
+{
+ file_id *p = __lookup_file_id (st);
+
+ if (! p)
+ p = __insert_file_id (st, UNKNOWN);
+ p->queued_output = queued_output;
+}
+
+bool
+has_queued_output (struct stat const *st)
+{
+ file_id *p = __lookup_file_id (st);
+
+ return p && p->queued_output;
+}
+
+void
update_sha1 (struct stat const *st, char const *sha1)
{
file_id *p = __lookup_file_id (st);
diff --git a/src/util.h b/src/util.h
index 2913b15..2f81c78 100644
--- a/src/util.h
+++ b/src/util.h
@@ -66,6 +66,8 @@ void set_signals (bool);
void write_fatal (void) __attribute__ ((noreturn));
void insert_file_id (struct stat const *, enum file_id_type);
enum file_id_type lookup_file_id (struct stat const *);
+void set_queued_output (struct stat const *, bool);
+bool has_queued_output (struct stat const *);
void update_sha1(struct stat const *, char const *);
char const *lookup_sha1 (struct stat const *);