File: simple.c

package info (click to toggle)
rdiff-backup-fs 1.0.0-8
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: sh: 3,800; ansic: 2,944; makefile: 23
file content (51 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "simple.h"
#include "support.h"
#include "support/gutils.h"

int __release_simple(struct stats *, int);

// public:

int retrieve_simple(struct file_system_info *fsinfo, struct stats *stats){

	int repo = 0;
	
	debug(2, "Retrieving file %s;\n", stats->path);
	if ((repo = repo_number(fsinfo, stats->path)) == -1)
		return -1;
    return retrieve_common(fsinfo, stats, repo);
		
};

int release_simple(struct file_system_info *fsinfo, struct stats *stats){

	int repo = 0;
	
	debug(2, "Releasing file %s from revision %dB;\n", stats->path, stats->rev);
	if ((repo = repo_number(fsinfo, stats->path)) == -1)
		return -1;
	return __release_simple(stats, repo);
		
};

// private:

int __release_simple(struct stats *stats, int index){

#define __release_simple_finish(value){						\
			unlock(file_mutex[index][stats->rev]);			\
			return value;									\
		}

	lock(file_mutex[index][stats->rev]);
    node_t *node = get_open_file(stats->path);
    if (!node)
        return -1;
	node->count--;
	if (node->count == 0){
		unlink(node->tmp_path);
        delete_open_file(node);
	};
	__release_simple_finish(0);

};