1 #include "bsdtar_platform.h"
2 
3 #include "chunks_internal.h"
4 
5 #include "chunks.h"
6 
7 /**
8  * chunks_transaction_checkpoint(cachepath):
9  * Mark the pending checkpoint in the cache directory ${cachepath} as being
10  * ready to commit from the perspective of the chunk layer.
11  */
12 int
chunks_transaction_checkpoint(const char * cachepath)13 chunks_transaction_checkpoint(const char * cachepath)
14 {
15 
16 	if (chunks_directory_commit(cachepath, ".ckpt", ".tmp"))
17 		goto err0;
18 
19 	/* Success! */
20 	return (0);
21 
22 err0:
23 	/* Failure! */
24 	return (-1);
25 }
26 
27 /**
28  * chunks_transaction_commit(cachepath):
29  * Commit the last finished transaction in the cache directory ${cachepath}
30  * from the perspective of the chunk layer.
31  */
32 int
chunks_transaction_commit(const char * cachepath)33 chunks_transaction_commit(const char * cachepath)
34 {
35 
36 	/*
37 	 * The only data belonging to the chunk layer which is stored in the
38 	 * cache directory ${cachepath} is the chunk directory; so tell that
39 	 * code to handle the commit.
40 	 */
41 	if (chunks_directory_commit(cachepath, ".tmp", ""))
42 		goto err0;
43 
44 	/* Success! */
45 	return (0);
46 
47 err0:
48 	/* Failure! */
49 	return (-1);
50 }
51