diff --git a/src/vol/devname.c b/src/vol/devname.c index 2a0a6908f1..e884ecb67f 100644 --- a/src/vol/devname.c +++ b/src/vol/devname.c @@ -198,14 +198,14 @@ vol_DevName(dev_t adev, char *wpath) #endif if (wpath) { strcpy(pbuf, pbuffer); - ptr = (char *)strrchr(pbuf, '/'); + ptr = (char *)strrchr(pbuf, OS_DIRSEPC); if (ptr) { *ptr = '\0'; strcpy(wpath, pbuf); } else return NULL; } - ptr = (char *)strrchr(pbuffer, '/'); + ptr = (char *)strrchr(pbuffer, OS_DIRSEPC); if (ptr) { strcpy(pbuffer, ptr + 1); return pbuffer; @@ -241,7 +241,7 @@ afs_rawname(char *devfile) i = strlen(devfile); while (i >= 0) { strcpy(rawname, devfile); - if (devfile[i] == '/') { + if (devfile[i] == OS_DIRSEPC) { rawname[i + 1] = 'r'; rawname[i + 2] = 0; strcat(rawname, &devfile[i + 1]); @@ -251,7 +251,7 @@ afs_rawname(char *devfile) if (!code && S_ISCHR(statbuf.st_mode)) return rawname; - while ((--i >= 0) && (devfile[i] != '/')); + while ((--i >= 0) && (devfile[i] != OS_DIRSEPC)); } return NULL; diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index d7bc0c846d..d7f516a779 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -758,7 +758,7 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) VDeregisterVolOp_r(vp); } #else /* !AFS_DEMAND_ATTACH_FS */ - tvolName[0] = '/'; + tvolName[0] = OS_DIRSEPC; snprintf(&tvolName[1], sizeof(tvolName)-1, VFORMAT, afs_printable_uint32_lu(vcom->vop->volume)); tvolName[sizeof(tvolName)-1] = '\0'; @@ -1934,7 +1934,7 @@ FSYNC_Drop(osi_socket fd) Volume *vp; - tvolName[0] = '/'; + tvolName[0] = OS_DIRSEPC; sprintf(&tvolName[1], VFORMAT, afs_printable_uint32_lu(p[i].volumeID)); vp = VAttachVolumeByName_r(&error, p[i].partName, tvolName, V_VOLUPD); diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 47000a0af9..beed24553c 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -1366,13 +1366,13 @@ getDevName(char *pbuffer, char *wpath) { char pbuf[128], *ptr; strcpy(pbuf, pbuffer); - ptr = (char *)strrchr(pbuf, '/'); + ptr = (char *)strrchr(pbuf, OS_DIRSEPC); if (ptr) { *ptr = '\0'; strcpy(wpath, pbuf); } else return NULL; - ptr = (char *)strrchr(pbuffer, '/'); + ptr = (char *)strrchr(pbuffer, OS_DIRSEPC); if (ptr) { strcpy(pbuffer, ptr + 1); return pbuffer; diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index dcd7dbefc7..3751c65620 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -407,7 +407,7 @@ namei_CreateDataDirectories(namei_t * name, int *created) int i; *created = 0; - afs_snprintf(tmp, 256, "%s\\%s", name->n_drive, name->n_voldir); + afs_snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir); if (mkdir(tmp) < 0) { if (errno != EEXIST) @@ -418,7 +418,7 @@ namei_CreateDataDirectories(namei_t * name, int *created) s = tmp; s += strlen(tmp); - *s++ = '\\'; + *s++ = OS_DIRSEPC; *(s + 1) = '\0'; for (i = 'A'; i <= 'R'; i++) { *s = (char)i; @@ -441,7 +441,7 @@ do { \ #define create_nextdir(A) \ do { \ - strcat(tmp, "/"); strcat(tmp, A); create_dir(); \ + strcat(tmp, OS_DIRSEP); strcat(tmp, A); create_dir(); \ } while(0) static int @@ -494,7 +494,7 @@ delTree(char *root, char *tree, int *errp) if (*tree) { /* delete the children first */ - cp = strchr(tree, '/'); + cp = strchr(tree, OS_DIRSEPC); if (cp) { delTree(root, cp + 1, errp); *cp = '\0'; @@ -511,7 +511,7 @@ delTree(char *root, char *tree, int *errp) /* since root is big enough, we reuse the space to * concatenate the dirname to the current tree */ - strcat(root, "/"); + strcat(root, OS_DIRSEP); strcat(root, dirp->d_name); if (afs_stat(root, &st) == 0 && S_ISDIR(st.st_mode)) { /* delete this subtree */ @@ -565,11 +565,11 @@ namei_RemoveDataDirectories(namei_t * name) char tmp[256]; int i; - afs_snprintf(tmp, 256, "%s\\%s", name->n_drive, name->n_voldir); + afs_snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir); path = tmp; path += strlen(path); - *path++ = '\\'; + *path++ = OS_DIRSEPC; *(path + 1) = '\0'; for (i = 'A'; i <= 'R'; i++) { *path = (char)i; @@ -2479,7 +2479,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH, dp2->d_name); #else /* Now we've got to the actual data */ - afs_snprintf(path3, sizeof(path3), "%s\\%s", path1, + afs_snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s", path1, dp1->d_name); #endif dirp3 = opendir(path3); @@ -2617,7 +2617,7 @@ DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info, FdHandle_t linkHandle; char dirl; - afs_snprintf(fpath, sizeof(fpath), "%s\\%s", dpath, name); + afs_snprintf(fpath, sizeof(fpath), "%s" OS_DIRSEP "%s", dpath, name); dirH = FindFirstFileEx(fpath, FindExInfoStandard, &data, FindExSearchNameMatch, NULL, @@ -2653,8 +2653,8 @@ DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info, else { /* Open this handle */ char lpath[1024]; - (void)sprintf(lpath, "%s\\%s", fpath, data.cFileName); - linkHandle.fd_fd = nt_open(lpath, O_RDONLY, 0666); + (void)sprintf(lpath, "%s" OS_DIRSEP "%s", fpath, data.cFileName); + linkHandle.fd_fd = afs_open(lpath, O_RDONLY, 0666); info->linkCount = namei_GetLinkCount(&linkHandle, (Inode) 0, 0, 0, 0); } @@ -2663,11 +2663,11 @@ DecodeInode(char *dpath, char *name, struct ViceInodeInfo *info, namei_GetLinkCount(&linkHandle, info->inodeNumber, 0, 0, 0); if (info->linkCount == 0) { #ifdef DELETE_ZLC - Log("Found 0 link count file %s\\%s, deleting it.\n", + Log("Found 0 link count file %s" OS_DIRSEP "%s, deleting it.\n", fpath, data.cFileName); AddToZLCDeleteList(dirl, data.cFileName); #else - Log("Found 0 link count file %s\\%s.\n", path, + Log("Found 0 link count file %s" OS_DIRSEP "%s.\n", path, data.cFileName); #endif } else { @@ -3073,7 +3073,7 @@ AddToZLCDeleteList(char dir, char *name) } if (dir) - (void)sprintf(zlcCur->zlc_names[zlcCur->zlc_n], "%c\\%s", dir, name); + (void)sprintf(zlcCur->zlc_names[zlcCur->zlc_n], "%c" OS_DIRSEP "%s", dir, name); else (void)sprintf(zlcCur->zlc_names[zlcCur->zlc_n], "%s", name); @@ -3090,7 +3090,7 @@ DeleteZLCFiles(char *path) for (z = zlcAnchor; z; z = z->zlc_next) { for (i = 0; i < z->zlc_n; i++) { if (path) - (void)sprintf(fname, "%s\\%s", path, z->zlc_names[i]); + (void)sprintf(fname, "%s" OS_DIRSEP "%s", path, z->zlc_names[i]); else (void)sprintf(fname, "%s", z->zlc_names[i]); if (namei_unlink(fname) < 0) { diff --git a/src/vol/nuke.c b/src/vol/nuke.c index 4ca2eab99e..7313c2b782 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -155,7 +155,7 @@ nuke(char *aname, afs_int32 avolid) strcpy(devName, tfile); /* save this from the static buffer */ } /* aim lastDevComp at the 'foo' of '/dev/foo' */ - lastDevComp = strrchr(devName, '/'); + lastDevComp = strrchr(devName, OS_DIRSEPC); /* either points at slash, or there is no slash; adjust appropriately */ if (lastDevComp) lastDevComp++; diff --git a/src/vol/partition.c b/src/vol/partition.c index 1333429a89..4ec19b907c 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -259,7 +259,7 @@ VInitPartition_r(char *path, char *devname, Device dev) /* 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, OS_DIRSEP); strcat(dp->devName, "Lock"); mkdir(dp->devName, 0700); strcat(dp->devName, path); @@ -427,7 +427,7 @@ VIsAlwaysAttach(char *part, int *awouldattach) } strncpy(checkfile, part, 100); - strcat(checkfile, "/"); + strcat(checkfile, OS_DIRSEP); strcat(checkfile, VICE_ALWAYSATTACH_FILE); ret = afs_stat(checkfile, &st); @@ -451,9 +451,9 @@ VAttachPartitions2(void) char pname[32]; int wouldattach; - dirp = opendir("/"); + dirp = opendir(OS_DIRSEP); while ((de = readdir(dirp))) { - strcpy(pname, "/"); + strcpy(pname, OS_DIRSEP); strncat(pname, de->d_name, 20); pname[sizeof(pname) - 1] = '\0'; diff --git a/src/vol/vol-info.c b/src/vol/vol-info.c index ab51e59e04..667df83955 100644 --- a/src/vol/vol-info.c +++ b/src/vol/vol-info.c @@ -362,7 +362,7 @@ FindCurrentPartition(void) perror("pwd"); exit(1); } - p = strchr(&partName[1], '/'); + p = strchr(&partName[1], OS_DIRSEPC); if (p) { tmp = *p; *p = '\0'; diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 599a9bf1fa..84e2e02ef7 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -650,7 +650,7 @@ SalvageFileSysParallel(struct DiskPartition64 *partP) ShowLog = 0; for (fd = 0; fd < 16; fd++) close(fd); - open("/", 0); + open(OS_DIRSEP, 0); dup2(0, 1); dup2(0, 2); #ifndef AFS_NT40_ENV @@ -715,13 +715,13 @@ get_DevName(char *pbuffer, char *wpath) { char pbuf[128], *ptr; strcpy(pbuf, pbuffer); - ptr = (char *)strrchr(pbuf, '/'); + ptr = (char *)strrchr(pbuf, OS_DIRSEPC); if (ptr) { *ptr = '\0'; strcpy(wpath, pbuf); } else return NULL; - ptr = (char *)strrchr(pbuffer, '/'); + ptr = (char *)strrchr(pbuffer, OS_DIRSEPC); if (ptr) { strcpy(pbuffer, ptr + 1); return pbuffer; @@ -770,7 +770,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) #ifdef AFS_NT40_ENV /* Opendir can fail on "C:" but not on "C:\" if C is empty! */ - (void)sprintf(salvinfo->fileSysPath, "%s\\", salvinfo->fileSysPathName); + (void)sprintf(salvinfo->fileSysPath, "%s" OS_DIRSEP, salvinfo->fileSysPathName); name = partP->devName; #else strlcpy(salvinfo->fileSysPath, salvinfo->fileSysPathName, sizeof(salvinfo->fileSysPath)); @@ -833,7 +833,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) char npath[1024]; Log("Removing old salvager temp files %s\n", dp->d_name); strcpy(npath, salvinfo->fileSysPath); - strcat(npath, "/"); + strcat(npath, OS_DIRSEP); strcat(npath, dp->d_name); unlink(npath); } @@ -845,7 +845,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) (void)_putenv("TMP="); /* If "TMP" is set, then that overrides tdir. */ (void)strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255); #else - snprintf(inodeListPath, 255, "%s/salvage.inodes.%s.%d", tdir, name, + snprintf(inodeListPath, 255, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name, getpid()); #endif @@ -1169,7 +1169,7 @@ GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile, VolumeId singleVolum (void)strcpy(summaryFileName, _tempnam(tdir, "salvage.temp")); #else (void)afs_snprintf(summaryFileName, sizeof summaryFileName, - "%s/salvage.temp.%d", tdir, getpid()); + "%s" OS_DIRSEP "salvage.temp.%d", tdir, getpid()); #endif summaryFile = afs_fopen(summaryFileName, "a+"); if (summaryFile == NULL) { @@ -1545,7 +1545,7 @@ RecordHeader(struct DiskPartition64 *dp, const char *name, /* check if the header file is incorrectly named */ int badname = 0; - const char *base = strrchr(name, '/'); + const char *base = strrchr(name, OS_DIRSEPC); if (base) { base++; } else { @@ -3278,7 +3278,7 @@ GetDirName(struct SalvInfo *salvinfo, VnodeId vnode, struct VnodeEssence *vp, } if (vp->parent && vp->name && (parentvp = CheckVnodeNumber(salvinfo, vp->parent)) && GetDirName(salvinfo, vp->parent, parentvp, path)) { - strcat(path, "/"); + strcat(path, OS_DIRSEP); strcat(path, vp->name); return path; } diff --git a/src/vol/volume.c b/src/vol/volume.c index cae075a974..5b3973a67c 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -2430,7 +2430,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) VOL_UNLOCK; - strcat(path, "/"); + strcat(path, OS_DIRSEP); strcat(path, name); if (!vp) { @@ -2629,7 +2629,7 @@ VAttachVolumeByVp_r(Error * ec, Volume * vp, int mode) VOL_UNLOCK; - strcat(path, "/"); + strcat(path, OS_DIRSEP); strcat(path, name); /* do volume attach @@ -6480,7 +6480,7 @@ VGetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep) struct DiskPartition64 *dp; *ec = 0; - name[0] = '/'; + name[0] = OS_DIRSEPC; (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, afs_printable_uint32_lu(volumeId)); for (dp = DiskPartitionList; dp; dp = dp->next) { struct afs_stat status; @@ -6509,14 +6509,14 @@ VGetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep) * @return volume number * * @note the string must be of the form VFORMAT. the only permissible - * deviation is a leading '/' character. + * deviation is a leading OS_DIRSEPC character. * * @see VFORMAT */ int VolumeNumber(char *name) { - if (*name == '/') + if (*name == OS_DIRSEPC) name++; return atoi(name + 1); }