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>
19 #include <afs/afsint.h>
26 int VolumeChanged
; /* to keep physio happy */
29 handleit(struct cmd_syndesc
*as
, void *arock
)
33 int bless
, unbless
, nofssync
;
35 VolumePackageOptions opts
;
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");
54 VOptDefaults(pt
, &opts
);
55 opts
.canUseFSSYNC
= !nofssync
;
57 if (VInitVolumePackage2(pt
, &opts
)) {
58 fprintf(stderr
,"Unable to initialize volume package\n");
62 vp
= VAttachVolume(&ec
, volumeId
, V_VOLUPD
);
64 fprintf(stderr
,"VAttachVolume failed: %d\n", ec
);
67 if (bless
) V_blessed(vp
) = 1;
68 if (unbless
) V_blessed(vp
) = 0;
69 VUpdateVolume(&ec
, vp
);
71 fprintf(stderr
,"VUpdateVolume failed: %d\n", ec
);
72 VDetachVolume(&ec
, vp
);
75 VDetachVolume(&ec
, vp
);
80 main(int argc
, char **argv
)
82 struct cmd_syndesc
*ts
;
85 ts
= cmd_CreateSyntax(NULL
, handleit
, NULL
, "Manipulate volume blessed bit");
86 cmd_AddParm(ts
, "-id", CMD_SINGLE
, CMD_REQUIRED
, "Volume id");
87 cmd_AddParm(ts
, "-bless", CMD_FLAG
, CMD_OPTIONAL
, "Set blessed bit");
88 cmd_AddParm(ts
, "-unbless", CMD_FLAG
, CMD_OPTIONAL
, "Clear blessed bit");
89 cmd_AddParm(ts
, "-nofssync", CMD_FLAG
, CMD_OPTIONAL
,
90 "Don't communicate with running fileserver");
91 code
= cmd_Dispatch(argc
, argv
);