From 14277e9b160a4d7a2d2db1b596748cea89e81559 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Fri, 20 Jan 2006 06:58:13 +0000 Subject: [PATCH] More rename fixes. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2217 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/uio/io.c | 4 +++- sc2/src/sc2code/libs/uio/ioaux.c | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/sc2/src/sc2code/libs/uio/io.c b/sc2/src/sc2code/libs/uio/io.c index 534972529..7a54c1b3d 100644 --- a/sc2/src/sc2code/libs/uio/io.c +++ b/sc2/src/sc2code/libs/uio/io.c @@ -372,6 +372,8 @@ uio_rename(uio_DirHandle *oldDir, const char *oldPath, } if (uio_mountInfoIsReadOnly(oldReadMountInfo)) { + // XXX: Doesn't uio_getPhysicalAccess already handle this? + // It doesn't return EROFS though; perhaps it should. uio_PDirHandle_unref(oldPReadDir); uio_PDirHandle_unref(newPReadDir); uio_PDirHandle_unref(newPWriteDir); @@ -391,7 +393,7 @@ uio_rename(uio_DirHandle *oldDir, const char *oldPath, return -1; } retVal = (oldReadMountInfo->pDirHandle->pRoot->handler->rename)( - oldPReadDir, oldName, newPReadDir, newName); + oldPReadDir, oldName, newPWriteDir, newName); if (retVal == -1) { int savedErrno = errno; uio_PDirHandle_unref(oldPReadDir); diff --git a/sc2/src/sc2code/libs/uio/ioaux.c b/sc2/src/sc2code/libs/uio/ioaux.c index d147ad744..8199e34cb 100644 --- a/sc2/src/sc2code/libs/uio/ioaux.c +++ b/sc2/src/sc2code/libs/uio/ioaux.c @@ -453,7 +453,7 @@ uio_getPhysicalAccess(uio_DirHandle *dirHandle, const char *path, // unless we intend to create it. if (flags & O_CREAT) { // The entry does not exist, but we can create it. - readItem = writeItem; + // Handled below. } else { // O_CREAT was not specified, so we cannot create // this entry. @@ -494,16 +494,8 @@ uio_getPhysicalAccess(uio_DirHandle *dirHandle, const char *path, return -1; } - // There exists no path for a write dir, so it will have to be created. - // writeMountInfo indicates the physical tree where it should end up. - - if (extraFlags & uio_GPA_NOWRITE) { - // The caller has specified that the path should not be created. - uio_PDirHandle_unref(readPDirHandle); - uio_free(fullPath); - errno = ENOENT; - return -1; - } + // Left is the case where the write location is different from the + // read location. pRootPath = uio_mountTreeItemRestPath(writeItem, tree->lastComp, fullPath); @@ -515,6 +507,17 @@ uio_getPhysicalAccess(uio_DirHandle *dirHandle, const char *path, uio_PDirHandle_ref(writeItem->mountInfo->pDirHandle); writePDirHandle = writeItem->mountInfo->pDirHandle; } else { + // There exists no path for a write dir, so it will have to be created. + // writeMountInfo indicates the physical tree where it should end up. + + if (extraFlags & uio_GPA_NOWRITE) { + // The caller has specified that the path should not be created. + uio_PDirHandle_unref(readPDirHandle); + uio_free(fullPath); + errno = ENOENT; + return -1; + } + writePDirHandle = uio_makePath(writeItem->mountInfo->pDirHandle, pRootPath, rest - pRootPath, 0777); if (writePDirHandle == NULL) { @@ -550,7 +553,7 @@ uio_getPhysicalAccess(uio_DirHandle *dirHandle, const char *path, if (readPRootPathPtr != NULL) *readPRootPathPtr = joinPathsAbsolute( readItem->mountInfo->dirName, readPRootPath); - *mountInfoReadPtr = writeItem->mountInfo; + *mountInfoWritePtr = writeItem->mountInfo; *writePDirHandlePtr = writePDirHandle; if (writePRootPathPtr != NULL) *writePRootPathPtr = joinPathsAbsolute(