summaryrefslogtreecommitdiffstats
path: root/dlm/dlm_kill/dlm_lockspace.c
blob: 35b6c8d00f7c290d84377c8cda060d957a603d81 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Copyright (c) 2010 David Teigland
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License V2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <sys/types.h>
#include <sys/uio.h>
#include <sys/poll.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>

#include "libdlm.h"

int quit;

void sigterm_handler(int sig)
{
	printf("sigterm\n");
	quit = 1;
}

int main(int argc, char *argv[])
{
	dlm_lshandle_t ls;
	int rv;

	signal(SIGTERM, sigterm_handler);

	printf("pid %d\n", getpid());
	printf("creating default lockspace...\n");

	ls = dlm_create_lockspace("default", 0444);
	if (!ls) {
		fprintf(stderr, "dlm_create_lockspace error %d\n", errno);
		return -1;
	}
	printf("done\n");

	while (!quit)
		pause();

	printf("releasing default lockspace...\n");

	rv = dlm_release_lockspace("default", ls, 1);
	if (rv) {
		fprintf(stderr, "dlm_release_lockspace error %d %d\n", rv, errno);
		return -1;
	}
	printf("done\n");

	return 0;
}