Remove the RCSID macro
[openafs.git] / src / vol / vol-bless.c
1 /*
2  * Copyright 2004, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13
14 #include <stdio.h>
15
16 #include <afs/cmd.h>
17
18 #include <rx/xdr.h>
19 #include <afs/afsint.h>
20 #include "nfs.h"
21 #include "lock.h"
22 #include "ihandle.h"
23 #include "vnode.h"
24 #include "volume.h"
25
26 int VolumeChanged; /* to keep physio happy */
27
28 static int
29 handleit(struct cmd_syndesc *as, void *arock)
30 {
31     Volume *vp;
32     Error ec;
33     int bless, unbless, nofssync;
34     int volumeId;
35
36     volumeId = atoi(as->parms[0].items->data);
37     bless    = !!(as->parms[1].items);
38     unbless  = !!(as->parms[2].items);
39     nofssync = !!(as->parms[3].items);
40
41     if (bless && unbless) {
42         fprintf(stderr,"Cannot use both -bless and -unbless\n");
43         exit(1);
44     }
45
46     if (VInitVolumePackage(nofssync ? salvager : volumeUtility, 5, 5, 1, 0)) {
47         fprintf(stderr,"Unable to initialize volume package\n");
48         exit(1);
49     }
50
51     vp = VAttachVolume(&ec, volumeId, V_VOLUPD);
52     if (ec) {
53         fprintf(stderr,"VAttachVolume failed: %d\n", ec);
54         exit(1);
55     }
56     if (bless) V_blessed(vp) = 1;
57     if (unbless) V_blessed(vp) = 0;
58     VUpdateVolume(&ec, vp);
59     if (ec) {
60         fprintf(stderr,"VUpdateVolume failed: %d\n", ec);
61         VPutVolume(vp);
62         exit(1);
63     }
64     VPutVolume(vp);
65     return 0;
66 }
67
68 int
69 main(int argc, char **argv)
70 {
71     register struct cmd_syndesc *ts;
72     afs_int32 code;
73
74     ts = cmd_CreateSyntax(NULL, handleit, NULL, "Manipulate volume blessed bit");
75     cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, "Volume id");
76     cmd_AddParm(ts, "-bless", CMD_FLAG, CMD_OPTIONAL, "Set blessed bit");
77     cmd_AddParm(ts, "-unbless", CMD_FLAG, CMD_OPTIONAL, "Clear blessed bit");
78     cmd_AddParm(ts, "-nofssync", CMD_FLAG, CMD_OPTIONAL,
79                 "Don't communicate with running fileserver");
80     code = cmd_Dispatch(argc, argv);
81     return code;
82 }
83
84