vol-allocate-partition-names-dynamically-to-avoid-problems-with-vx-stuff-20020624

otherwise long device paths can screw you
This commit is contained in:
Kris Van Hees 2002-06-24 20:09:59 +00:00 committed by Derrick Brashear
parent de06f45787
commit 78b1f7ec56
2 changed files with 7 additions and 4 deletions

View File

@ -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;

View File

@ -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 */