From: Kris Van Hees Date: Wed, 10 Jul 2002 21:41:45 +0000 (+0000) Subject: STABLE12-vol-allocate-partition-names-dynamically-to-avoid-problems-with-vx-stuff... X-Git-Tag: openafs-stable-1_2_6~41 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=de830d832d6444df92486fb3b72ca9d8cde61e68;p=packages%2Fo%2Fopenafs.git STABLE12-vol-allocate-partition-names-dynamically-to-avoid-problems-with-vx-stuff-20020624 otherwise long device paths can screw you (cherry picked from commit 78b1f7ec565ec32e114e80035581f95de50a9f04) --- diff --git a/src/vol/partition.c b/src/vol/partition.c index fcdafbe9a..2a63e32cd 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -194,9 +194,11 @@ static void VInitPartition_r(char *path, char *devname, Device dev) else DiskPartitionList = dp; dp->next = 0; - strcpy(dp->name, path); + dp->name = (char *)malloc(strlen(path) + 1); + strncpy(dp->name, path, strlen(path) + 1); #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV) /* Create a lockfile for the partition, of the form /vicepa/Lock/vicepa */ + dp->devName = (char *)malloc(2 * strlen(path) + 6); strcpy(dp->devName, path); strcat(dp->devName, "/"); strcat(dp->devName, "Lock"); @@ -205,7 +207,8 @@ static void VInitPartition_r(char *path, char *devname, Device dev) close(open(dp->devName, O_RDWR | O_CREAT, 0600)); dp->device = volutil_GetPartitionID(path); #else - strcpy(dp->devName, devname); + dp->devName = (char *)malloc(strlen(devname) + 1); + strncpy(dp->devName, devname, strlen(devname) + 1); dp->device = dev; #endif dp->lock_fd = -1; diff --git a/src/vol/partition.h b/src/vol/partition.h index c583bd0af..e471dea54 100644 --- a/src/vol/partition.h +++ b/src/vol/partition.h @@ -50,8 +50,8 @@ */ struct DiskPartition { struct DiskPartition *next; - char name[32]; /* Mounted partition name */ - char devName[32]; /* Device mounted on */ + char *name; /* Mounted partition name */ + char *devName; /* Device mounted on */ Device device; /* device number */ int lock_fd; /* File descriptor of this partition if locked; otherwise -1; Not used by the file server */