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>
18 #include <afs/afsint.h>
25 int VolumeChanged
; /* to keep physio happy */
28 handleit(struct cmd_syndesc
*as
, void *arock
)
32 int bless
, unbless
, nofssync
;
34 VolumePackageOptions opts
;
37 volumeId
= atoi(as
->parms
[0].items
->data
);
38 bless
= !!(as
->parms
[1].items
);
39 unbless
= !!(as
->parms
[2].items
);
40 nofssync
= !!(as
->parms
[3].items
);
42 if (bless
&& unbless
) {
43 fprintf(stderr
,"Cannot use both -bless and -unbless\n");
53 VOptDefaults(pt
, &opts
);
54 opts
.canUseFSSYNC
= !nofssync
;
56 if (VInitVolumePackage2(pt
, &opts
)) {
57 fprintf(stderr
,"Unable to initialize volume package\n");
61 vp
= VAttachVolume(&ec
, volumeId
, V_VOLUPD
);
63 fprintf(stderr
,"VAttachVolume failed: %d\n", ec
);
66 if (bless
) V_blessed(vp
) = 1;
67 if (unbless
) V_blessed(vp
) = 0;
68 VUpdateVolume(&ec
, vp
);
70 fprintf(stderr
,"VUpdateVolume failed: %d\n", ec
);
71 VDetachVolume(&ec
, vp
);
74 VDetachVolume(&ec
, vp
);
79 main(int argc
, char **argv
)
81 struct cmd_syndesc
*ts
;
84 ts
= cmd_CreateSyntax(NULL
, handleit
, NULL
, 0, "Manipulate volume blessed bit");
85 cmd_AddParm(ts
, "-id", CMD_SINGLE
, CMD_REQUIRED
, "Volume id");
86 cmd_AddParm(ts
, "-bless", CMD_FLAG
, CMD_OPTIONAL
, "Set blessed bit");
87 cmd_AddParm(ts
, "-unbless", CMD_FLAG
, CMD_OPTIONAL
, "Clear blessed bit");
88 cmd_AddParm(ts
, "-nofssync", CMD_FLAG
, CMD_OPTIONAL
,
89 "Don't communicate with running fileserver");
90 code
= cmd_Dispatch(argc
, argv
);