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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* RCM module providing support for swap areas
* during reconfiguration operations.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <thread.h>
#include <synch.h>
#include <strings.h>
#include <assert.h>
#include <errno.h>
#include <libintl.h>
#include <sys/types.h>
#include <sys/swap.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/dumpadm.h>
#include <sys/wait.h>
#include "rcm_module.h"
/* cache flags */
#define SWAP_CACHE_NEW 0x01
#define SWAP_CACHE_STALE 0x02
#define SWAP_CACHE_OFFLINED 0x04
#define SWAP_CMD "/usr/sbin/swap"
#define SWAP_DELETE SWAP_CMD" -d %s %ld"
#define SWAP_ADD SWAP_CMD" -a %s %ld %ld"
/* LP64 hard code */
#define MAXOFFSET_STRLEN 20
typedef struct swap_file {
char path[MAXPATHLEN];
int cache_flags;
struct swap_area *areas;
struct swap_file *next;
struct swap_file *prev;
} swap_file_t;
/* swap file may have multiple swap areas */
typedef struct swap_area {
off_t start;
off_t len;
int cache_flags;
struct swap_area *next;
struct swap_area *prev;
} swap_area_t;
static swap_file_t *cache;
static mutex_t cache_lock;
static int swap_register(rcm_handle_t *);
static int swap_unregister(rcm_handle_t *);
static int swap_getinfo(rcm_handle_t *, char *, id_t, uint_t,
char **, char **, nvlist_t *, rcm_info_t **);
static int swap_suspend(rcm_handle_t *, char *, id_t, timespec_t *,
uint_t, char **, rcm_info_t **);
static int swap_resume(rcm_handle_t *, char *, id_t, uint_t,
char **, rcm_info_t **);
static int swap_offline(rcm_handle_t *, char *, id_t, uint_t,
char **, rcm_info_t **);
static int swap_online(rcm_handle_t *, char *, id_t, uint_t,
char **, rcm_info_t **);
static int swap_remove(rcm_handle_t *, char *, id_t, uint_t,
char **, rcm_info_t **);
static int alloc_usage(char **);
static void cache_insert(swap_file_t *);
static swap_file_t *cache_lookup(char *);
static void cache_remove(swap_file_t *);
static void free_cache(void);
static int get_dumpdev(char []);
static void log_cmd_status(int);
static int swap_add(swap_file_t *, char **);
static void swap_area_add(swap_file_t *, swap_area_t *);
static swap_area_t *swap_area_alloc(swapent_t *);
static swap_area_t *swap_area_lookup(swap_file_t *, swapent_t *);
static void swap_area_remove(swap_file_t *, swap_area_t *);
static int swap_delete(swap_file_t *, char **);
static swap_file_t *swap_file_alloc(char *);
static void swap_file_free(swap_file_t *);
static swaptbl_t *sys_swaptbl(void);
static int update_cache(rcm_handle_t *);
static struct rcm_mod_ops swap_ops =
{
RCM_MOD_OPS_VERSION,
swap_register,
swap_unregister,
swap_getinfo,
swap_suspend,
swap_resume,
swap_offline,
swap_online,
swap_remove,
NULL,
NULL,
NULL
};
struct rcm_mod_ops *
rcm_mod_init()
{
return (&swap_ops);
}
const char *
rcm_mod_info()
{
return ("RCM Swap module 1.5");
}
int
rcm_mod_fini()
{
free_cache();
(void) mutex_destroy(&cache_lock);
return (RCM_SUCCESS);
}
static int
swap_register(rcm_handle_t *hdl)
{
return (update_cache(hdl));
}
static int
swap_unregister(rcm_handle_t *hdl)
{
swap_file_t *sf;
(void) mutex_lock(&cache_lock);
while ((sf = cache) != NULL) {
cache = cache->next;
(void) rcm_unregister_interest(hdl, sf->path, 0);
swap_file_free(sf);
}
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
swap_getinfo(rcm_handle_t *hdl, char *rsrcname, id_t id, uint_t flags,
char **infostr, char **errstr, nvlist_t *props, rcm_info_t **dependent)
{
assert(rsrcname != NULL && infostr != NULL);
(void) mutex_lock(&cache_lock);
if (cache_lookup(rsrcname) == NULL) {
rcm_log_message(RCM_ERROR, "unknown resource: %s\n",
rsrcname);
(void) mutex_unlock(&cache_lock);
return (RCM_FAILURE);
}
(void) mutex_unlock(&cache_lock);
(void) alloc_usage(infostr);
return (RCM_SUCCESS);
}
/*
* Remove swap space to maintain availability of anonymous pages
* during device suspension. Swap will be reconfigured upon resume.
* Fail if operation will unconfigure dump device.
*/
/*ARGSUSED*/
static int
swap_suspend(rcm_handle_t *hdl, char *rsrcname, id_t id, timespec_t *interval,
uint_t flags, char **errstr, rcm_info_t **dependent)
{
swap_file_t *sf;
int rv;
assert(rsrcname != NULL && errstr != NULL);
if (flags & RCM_QUERY)
return (RCM_SUCCESS);
(void) mutex_lock(&cache_lock);
if ((sf = cache_lookup(rsrcname)) == NULL) {
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
rv = swap_delete(sf, errstr);
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*ARGSUSED*/
static int
swap_resume(rcm_handle_t *hdl, char *rsrcname, id_t id, uint_t flags,
char **errstr, rcm_info_t **dependent)
{
swap_file_t *sf;
int rv;
assert(rsrcname != NULL && errstr != NULL);
(void) mutex_lock(&cache_lock);
if ((sf = cache_lookup(rsrcname)) == NULL) {
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
rv = swap_add(sf, errstr);
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*
* By default, reject offline request. If forced, attempt to
* delete swap. Fail if operation will unconfigure dump device.
*/
/*ARGSUSED*/
static int
swap_offline(rcm_handle_t *hdl, char *rsrcname, id_t id, uint_t flags,
char **errstr, rcm_info_t **dependent)
{
swap_file_t *sf;
int rv;
assert(rsrcname != NULL && errstr != NULL);
if ((flags & RCM_FORCE) && (flags & RCM_QUERY))
return (RCM_SUCCESS);
(void) mutex_lock(&cache_lock);
if ((sf = cache_lookup(rsrcname)) == NULL) {
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
if (flags & RCM_FORCE) {
rv = swap_delete(sf, errstr);
(void) mutex_unlock(&cache_lock);
return (rv);
}
/* default reject */
(void) mutex_unlock(&cache_lock);
(void) alloc_usage(errstr);
return (RCM_FAILURE);
}
/*ARGSUSED*/
static int
swap_online(rcm_handle_t *hdl, char *rsrcname, id_t id, uint_t flags,
char **errstr, rcm_info_t **dependent)
{
swap_file_t *sf;
int rv;
assert(rsrcname != NULL && errstr != NULL);
(void) mutex_lock(&cache_lock);
if ((sf = cache_lookup(rsrcname)) == NULL) {
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
rv = swap_add(sf, errstr);
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*ARGSUSED*/
static int
swap_remove(rcm_handle_t *hdl, char *rsrcname, id_t id, uint_t flags,
char **errstr, rcm_info_t **dependent)
{
swap_file_t *sf;
assert(rsrcname != NULL);
(void) mutex_lock(&cache_lock);
if ((sf = cache_lookup(rsrcname)) == NULL) {
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
/* RCM framework handles unregistration */
cache_remove(sf);
swap_file_free(sf);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
/*
* Delete all swap areas for swap file.
* Invoke swap(8) instead of swapctl(2) to
* handle relocation of dump device.
* If dump device is configured, fail if
* unable to relocate dump.
*
* Call with cache_lock held.
*/
static int
swap_delete(swap_file_t *sf, char **errstr)
{
swap_area_t *sa;
char cmd[sizeof (SWAP_DELETE) + MAXPATHLEN +
MAXOFFSET_STRLEN];
char dumpdev[MAXPATHLEN];
int have_dump = 1;
int stat;
int rv = RCM_SUCCESS;
if (get_dumpdev(dumpdev) == 0 && dumpdev[0] == '\0')
have_dump = 0;
for (sa = sf->areas; sa != NULL; sa = sa->next) {
/* swap(8) is not idempotent */
if (sa->cache_flags & SWAP_CACHE_OFFLINED) {
continue;
}
(void) snprintf(cmd, sizeof (cmd), SWAP_DELETE, sf->path,
sa->start);
rcm_log_message(RCM_TRACE1, "%s\n", cmd);
if ((stat = rcm_exec_cmd(cmd)) != 0) {
log_cmd_status(stat);
*errstr = strdup(gettext("unable to delete swap"));
rv = RCM_FAILURE;
goto out;
}
sa->cache_flags |= SWAP_CACHE_OFFLINED;
/*
* Fail on removal of dump device.
*/
if (have_dump == 0)
continue;
if (get_dumpdev(dumpdev) != 0) {
rcm_log_message(RCM_WARNING, "unable to "
"check for removal of dump device\n");
} else if (dumpdev[0] == '\0') {
rcm_log_message(RCM_DEBUG, "removed dump: "
"attempting recovery\n");
/*
* Restore dump
*/
(void) snprintf(cmd, sizeof (cmd), SWAP_ADD,
sf->path, sa->start, sa->len);
rcm_log_message(RCM_TRACE1, "%s\n", cmd);
if ((stat = rcm_exec_cmd(cmd)) != 0) {
log_cmd_status(stat);
rcm_log_message(RCM_ERROR,
"failed to restore dump\n");
} else {
sa->cache_flags &= ~SWAP_CACHE_OFFLINED;
rcm_log_message(RCM_DEBUG, "dump restored\n");
}
*errstr = strdup(gettext("unable to relocate dump"));
rv = RCM_FAILURE;
goto out;
}
}
sf->cache_flags |= SWAP_CACHE_OFFLINED;
out:
return (rv);
}
/*
* Invoke swap(8) to add each registered swap area.
*
* Call with cache_lock held.
*/
static int
swap_add(swap_file_t *sf, char **errstr)
{
swap_area_t *sa;
char cmd[sizeof (SWAP_ADD) + MAXPATHLEN +
(2 * MAXOFFSET_STRLEN)];
int stat;
int rv = RCM_SUCCESS;
for (sa = sf->areas; sa != NULL; sa = sa->next) {
/* swap(8) is not idempotent */
if (!(sa->cache_flags & SWAP_CACHE_OFFLINED)) {
continue;
}
(void) snprintf(cmd, sizeof (cmd),
SWAP_ADD, sf->path, sa->start, sa->len);
rcm_log_message(RCM_TRACE1, "%s\n", cmd);
if ((stat = rcm_exec_cmd(cmd)) != 0) {
log_cmd_status(stat);
*errstr = strdup(gettext("unable to add swap"));
rv = RCM_FAILURE;
break;
} else {
sa->cache_flags &= ~SWAP_CACHE_OFFLINED;
sf->cache_flags &= ~SWAP_CACHE_OFFLINED;
}
}
return (rv);
}
static int
update_cache(rcm_handle_t *hdl)
{
swaptbl_t *swt;
swap_file_t *sf, *stale_sf;
swap_area_t *sa, *stale_sa;
int i;
int rv = RCM_SUCCESS;
if ((swt = sys_swaptbl()) == NULL) {
rcm_log_message(RCM_ERROR, "failed to read "
"current swap configuration\n");
return (RCM_FAILURE);
}
(void) mutex_lock(&cache_lock);
/*
* cache pass 1 - mark everyone stale
*/
for (sf = cache; sf != NULL; sf = sf->next) {
sf->cache_flags |= SWAP_CACHE_STALE;
for (sa = sf->areas; sa != NULL; sa = sa->next) {
sa->cache_flags |= SWAP_CACHE_STALE;
}
}
/*
* add new entries
*/
for (i = 0; i < swt->swt_n; i++) {
if (swt->swt_ent[i].ste_flags & (ST_INDEL|ST_DOINGDEL)) {
continue;
}
/*
* assure swap_file_t
*/
if ((sf = cache_lookup(swt->swt_ent[i].ste_path)) == NULL) {
if ((sf = swap_file_alloc(swt->swt_ent[i].ste_path)) ==
NULL) {
free(swt);
return (RCM_FAILURE);
}
sf->cache_flags |= SWAP_CACHE_NEW;
cache_insert(sf);
} else {
sf->cache_flags &= ~SWAP_CACHE_STALE;
}
/*
* assure swap_area_t
*/
if ((sa = swap_area_lookup(sf, &swt->swt_ent[i])) == NULL) {
if ((sa = swap_area_alloc(&swt->swt_ent[i])) == NULL) {
free(swt);
return (RCM_FAILURE);
}
swap_area_add(sf, sa);
} else {
sa->cache_flags &= ~SWAP_CACHE_STALE;
}
}
free(swt);
/*
* cache pass 2
*
* swap_file_t - skip offlined, register new, unregister/remove stale
* swap_area_t - skip offlined, remove stale
*/
sf = cache;
while (sf != NULL) {
sa = sf->areas;
while (sa != NULL) {
if (sa->cache_flags & SWAP_CACHE_OFFLINED) {
sa->cache_flags &= ~SWAP_CACHE_STALE;
sa = sa->next;
continue;
}
if (sa->cache_flags & SWAP_CACHE_STALE) {
stale_sa = sa;
sa = sa->next;
swap_area_remove(sf, stale_sa);
free(stale_sa);
continue;
}
sa = sa->next;
}
if (sf->cache_flags & SWAP_CACHE_OFFLINED) {
sf->cache_flags &= ~SWAP_CACHE_STALE;
sf = sf->next;
continue;
}
if (sf->cache_flags & SWAP_CACHE_STALE) {
if (rcm_unregister_interest(hdl, sf->path, 0) !=
RCM_SUCCESS) {
rcm_log_message(RCM_ERROR, "failed to register "
"%s\n", sf->path);
}
stale_sf = sf;
sf = sf->next;
cache_remove(stale_sf);
swap_file_free(stale_sf);
continue;
}
if (!(sf->cache_flags & SWAP_CACHE_NEW)) {
sf = sf->next;
continue;
}
if (rcm_register_interest(hdl, sf->path, 0, NULL) !=
RCM_SUCCESS) {
rcm_log_message(RCM_ERROR, "failed to register %s\n",
sf->path);
rv = RCM_FAILURE;
} else {
rcm_log_message(RCM_DEBUG, "registered %s\n",
sf->path);
sf->cache_flags &= ~SWAP_CACHE_NEW;
}
sf = sf->next;
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*
* Returns system swap table.
*/
static swaptbl_t *
sys_swaptbl()
{
swaptbl_t *swt;
char *cp;
int i, n;
size_t tbl_size;
if ((n = swapctl(SC_GETNSWP, NULL)) == -1)
return (NULL);
tbl_size = sizeof (int) + n * sizeof (swapent_t) + n * MAXPATHLEN;
if ((swt = (swaptbl_t *)malloc(tbl_size)) == NULL)
return (NULL);
swt->swt_n = n;
cp = (char *)swt + (sizeof (int) + n * sizeof (swapent_t));
for (i = 0; i < n; i++) {
swt->swt_ent[i].ste_path = cp;
cp += MAXPATHLEN;
}
if ((n = swapctl(SC_LIST, swt)) == -1) {
free(swt);
return (NULL);
}
if (n != swt->swt_n) {
/* mismatch, try again */
free(swt);
return (sys_swaptbl());
}
return (swt);
}
static int
get_dumpdev(char dumpdev[])
{
int fd;
int rv = 0;
char *err;
if ((fd = open("/dev/dump", O_RDONLY)) == -1) {
rcm_log_message(RCM_ERROR, "failed to open /dev/dump\n");
return (-1);
}
if (ioctl(fd, DIOCGETDEV, dumpdev) == -1) {
if (errno == ENODEV) {
dumpdev[0] = '\0';
} else {
rcm_log_message(RCM_ERROR, "ioctl: %s\n",
((err = strerror(errno)) == NULL) ? "" : err);
rv = -1;
}
}
(void) close(fd);
return (rv);
}
static void
free_cache(void)
{
swap_file_t *sf;
(void) mutex_lock(&cache_lock);
while ((sf = cache) != NULL) {
cache = cache->next;
swap_file_free(sf);
}
(void) mutex_unlock(&cache_lock);
}
/*
* Call with cache_lock held.
*/
static void
swap_file_free(swap_file_t *sf)
{
swap_area_t *sa;
assert(sf != NULL);
while ((sa = sf->areas) != NULL) {
sf->areas = sf->areas->next;
free(sa);
}
free(sf);
}
/*
* Call with cache_lock held.
*/
static void
cache_insert(swap_file_t *ent)
{
ent->next = cache;
if (ent->next)
ent->next->prev = ent;
ent->prev = NULL;
cache = ent;
}
/*
* Call with cache_lock held.
*/
static swap_file_t *
cache_lookup(char *rsrc)
{
swap_file_t *sf;
for (sf = cache; sf != NULL; sf = sf->next) {
if (strcmp(rsrc, sf->path) == 0) {
return (sf);
}
}
return (NULL);
}
/*
* Call with cache_lock held.
*/
static void
cache_remove(swap_file_t *ent)
{
assert(ent != NULL);
if (ent->next != NULL) {
ent->next->prev = ent->prev;
}
if (ent->prev != NULL) {
ent->prev->next = ent->next;
} else {
cache = ent->next;
}
ent->next = NULL;
ent->prev = NULL;
}
/*
* Call with cache_lock held.
*/
static void
swap_area_add(swap_file_t *sf, swap_area_t *sa)
{
sa->next = sf->areas;
if (sa->next)
sa->next->prev = sa;
sa->prev = NULL;
sf->areas = sa;
}
/*
* Call with cache_lock held.
*/
static void
swap_area_remove(swap_file_t *sf, swap_area_t *ent)
{
assert(sf != NULL && ent != NULL);
if (ent->next != NULL) {
ent->next->prev = ent->prev;
}
if (ent->prev != NULL) {
ent->prev->next = ent->next;
} else {
sf->areas = ent->next;
}
ent->next = NULL;
ent->prev = NULL;
}
static swap_file_t *
swap_file_alloc(char *rsrc)
{
swap_file_t *sf;
if ((sf = calloc(1, sizeof (*sf))) == NULL) {
rcm_log_message(RCM_ERROR, "calloc failure\n");
return (NULL);
}
(void) strlcpy(sf->path, rsrc, sizeof (sf->path));
return (sf);
}
static swap_area_t *
swap_area_alloc(swapent_t *swt_ent)
{
swap_area_t *sa;
if ((sa = calloc(1, sizeof (*sa))) == NULL) {
rcm_log_message(RCM_ERROR, "calloc failure\n");
return (NULL);
}
sa->start = swt_ent->ste_start;
sa->len = swt_ent->ste_length;
return (sa);
}
/*
* Call with cache_lock held.
*/
static swap_area_t *
swap_area_lookup(swap_file_t *sf, swapent_t *swt_ent)
{
swap_area_t *sa;
assert(sf != NULL && swt_ent != NULL);
assert(strcmp(sf->path, swt_ent->ste_path) == 0);
for (sa = sf->areas; sa != NULL; sa = sa->next) {
if (sa->start == swt_ent->ste_start &&
sa->len == swt_ent->ste_length) {
return (sa);
}
}
return (NULL);
}
/*
* All-purpose usage string.
*/
static int
alloc_usage(char **cpp)
{
if ((*cpp = strdup(gettext("swap area"))) == NULL) {
rcm_log_message(RCM_ERROR, "strdup failure\n");
return (-1);
}
return (0);
}
static void
log_cmd_status(int stat)
{
char *err;
if (stat == -1) {
rcm_log_message(RCM_ERROR, "wait: %s\n",
((err = strerror(errno)) == NULL) ? "" : err);
} else if (WIFEXITED(stat)) {
rcm_log_message(RCM_ERROR, "exit status: %d\n",
WEXITSTATUS(stat));
} else {
rcm_log_message(RCM_ERROR, "wait status: %d\n", stat);
}
}
|