From 78b1f7ec565ec32e114e80035581f95de50a9f04 Mon Sep 17 00:00:00 2001 From: Kris Van Hees Date: Mon, 24 Jun 2002 20:09:59 +0000 Subject: [PATCH] vol-allocate-partition-names-dynamically-to-avoid-problems-with-vx-stuff-20020624 otherwise long device paths can screw you --- src/vol/partition.c | 7 +++++-- src/vol/partition.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vol/partition.c b/src/vol/partition.c index e361761570..4b2f6e1189 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -190,9 +190,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"); @@ -201,7 +203,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 c583bd0af6..e471dea547 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 */