※ リポジトリは、pm-diskd ブランチが https://github.com/linux-ha-japan/pm_diskd-1.0 へ、pm-diskd-2.0ブランチが https://github.com/linux-ha-japan/pm_diskd へ移行しました。
Pacemaker 対応ディスク故障監視機能。
Pacemaker-1.0公式リポジトリのクローンに対し、パッチ作成用のブランチを作成して管理する。
ブランチ名: pm-diskd
初回 hg clone 実行後は、hg update -r pm-diskd を実行すること。
Heartbeat-2.1.4 用 hb-diskd(*) のPacemaker対応版
(*) http://sourceforge.jp/projects/linux-ha/releases/?package_id=10555
修訂 | c0120717ece7a045c5a9edb048743a014eaa1f9e (tree) |
---|---|
時間 | 2013-02-19 14:33:39 |
作者 | Yuusuke Iida <iidayuus@inte...> |
Commiter | Yuusuke Iida |
The code was corrected in order to make it cooperate with pacemaker-1.1.
@@ -5,7 +5,7 @@ | ||
5 | 5 | MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure |
6 | 6 | |
7 | 7 | SUBDIRS = tools resources |
8 | -doc_DATA = README | |
8 | +doc_DATA = README | |
9 | 9 | |
10 | 10 | SPEC = $(PACKAGE_NAME).spec |
11 | 11 | TARFILE = $(PACKAGE_NAME)-$(VERSION).tar.gz |
@@ -2,7 +2,7 @@ | ||
2 | 2 | # Process this file with autoconf to produce a configure script. |
3 | 3 | |
4 | 4 | AC_PREREQ([2.53]) |
5 | -AC_INIT([pm_diskd], [1.2], BUG-REPORT-ADDRESS) | |
5 | +AC_INIT([pm_diskd], [2.0], BUG-REPORT-ADDRESS) | |
6 | 6 | AM_INIT_AUTOMAKE |
7 | 7 | |
8 | 8 | # Checks for programs. |
@@ -28,8 +28,6 @@ | ||
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | -# Checks for libraries. | |
32 | - | |
33 | 31 | # Checks for typedefs, structures, and compiler characteristics. |
34 | 32 | dnl Fix default variables - "prefix" variable if not specified |
35 | 33 | if test "$prefix" = "NONE"; then |
@@ -53,51 +51,56 @@ | ||
53 | 51 | fi |
54 | 52 | fi |
55 | 53 | |
56 | -# Checks for header files. | |
57 | -CFLAGS="$CFLAGS -I${prefix}/include/heartbeat" | |
58 | -CFLAGS="$CFLAGS -I${prefix}/include/pacemaker" | |
54 | +dnl =============================================== | |
55 | +dnl Libraries | |
56 | +dnl =============================================== | |
59 | 57 | |
60 | -AC_CHECK_HEADERS([hb_config.h]) | |
61 | -AC_CHECK_HEADERS([glue_config.h]) | |
62 | -AC_CHECK_HEADERS([agent_config.h]) | |
58 | +dnl check for pacemaker | |
59 | +PKG_CHECK_MODULES(CRM, pacemaker-cluster) | |
60 | +LIBS="$LIBS $CRM_LIBS" | |
63 | 61 | |
64 | -GLUE_HEADER=none | |
65 | -if test "$ac_cv_header_glue_config_h" = "yes"; then | |
66 | - GLUE_HEADER=glue_config.h | |
67 | -elif test "$ac_cv_header_hb_config_h" = "yes"; then | |
68 | - GLUE_HEADER=hb_config.h | |
69 | -else | |
70 | - AC_MSG_FAILURE(Core development headers were not found) | |
62 | +dnl check for gthread | |
63 | +PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.0, have_gthread=yes, have_gthread=no) | |
64 | +AM_CONDITIONAL(HAVE_GTHREAD, test x$have_gthread = xyes) | |
65 | +if test x"$have_gthread" = xyes; then | |
66 | + CFLAGS="$CFLAGS $GTHREAD_CFLAGS" | |
67 | + LIBS="$LIBS $GTHREAD_LIBS" | |
71 | 68 | fi |
72 | 69 | |
73 | -OCF_RA_DIR=`extract_header_define $GLUE_HEADER OCF_RA_DIR` | |
74 | -AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", ocf resource directory) | |
75 | -AC_SUBST(OCF_RA_DIR) | |
70 | +dnl ======================================================================== | |
71 | +dnl Headers | |
72 | +dnl ======================================================================== | |
73 | + | |
74 | +AC_CHECK_HEADER([pacemaker/crm_config.h]) | |
75 | + | |
76 | +AC_PATH_PROGS(XML2CONFIG, xml2-config) | |
77 | +AC_MSG_CHECKING(for special libxml2 includes) | |
78 | +if test "x$XML2CONFIG" = "x"; then | |
79 | + AC_MSG_ERROR(libxml2 config not found) | |
80 | +else | |
81 | + XML2HEAD="`$XML2CONFIG --cflags`" | |
82 | + AC_MSG_RESULT($XML2HEAD) | |
83 | +fi | |
84 | +CPPFLAGS="$CPPFLAGS $XML2HEAD" | |
85 | + | |
86 | + | |
87 | +#CFLAGS="$CFLAGS -I${prefix}/include/glib-2.0" | |
88 | +#CFLAGS="$CFLAGS -I${prefix}/lib64/glib-2.0/include" | |
89 | + | |
90 | +if test "$ac_cv_header_pacemaker_crm_config_h" = "yes"; then | |
91 | + CFLAGS="$CFLAGS -I${prefix}/include/pacemaker" | |
92 | +fi | |
93 | + | |
94 | +OCF_ROOT_DIR=`extract_header_define crm/services.h OCF_ROOT_DIR` | |
95 | +#AC_DEFINE_UNQUOTED(OCF_ROOT_DIR,"$OCF_ROOT_DIR", ocf resource directory) | |
96 | +AC_SUBST(OCF_ROOT_DIR) | |
76 | 97 | |
77 | 98 | CRM_DAEMON_DIR=`extract_header_define crm_config.h CRM_DAEMON_DIR` |
78 | -AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", crm daemon directory) | |
99 | +#AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", crm daemon directory) | |
79 | 100 | AC_SUBST(CRM_DAEMON_DIR) |
80 | 101 | |
81 | -CRM_DAEMON_GROUP=`extract_header_define $GLUE_HEADER HA_APIGROUP` | |
82 | -AC_DEFINE_UNQUOTED(CRM_DAEMON_GROUP,"$CRM_DAEMON_GROUP", Group to run Pacemaker daemons as) | |
83 | -AC_SUBST(CRM_DAEMON_GROUP) | |
84 | - | |
85 | -CRM_DAEMON_USER=`extract_header_define $GLUE_HEADER HA_CCMUSER` | |
86 | -AC_DEFINE_UNQUOTED(CRM_DAEMON_USER,"$CRM_DAEMON_USER", User to run Pacemaker daemons as) | |
87 | -AC_SUBST(CRM_DAEMON_USER) | |
88 | 102 | |
89 | -# | |
90 | -grep "release 6" /etc/redhat-release -q | |
91 | -if test $? = 0; then | |
92 | - rhelver=6 | |
93 | -else | |
94 | - rhelver=5 | |
95 | -fi | |
96 | -RHEL_VER="$rhelver" | |
97 | -AC_SUBST(RHEL_VER) | |
98 | - | |
99 | -# Checks for library functions. | |
100 | - | |
103 | +dnl The Makefiles and shell scripts we output | |
101 | 104 | AC_CONFIG_FILES(Makefile \ |
102 | 105 | resources/Makefile \ |
103 | 106 | tools/Makefile \ |
@@ -136,10 +139,11 @@ | ||
136 | 139 | AC_MSG_RESULT([ State information = ${localstatedir}]) |
137 | 140 | AC_MSG_RESULT([ System configuration = ${sysconfdir}]) |
138 | 141 | AC_MSG_RESULT([ Document directory = ${docdir}]) |
139 | -AC_MSG_RESULT([ Ocf RA dir = ${OCF_RA_DIR}]) | |
142 | +AC_MSG_RESULT([ Ocf RA dir = ${OCF_ROOT_DIR}]) | |
140 | 143 | AC_MSG_RESULT([]) |
141 | 144 | AC_MSG_RESULT([ HA group name = ${CRM_DAEMON_GROUP}]) |
142 | 145 | AC_MSG_RESULT([ HA user name = ${CRM_DAEMON_USER}]) |
143 | 146 | AC_MSG_RESULT([]) |
144 | 147 | AC_MSG_RESULT([ CFLAGS = ${CFLAGS}]) |
148 | +AC_MSG_RESULT([ Libraries = ${LIBS}]) | |
145 | 149 |
@@ -3,8 +3,8 @@ | ||
3 | 3 | ######################################## |
4 | 4 | %define __check_files %{nil} |
5 | 5 | %define name pm_diskd |
6 | -%define version 1.2 | |
7 | -%define release 1.el@RHEL_VER@ | |
6 | +%define version 2.0 | |
7 | +%define release 1%{?dist} | |
8 | 8 | %define prefix /usr |
9 | 9 | %define libdir %{_libdir} |
10 | 10 | %define orgarch pm_diskd-%{version} |
@@ -21,17 +21,16 @@ | ||
21 | 21 | License: GPL/LGPL |
22 | 22 | Vendor: NIPPON TELEGRAPH AND TELEPHONE CORPORATION |
23 | 23 | BuildRoot: %{_tmppath}/%{name}-%{version} |
24 | -BuildRequires: autoconf, automake, pacemaker-libs-devel >= 1.0.9, heartbeat-devel >= 3.0.3, cluster-glue-libs-devel >= 1.0.6 | |
25 | -Requires: pacemaker >= 1.0.9, resource-agents >= 1.0.3, cluster-glue >= 1.0.6, heartbeat >= 3.0.3 | |
24 | +BuildRequires: autoconf, automake | |
25 | +BuildRequires: pacemaker-libs-devel >= 1.1.8 | |
26 | +Requires: pacemaker-libs >= 1.1.8 | |
26 | 27 | |
27 | 28 | ######################################## |
28 | 29 | %description |
29 | 30 | pacemaker diskcheck service |
30 | - for pacemaker 1.0.9 | |
31 | + for pacemaker 1.1.8 | |
31 | 32 | and |
32 | - resoucr-agent 1.0.3 | |
33 | - and | |
34 | - cluster-glue 1.0.6 | |
33 | + cluster-glue 1.0.11 | |
35 | 34 | |
36 | 35 | ######################################## |
37 | 36 | %prep |
@@ -93,10 +92,10 @@ | ||
93 | 92 | %files |
94 | 93 | ######################################## |
95 | 94 | %defattr(-,root,root) |
96 | - | |
95 | +%doc README | |
97 | 96 | %dir %{ocfdir} |
98 | 97 | %attr (755, root, root) %{ocfdir}/diskd |
99 | -%attr (755, root, root) %{_libdir}/heartbeat/diskd | |
98 | +%attr (755, root, root) %{_libexecdir}/pacemaker/diskd | |
100 | 99 | |
101 | 100 | ######################################## |
102 | 101 | %changelog |
@@ -2,5 +2,5 @@ | ||
2 | 2 | |
3 | 3 | EXTRA_DIST = $(ocf_SCRIPTS) |
4 | 4 | |
5 | -ocfdir = $(OCF_RA_DIR)/pacemaker | |
5 | +ocfdir = $(OCF_ROOT_DIR)/resource.d/pacemaker | |
6 | 6 | ocf_SCRIPTS = diskd |
@@ -1,19 +1,16 @@ | ||
1 | 1 | MAINTAINERCLEANFILES = Makefile.in |
2 | 2 | |
3 | -INCLUDES = -I/usr/include/pacemaker \ | |
4 | - -I/usr/include/glib-2.0 \ | |
5 | - -I$(libdir)/glib-2.0/include \ | |
6 | - -I/usr/include/libxml2 | |
7 | - | |
8 | 3 | halibdir = $(CRM_DAEMON_DIR) |
9 | 4 | halib_PROGRAMS = diskd |
10 | 5 | |
11 | 6 | # BUILD |
12 | 7 | |
13 | 8 | diskd_SOURCES = diskd.c |
14 | -diskd_LDADD = -lcrmcommon \ | |
15 | - -lgthread-2.0 \ | |
16 | - -lcrmcluster | |
9 | +#diskd_LDADD = -lgthread-2.0 | |
10 | + | |
11 | +#diskd_LDADD = -lcrmcommon \ | |
12 | +# -lgthread-2.0 \ | |
13 | +# -lcrmcluster | |
17 | 14 | |
18 | 15 | |
19 | 16 | AM_CFLAGS = -Wall -Werror |
@@ -40,19 +40,13 @@ | ||
40 | 40 | #include <time.h> |
41 | 41 | #include <string.h> |
42 | 42 | |
43 | -#include <clplumbing/Gmain_timeout.h> | |
44 | -#include <clplumbing/lsb_exitcodes.h> | |
45 | - | |
46 | -#include <crm/crm.h> | |
47 | -#include <crm/common/util.h> | |
48 | -#include <crm/common/ipc.h> | |
43 | +#include <crm/attrd.h> | |
44 | +#include <crm/common/mainloop.h> | |
49 | 45 | |
50 | 46 | #ifdef HAVE_GETOPT_H |
51 | 47 | # include <getopt.h> |
52 | 48 | #endif |
53 | 49 | |
54 | -#include <glib.h> | |
55 | - | |
56 | 50 | #define MIN_INTERVAL 1 |
57 | 51 | #define MAX_INTERVAL 3600 |
58 | 52 | #define MIN_TIMEOUT 1 |
@@ -114,14 +108,15 @@ | ||
114 | 108 | static void diskd_thread_condsend(void); |
115 | 109 | static void diskd_thread_timer_end(void); |
116 | 110 | void send_update(void); |
111 | +void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile); | |
117 | 112 | |
118 | -static gboolean | |
119 | -diskd_shutdown(int nsig, gpointer unused) | |
113 | +static void | |
114 | +diskd_shutdown(int nsig) | |
120 | 115 | { |
121 | 116 | crm_info("Exiting"); |
122 | 117 | |
123 | 118 | if (timer_id != -1) { |
124 | - Gmain_timeout_remove(timer_id); | |
119 | + g_source_remove(timer_id); | |
125 | 120 | timer_id = -1; |
126 | 121 | } |
127 | 122 |
@@ -130,17 +125,16 @@ | ||
130 | 125 | if (mainloop != NULL && g_main_is_running(mainloop)) { |
131 | 126 | g_main_quit(mainloop); |
132 | 127 | } else { |
133 | - exit(0); | |
128 | + crm_exit(EX_OK); | |
134 | 129 | } |
135 | - return FALSE; | |
136 | 130 | } |
137 | 131 | |
138 | 132 | static void |
139 | -usage(const char *cmd, int exit_status) | |
133 | +usage(const char *cmd, int crm_exit_status) | |
140 | 134 | { |
141 | 135 | FILE *stream; |
142 | 136 | |
143 | - stream = exit_status ? stderr : stdout; | |
137 | + stream = crm_exit_status ? stderr : stdout; | |
144 | 138 | |
145 | 139 | fprintf(stream, "usage: %s (-N|-w) [-daipDV?trIoe]\n", cmd); |
146 | 140 | fprintf(stream, " Basic options\n"); |
@@ -174,7 +168,7 @@ | ||
174 | 168 | |
175 | 169 | fflush(stream); |
176 | 170 | |
177 | - exit(exit_status); | |
171 | + crm_exit(crm_exit_status); | |
178 | 172 | } |
179 | 173 | |
180 | 174 | static gboolean |
@@ -275,7 +269,7 @@ | ||
275 | 269 | |
276 | 270 | if (th_timer != NULL) { |
277 | 271 | ret_thread = g_thread_join(th_timer); |
278 | - crm_debug_2("thread_join -> %d", GPOINTER_TO_INT (ret_thread)); | |
272 | + crm_trace("thread_join -> %d", GPOINTER_TO_INT (ret_thread)); | |
279 | 273 | th_timer = NULL; |
280 | 274 | } |
281 | 275 | } else { |
@@ -312,7 +306,7 @@ | ||
312 | 306 | g_thread_exit(GINT_TO_POINTER(ERROR)); |
313 | 307 | } |
314 | 308 | |
315 | - crm_debug_2("Received Cond from Main()."); | |
309 | + crm_trace("Received Cond from Main()."); | |
316 | 310 | g_thread_exit(GINT_TO_POINTER(normal)); |
317 | 311 | } |
318 | 312 |
@@ -349,7 +343,7 @@ | ||
349 | 343 | struct timeval timeout_tv; |
350 | 344 | fd_set write_fd_set; |
351 | 345 | |
352 | - crm_debug_2("diskcheck_wt start"); | |
346 | + crm_trace("diskcheck_wt start"); | |
353 | 347 | |
354 | 348 | diskd_thread_create(); |
355 | 349 |
@@ -363,14 +357,14 @@ | ||
363 | 357 | |
364 | 358 | if (fd == -1) { |
365 | 359 | crm_err("Could not open %s", wfile); |
366 | - cl_perror("%s", wfile); | |
360 | + crm_perror(LOG_ERR, "%s", wfile); | |
367 | 361 | continue; /* failed to open file. try re-open */ |
368 | 362 | } |
369 | 363 | |
370 | 364 | while( 1 ) { |
371 | 365 | err = write(fd, buf, WRITE_DATA); /* data write */ |
372 | 366 | if (err == WRITE_DATA) { |
373 | - crm_debug_2("data writing is OK"); | |
367 | + crm_trace("data writing is OK"); | |
374 | 368 | close(fd); |
375 | 369 | if (-1 == remove((const char *)wfile)) { |
376 | 370 | crm_warn("failed to remove file %s", wfile); |
@@ -406,7 +400,7 @@ | ||
406 | 400 | } |
407 | 401 | } else { |
408 | 402 | crm_err("Could not write to file %s", wfile); |
409 | - cl_perror("%s", wfile); | |
403 | + crm_perror(LOG_ERR, "%s", wfile); | |
410 | 404 | close(fd); |
411 | 405 | if (-1 == remove((const char *)wfile)) { |
412 | 406 | crm_warn("failed to remove file %s", wfile); |
@@ -436,7 +430,7 @@ | ||
436 | 430 | struct timeval timeout_tv; |
437 | 431 | fd_set read_fd_set; |
438 | 432 | |
439 | - crm_debug_2("diskcheck start"); | |
433 | + crm_trace("diskcheck start"); | |
440 | 434 | |
441 | 435 | diskd_thread_create(); |
442 | 436 |
@@ -461,7 +455,7 @@ | ||
461 | 455 | while( 1 ) { |
462 | 456 | err = read(fd, buf, pagesize); |
463 | 457 | if (err == pagesize) { |
464 | - crm_debug_2("reading form data is OK"); | |
458 | + crm_trace("reading form data is OK"); | |
465 | 459 | close(fd); |
466 | 460 | diskd_thread_condsend(); |
467 | 461 | check_status(normal); |
@@ -504,23 +498,23 @@ | ||
504 | 498 | |
505 | 499 | if ( wflag ) { /* writer */ |
506 | 500 | if (wfile == NULL) { |
507 | - wdir = crm_strdup(WRITE_DIR); | |
508 | - crm_malloc0(wfile, PATH_MAX); | |
501 | + wdir = strdup(WRITE_DIR); | |
502 | + wfile = calloc(1, PATH_MAX); | |
509 | 503 | g_snprintf(wfile, PATH_MAX, "%s/%s", WRITE_DIR, WRITE_FILE); |
510 | 504 | } |
511 | 505 | buf = (void *)malloc(WRITE_DATA); |
512 | 506 | if (buf == NULL) { |
513 | 507 | crm_err("Could not allocate memory"); |
514 | - exit(LSB_EXIT_GENERIC); | |
508 | + crm_exit(1); | |
515 | 509 | } |
516 | 510 | rc = diskcheck_wt(NULL); |
517 | - crm_free(wfile); | |
511 | + free(wfile); | |
518 | 512 | } else { /* reader */ |
519 | 513 | pagesize = getpagesize(); |
520 | 514 | ptr = (void *)malloc(2 * pagesize); |
521 | 515 | if (ptr == NULL) { |
522 | 516 | crm_err("Could not allocate memory"); |
523 | - exit(LSB_EXIT_GENERIC); | |
517 | + crm_exit(1); | |
524 | 518 | } |
525 | 519 | buf = (void *)(((u_long)ptr + pagesize) & ~(pagesize-1)); |
526 | 520 | rc = diskcheck(NULL); |
@@ -565,19 +559,18 @@ | ||
565 | 559 | {0, 0, 0, 0} |
566 | 560 | }; |
567 | 561 | #endif |
568 | - pid_file = crm_strdup(PID_FILE); | |
562 | + pid_file = strdup(PID_FILE); | |
569 | 563 | crm_system_name = basename(argv[0]); |
570 | 564 | |
571 | - G_main_add_SignalHandler( | |
572 | - G_PRIORITY_HIGH, SIGTERM, diskd_shutdown, NULL, NULL); | |
565 | + mainloop_add_signal(SIGTERM, diskd_shutdown); | |
573 | 566 | |
574 | - crm_log_init(basename(argv[0]), LOG_INFO, TRUE, FALSE, argc, argv); | |
567 | + crm_log_init(basename(argv[0]), LOG_INFO, TRUE, FALSE, argc, argv, FALSE); | |
575 | 568 | |
576 | 569 | /* check user. user shuld be root.*/ |
577 | 570 | if (strcmp("root", (const gchar *)g_get_user_name()) != 0) { |
578 | 571 | crm_err("permission denied. diskd should be executed by root.\n"); |
579 | 572 | printf ("permission denied. diskd should be executed by root.\n"); |
580 | - exit(LSB_EXIT_GENERIC); | |
573 | + crm_exit(1); | |
581 | 574 | } |
582 | 575 | |
583 | 576 | while (1) { |
@@ -592,15 +585,14 @@ | ||
592 | 585 | |
593 | 586 | switch(flag) { |
594 | 587 | case 'V': |
595 | - cl_log_enable_stderr(TRUE); | |
596 | - alter_debug(DEBUG_INC); | |
588 | + crm_bump_log_level(argc, argv); | |
597 | 589 | break; |
598 | 590 | case 'p': |
599 | - crm_free(pid_file); | |
600 | - pid_file = crm_strdup(optarg); | |
591 | + free(pid_file); | |
592 | + pid_file = strdup(optarg); | |
601 | 593 | break; |
602 | 594 | case 'a': |
603 | - diskd_attr = crm_strdup(optarg); | |
595 | + diskd_attr = strdup(optarg); | |
604 | 596 | break; |
605 | 597 | case 'r': |
606 | 598 | retry = crm_parse_int(optarg, "1"); |
@@ -627,7 +619,7 @@ | ||
627 | 619 | ++argerr; |
628 | 620 | break; |
629 | 621 | case 'N': |
630 | - device = crm_strdup(optarg); | |
622 | + device = strdup(optarg); | |
631 | 623 | optflag++; /* add 2008.20.24 */ |
632 | 624 | break; |
633 | 625 | case 'D': |
@@ -638,8 +630,8 @@ | ||
638 | 630 | optflag++; |
639 | 631 | break; |
640 | 632 | case 'd': /* add option 2009.4.17 */ |
641 | - wdir = crm_strdup(optarg); | |
642 | - crm_malloc0(wfile, PATH_MAX); | |
633 | + wdir = strdup(optarg); | |
634 | + wfile = calloc(1, PATH_MAX); | |
643 | 635 | g_snprintf(wfile, PATH_MAX, "%s/%s", optarg, WRITE_FILE); |
644 | 636 | break; |
645 | 637 | case 'o': /* add option 2009.10.01 */ |
@@ -649,7 +641,7 @@ | ||
649 | 641 | exec_thread_flag =1; |
650 | 642 | break; |
651 | 643 | case '?': |
652 | - usage(crm_system_name, LSB_EXIT_GENERIC); | |
644 | + usage(crm_system_name, 1); | |
653 | 645 | break; |
654 | 646 | default: |
655 | 647 | printf ("Argument code 0%o (%c) is not (?yet?) supported\n", flag, flag); |
@@ -673,7 +665,7 @@ | ||
673 | 665 | } |
674 | 666 | if ((argerr) || (optflag >= 2) || (device == NULL && wflag == FALSE)) { /* add optflag 2008.10.24 */ |
675 | 667 | /* "-N" + "-w" pattern and not "-N" + not "-w"*/ |
676 | - usage(crm_system_name, LSB_EXIT_GENERIC); | |
668 | + usage(crm_system_name, 1); | |
677 | 669 | } |
678 | 670 | if ((device != NULL) && (wfile != NULL)) { |
679 | 671 | /* "-N" + "-d" pattern */ |
@@ -683,9 +675,9 @@ | ||
683 | 675 | if (oneshot_flag) { |
684 | 676 | int rc = 0; |
685 | 677 | |
686 | - crm_free(pid_file); | |
678 | + free(pid_file); | |
687 | 679 | rc = oneshot(); |
688 | - exit (rc); | |
680 | + crm_exit (rc); | |
689 | 681 | } |
690 | 682 | |
691 | 683 | crm_make_daemon(crm_system_name, daemonize, pid_file); |
@@ -693,29 +685,29 @@ | ||
693 | 685 | |
694 | 686 | if ( wflag ) { /* writer */ |
695 | 687 | if (wfile == NULL) { |
696 | - wdir = crm_strdup(WRITE_DIR); | |
697 | - crm_malloc0(wfile, PATH_MAX); | |
688 | + wdir = strdup(WRITE_DIR); | |
689 | + wfile = calloc(1, PATH_MAX); | |
698 | 690 | g_snprintf(wfile, PATH_MAX, "%s/%s", WRITE_DIR, WRITE_FILE); |
699 | 691 | } |
700 | 692 | buf = (void *)malloc(WRITE_DATA); |
701 | 693 | if (buf == NULL) { |
702 | 694 | crm_err("Could not allocate memory"); |
703 | 695 | check_status(ERROR); |
704 | - exit(LSB_EXIT_GENERIC); | |
696 | + crm_exit(1); | |
705 | 697 | } |
706 | 698 | diskcheck_wt(NULL); |
707 | - timer_id = Gmain_timeout_add(interval*1000, diskcheck_wt, NULL); | |
699 | + timer_id = g_timeout_add(interval*1000, diskcheck_wt, NULL); | |
708 | 700 | } else { /* reader */ |
709 | 701 | pagesize = getpagesize(); |
710 | 702 | ptr = (void *)malloc(2 * pagesize); |
711 | 703 | if (ptr == NULL) { |
712 | 704 | crm_err("Could not allocate memory"); |
713 | 705 | check_status(ERROR); |
714 | - exit(LSB_EXIT_GENERIC); | |
706 | + crm_exit(1); | |
715 | 707 | } |
716 | 708 | buf = (void *)(((u_long)ptr + pagesize) & ~(pagesize-1)); |
717 | 709 | diskcheck(NULL); |
718 | - timer_id = Gmain_timeout_add(interval*1000, diskcheck, NULL); | |
710 | + timer_id = g_timeout_add(interval*1000, diskcheck, NULL); | |
719 | 711 | } |
720 | 712 | |
721 | 713 | crm_info("Starting %s", crm_system_name); |
@@ -723,9 +715,9 @@ | ||
723 | 715 | g_main_run(mainloop); |
724 | 716 | |
725 | 717 | free(ptr); |
726 | - crm_free(pid_file); | |
718 | + free(pid_file); | |
727 | 719 | if (wfile != NULL) { |
728 | - crm_free(wfile); | |
720 | + free(wfile); | |
729 | 721 | } |
730 | 722 | |
731 | 723 | diskd_thread_timer_end(); |
@@ -737,7 +729,10 @@ | ||
737 | 729 | void |
738 | 730 | send_update(void) |
739 | 731 | { |
740 | - attrd_lazy_update('U', NULL, diskd_attr, diskcheck_value, attr_section, attr_set, "0"); | |
732 | + if(FALSE == attrd_update_delegate( | |
733 | + NULL, 'U', NULL, diskd_attr, diskcheck_value, attr_section, attr_set, "0", NULL)) { | |
734 | + crm_err("Could not update %s=%s", diskd_attr, diskcheck_value); | |
735 | + } | |
741 | 736 | } |
742 | 737 | |
743 | 738 |