summaryrefslogtreecommitdiff
path: root/sqlfs_txn_cmd.c
blob: 6a4c51034a2cf180a6fd80411799efc7bf72b67b (plain)
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
#include <sys/types.h>
#include <sys/xattr.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

#define DB_START_TRANS_XATTR_NAME "full_db_transaction_start"
#define DB_STOP_TRANS_XATTR_NAME "full_db_transaction_stop"
#define DB_RB_TRANS_XATTR_NAME "full_db_transaction_rb"
#define DB_TRANS_ONLY_CHECK "full_db_transaction_check"

int main(int argc, char** argv)
{
	int pid;

	pid = getpid();
	if(argc < 3){
		printf("%s <path> <cmd>\n", argv[0]);
		printf("ex) %s /opt/var/kdb/db \"cp -a db_bak/* db\"\n", argv[0]);
		return -1;
	}

	if(setxattr(argv[1], DB_START_TRANS_XATTR_NAME, &pid, sizeof(pid), 0) == -1)
		printf("start failed\n");

	system(argv[2]);

	if(setxattr(argv[1], DB_STOP_TRANS_XATTR_NAME, &pid, sizeof(pid), 0) == -1)
		printf("stop failed\n");

	sync();

	return 0;
}