From 0c77c0acabe0a0588ab0a9efab0124ee1e15ef6a Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Thu, 2 Aug 2012 18:37:05 -0400 Subject: [PATCH] vos: convertROtoRW may create 2nd RW on a fileserver If an RW is already present on disk on the target server (any partition), 'vos convertROtoRW' will still convert the RO, creating a second RW on the server. Detect this and refuse to convert the RO by returning EXDEV (invalid cross-device link). Change-Id: Ide15a7c39f2a975fd8597e497094b6a67b448e4f Reviewed-on: http://gerrit.openafs.org/7934 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/namei_ops.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 0c006f8..7274af5 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -2894,6 +2894,8 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId) struct DiskPartition64 *partP; struct ViceInodeInfo info; struct VolumeDiskHeader h; + char *rwpart, *rwname; + Error ec; # ifdef AFS_DEMAND_ATTACH_FS int locktype = 0; # endif /* AFS_DEMAND_ATTACH_FS */ @@ -2923,6 +2925,19 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId) goto done; } + /* check for existing RW on any partition on this server; */ + /* if found, return EXDEV - invalid cross-device link */ + VOL_LOCK; + VGetVolumePath(&ec, h.parent, &rwpart, &rwname); + if (ec == 0) { + Log("1 namei_ConvertROtoRWvolume: RW volume %lu already exists on server partition %s.\n", + afs_printable_uint32_lu(h.parent), rwpart); + code = EXDEV; + VOL_UNLOCK; + goto done; + } + VOL_UNLOCK; + FSYNC_VolOp(volumeId, pname, FSYNC_VOL_BREAKCBKS, 0, NULL); ino = namei_MakeSpecIno(h.parent, VI_LINKTABLE); -- 1.9.4