/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include "uss_vol.h" /*Interface to this module */
#include "uss_common.h" /*Common definitions */
#include "uss_procs.h" /*Defs from procs module */
#include "uss_fs.h" /*CacheManager ops */
+#include "uss_acl.h"
#include <sys/stat.h>
#include <pwd.h>
#include <netdb.h>
#include <errno.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
+#include <afs/com_err.h>
#include <afs/vlserver.h>
+#include <afs/vldbint.h>
#include <afs/auth.h>
#include <afs/cellconfig.h>
#include <rx/rx_globals.h>
#include <afs/volser.h>
+#include <afs/volser_prototypes.h>
#include <afs/volint.h>
#include <afs/keys.h>
+#include <afs/afsutil.h>
#include <ubik.h>
-extern struct rx_connection *UV_Bind();
extern int line;
-extern int VL_GetEntryByID();
-extern char *hostutil_GetNameByINet();
-
/*
* ---------------------- Private definitions ---------------------
*------------------------------------------------------------------------*/
static afs_int32
-InitThisModule(a_noAuthFlag, a_confDir, a_cellName)
- int a_noAuthFlag;
- char *a_confDir;
- char *a_cellName;
-
+InitThisModule(int a_noAuthFlag, char *a_confDir, char *a_cellName)
{ /*InitThisModule */
-
+#ifdef USS_VOL_DB
static char rn[] = "uss_vol:InitThisModule";
+#endif
register afs_int32 code; /*Return code */
struct afsconf_dir *tdir; /*Ptr to conf dir info */
struct afsconf_cell info; /*Info about chosen cell */
- struct ktc_principal sname; /*Service name */
- struct ktc_token ttoken; /*Service ticket */
afs_int32 scIndex; /*Chosen security index */
+ afs_int32 secFlags;
struct rx_securityClass *sc; /*Generated security object */
afs_int32 i; /*Loop index */
#ifdef USS_VOL_DB
printf("[%s] Getting tickets if needed\n", rn);
#endif /* USS_VOL_DB */
- if (!a_noAuthFlag) {
- /*
- * We don't need tickets for unauthenticated connections.
- */
- strcpy(sname.cell, info.name);
- sname.instance[0] = 0;
- strcpy(sname.name, "afs");
- code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
- if (code) {
- fprintf(stderr,
- "%s: Couldn't get AFS tokens, running unauthenticated.\n",
- uss_whoami);
- scIndex = 0;
- } else {
- /*
- * We got a ticket, go for an authenticated connection.
- */
- if (ttoken.kvno >= 0 && ttoken.kvno <= 255)
- scIndex = 2; /*Kerberos */
- else {
- fprintf(stderr, "%s: Funny kvno (%d) in ticket, proceeding\n",
- uss_whoami, ttoken.kvno);
- scIndex = 2;
- }
- } /*Got a ticket */
- } /*Authentication desired */
- else
- scIndex = 0;
- /*
- * Generate the appropriate security object for the connection.
- */
-#ifdef USS_VOL_DB
- printf("[%s] Generating Rx security object\n", rn);
-#endif /* USS_VOL_DB */
- switch (scIndex) {
- case 0:
- sc = (struct rx_securityClass *)
- rxnull_NewClientSecurityObject();
- break;
-
- case 1:
- break;
-
- case 2:
- sc = (struct rx_securityClass *)
- rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
- ttoken.kvno, ttoken.ticketLen,
- ttoken.ticket);
- break;
+ secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
+ if (a_noAuthFlag)
+ secFlags |= AFSCONF_SECOPTS_NOAUTH;
+
+ code = afsconf_PickClientSecObj(tdir, secFlags, &info, a_cellName,
+ &sc, &scIndex, NULL);
+ if (code) {
+ printf("%s: Can't create client security object\n", uss_whoami);
+ exit(1);
+ }
+ if (scIndex == RX_SECIDX_NULL && !a_noAuthFlag) {
+ fprintf(stderr,
+ "%s: Couldn't get AFS tokens, running unauthenticated.\n",
+ uss_whoami);
}
/*
* As advertised.
*------------------------------------------------------------------------*/
-char *hostutil_GetNameByINet();
-
static void
-HostIDToHostName(a_hostID, a_hostName)
- afs_int32 a_hostID;
- char *a_hostName;
-
+HostIDToHostName(afs_int32 a_hostID, char *a_hostName)
{ /*HostIDToHostName */
strcpy(a_hostName, hostutil_GetNameByINet(a_hostID));
*------------------------------------------------------------------------*/
static afs_int32
-PartIDToPartName(a_partID, a_partName)
- afs_int32 a_partID;
- char *a_partName;
-
+PartIDToPartName(afs_int32 a_partID, char *a_partName)
{ /*PartIDToPartName */
-
+#ifdef USS_VOL_DB
static char rn[] = "PartIDToPartName";
-
+#endif
#ifdef USS_VOL_DB
printf("[%s] Translating partition id %d to its name\n", rn, a_partID);
#endif /* USS_VOL_DB */
*------------------------------------------------------------------------*/
afs_int32
-uss_vol_GetServer(a_name)
- char *a_name;
-
+uss_vol_GetServer(char *a_name)
{ /*uss_vol_GetServer */
register struct hostent *th;
afs_int32 addr;
- char b1, b2, b3, b4;
+ afs_int32 b1, b2, b3, b4;
register afs_int32 code;
code = sscanf(a_name, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
* Parsed as 128.2.9.4, or similar; return it in network
* byte order (128 in byte 0).
*/
- addr =
- (((afs_int32) b1) << 24) | (((afs_int32) b2) << 16) |
- (((afs_int32) b3) << 8) | (afs_int32) b4;
+ addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
return htonl(addr);
}
} /*uss_vol_GetServer */
+/* XXX - This function is unused, and could be deleted */
+#if 0
/*------------------------------------------------------------------------
* static GetVolumeType
*
*------------------------------------------------------------------------*/
static afs_int32
-GetVolumeType(a_type)
- char *a_type;
-
+GetVolumeType(char *a_type)
{ /*GetVolumeType */
if (!strcmp(a_type, "ro"))
return (-1);
} /*GetVolumeType */
-
+#endif
/*------------------------------------------------------------------------
* EXPORTED uss_Vol_GetPartitionID
*------------------------------------------------------------------------*/
afs_int32
-uss_vol_GetPartitionID(a_name)
- char *a_name;
-
+uss_vol_GetPartitionID(char *a_name)
{ /*uss_vol_GetPartitionID */
register char tc;
*------------------------------------------------------------------------*/
static int
-CheckDoubleMount(a_mp, a_oldmp)
- char *a_mp;
- char *a_oldmp;
-
+CheckDoubleMount(char *a_mp, char *a_oldmp)
{ /*CheckDoubleMount */
+#ifdef USS_VOL_DB
static char rn[] = "uss_vol:CheckDoubleMount";
+#endif
int start, len, mlen, tlen;
int i = 0;
struct passwd *pws;
*------------------------------------------------------------------------*/
afs_int32
-uss_vol_CreateVol(a_volname, a_server, a_partition, a_quota, a_mpoint,
- a_owner, a_acl)
- char *a_volname;
- char *a_server;
- char *a_partition;
- char *a_quota;
- char *a_mpoint;
- char *a_owner;
- char *a_acl;
-
+uss_vol_CreateVol(char *a_volname, char *a_server, char *a_partition,
+ char *a_quota, char *a_mpoint, char *a_owner,
+ char *a_acl)
{ /*uss_vol_CreateVol */
-
+#ifdef USS_VOL_DB
static char rn[] = "uss_vol_CreateVol"; /*Routine name */
+#endif
afs_int32 pname; /*Partition name */
- afs_int32 volid, code; /*Volume ID, return code */
+ afs_uint32 volid; /*Volume ID */
+ afs_int32 code; /*return code */
afs_int32 saddr; /*Socket info for server */
int VolExistFlag = 0; /*Does the volume exist? */
int mpExistFlag = 0; /*Does the mountpoint exist? */
if (!initDone) {
code = InitThisModule(NoAuthFlag, uss_ConfDir, uss_Cell);
if (code) {
- com_err(uss_whoami, code,
+ afs_com_err(uss_whoami, code,
"while inititializing VLDB connection(s)\n");
return (code);
}
* Set the volume disk quota.
*/
if (!uss_DryRun) {
- if (code = uss_acl_SetDiskQuota(a_mpoint, atoi(a_quota)))
+ if ((code = uss_acl_SetDiskQuota(a_mpoint, atoi(a_quota))))
return (code);
} /*Dry run */
else {
*------------------------------------------------------------------------*/
afs_int32
-uss_vol_DeleteVol(a_volName, a_volID, a_servName, a_servID, a_partName,
- a_partID)
- char *a_volName;
- afs_int32 a_volID;
- char *a_servName;
- afs_int32 a_servID;
- char *a_partName;
- afs_int32 a_partID;
-
+uss_vol_DeleteVol(char *a_volName, afs_int32 a_volID, char *a_servName,
+ afs_int32 a_servID, char *a_partName, afs_int32 a_partID)
{ /*uss_vol_DeleteVol */
+#ifdef USS_VOL_DB
static char rn[] = "uss_vol_DeleteVol"; /*Routine name */
- register afs_int32 code; /*Return code */
+#endif
+ register afs_int32 code = 0; /*Return code */
/*
* Make sure we've initialized our VLDB connection(s) before
*------------------------------------------------------------------------*/
static afs_int32
-GetServerAndPart(a_vldbEntryP, a_servIDP, a_partIDP)
- struct vldbentry *a_vldbEntryP;
- afs_int32 *a_servIDP;
- afs_int32 *a_partIDP;
-
+GetServerAndPart(struct nvldbentry *a_vldbEntryP, afs_int32 *a_servIDP,
+ afs_int32 *a_partIDP)
{ /*GetServerAndPart */
/*
/*------------------------------------------------------------------------
+ * static ovlentry_to_nvlentry
+ *
+ * Description:
+ * Converts a vldbentry to nvldbentry.
+ *
+ * Arguments:
+ * oentryp IN : Ptr to vldbentry.
+ * nentryp OUT : Ptr to nvldbentry.
+ *
+ * Returns:
+ * None
+ *
+ * Environment:
+ * Nothing interesting.
+ *
+ * Side Effects:
+ * None.
+ *------------------------------------------------------------------------*/
+
+static void
+ovlentry_to_nvlentry(struct vldbentry *oentryp,
+ struct nvldbentry *nentryp)
+{
+ register int i;
+
+ memset(nentryp, 0, sizeof(struct nvldbentry));
+ strncpy(nentryp->name, oentryp->name, sizeof(nentryp->name));
+ for (i = 0; i < oentryp->nServers; i++) {
+ nentryp->serverNumber[i] = oentryp->serverNumber[i];
+ nentryp->serverPartition[i] = oentryp->serverPartition[i];
+ nentryp->serverFlags[i] = oentryp->serverFlags[i];
+ }
+ nentryp->nServers = oentryp->nServers;
+ for (i = 0; i < MAXTYPES; i++)
+ nentryp->volumeId[i] = oentryp->volumeId[i];
+ nentryp->cloneId = oentryp->cloneId;
+ nentryp->flags = oentryp->flags;
+}
+
+
+/*------------------------------------------------------------------------
+ * static uss_vol_GetEntryByID
+ *
+ * Description:
+ * Obtains a nvldbentry whether new or old forms of
+ * ubik_VL_GetEntryByID are required.
+ *
+ * Arguments:
+ * cstruct : Ptr to ubik_client.
+ * volid : Volume ID for which entry is being obtained.
+ * voltype : Required volume type
+ * entryp : Ptr to nvldbentry to receive the output on success.
+ *
+ * Returns:
+ * 0 if everything went well, or
+ * ubik return code otherwise.
+ *
+ * Environment:
+ * Nothing interesting.
+ *
+ * Side Effects:
+ * None.
+ *------------------------------------------------------------------------*/
+
+static int
+uss_vol_GetEntryByID(struct ubik_client *cstruct, afs_uint32 volid,
+ afs_int32 voltype, struct nvldbentry *entryp)
+{
+ struct vldbentry oentry;
+ int code;
+
+ code = ubik_VL_GetEntryByIDN(cstruct, 0, volid, voltype, entryp);
+ if (code == RXGEN_OPCODE) {
+ code =
+ ubik_VL_GetEntryByID(cstruct, 0, volid, voltype, &oentry);
+ if (!code)
+ ovlentry_to_nvlentry(&oentry, entryp);
+ }
+ return code;
+}
+
+
+/*------------------------------------------------------------------------
* EXPORTED uss_vol_GetVolInfoFromMountPoint
*
* Environment:
- * If the mountpoint path provided is not
+ * If the mountpoint path provided is not
*
* Side Effects:
* As advertised.
*------------------------------------------------------------------------*/
afs_int32
-uss_vol_GetVolInfoFromMountPoint(a_mountpoint)
- char *a_mountpoint;
-
+uss_vol_GetVolInfoFromMountPoint(char *a_mountpoint)
{ /*uss_vol_GetVolInfoFromMountPoint */
-
+#ifdef USS_VOL_DB
static char rn[] = "uss_vol_GetVolInfoFromMountPoint";
+#endif
register afs_int32 code; /*Return code */
uss_VolumeStatus_t *statusP; /*Ptr to returned status */
afs_int32 volID; /*Volume ID */
- struct vldbentry vldbEntry; /*VLDB entry for volume */
+ struct nvldbentry vldbEntry; /*VLDB entry for volume */
afs_int32 serverID; /*Addr of host FileServer */
afs_int32 partID; /*Volume's partition ID */
if (code)
return (code);
}
- code = ubik_Call(VL_GetEntryByID, uconn_vldbP, 0, volID, -1, &vldbEntry);
+ code = uss_vol_GetEntryByID( uconn_vldbP, volID, -1, &vldbEntry);
if (code) {
printf("%s: Can't fetch VLDB entry for volume ID %d\n", uss_whoami,
volID);
return (-1);
}
if (vldbEntry.nServers != 1) {
- printf("s: Volume '%s' (ID %d) exists on multiple servers!!\n",
+ printf("%s: Volume '%s' (ID %d) exists on multiple servers!!\n",
uss_whoami, uss_Volume, volID);
return (-1);
}