2 * Copyright 2004, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include <afs/param.h>
21 #include <afs/afsint.h>
28 int VolumeChanged; /* to keep physio happy */
31 handleit(struct cmd_syndesc *as, void *arock)
35 int bless, unbless, nofssync;
38 volumeId = atoi(as->parms[0].items->data);
39 bless = !!(as->parms[1].items);
40 unbless = !!(as->parms[2].items);
41 nofssync = !!(as->parms[3].items);
43 if (bless && unbless) {
44 fprintf(stderr,"Cannot use both -bless and -unbless\n");
48 if (VInitVolumePackage(nofssync ? salvager : volumeUtility, 5, 5, 1, 0)) {
49 fprintf(stderr,"Unable to initialize volume package\n");
53 vp = VAttachVolume(&ec, volumeId, V_VOLUPD);
55 fprintf(stderr,"VAttachVolume failed: %d\n", ec);
58 if (bless) V_blessed(vp) = 1;
59 if (unbless) V_blessed(vp) = 0;
60 VUpdateVolume(&ec, vp);
62 fprintf(stderr,"VUpdateVolume failed: %d\n", ec);
71 main(int argc, char **argv)
73 register struct cmd_syndesc *ts;
76 ts = cmd_CreateSyntax(NULL, handleit, NULL, "Manipulate volume blessed bit");
77 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, "Volume id");
78 cmd_AddParm(ts, "-bless", CMD_FLAG, CMD_OPTIONAL, "Set blessed bit");
79 cmd_AddParm(ts, "-unbless", CMD_FLAG, CMD_OPTIONAL, "Clear blessed bit");
80 cmd_AddParm(ts, "-nofssync", CMD_FLAG, CMD_OPTIONAL,
81 "Don't communicate with running fileserver");
82 code = cmd_Dispatch(argc, argv);