View | Details | Raw Unified | Return to bug 21808
Collapse All | Expand All

(-)msdosfs_vnops.c (-14 / +9 lines)
Lines 1056-1064 Link Here
1056
	if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
1056
	if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
1057
		newparent = 1;
1057
		newparent = 1;
1058
	if (doingdirectory && newparent) {
1058
	if (doingdirectory && newparent) {
1059
		if (error)	/* write access check above */
1059
		if (error)	/* write access check above */
1060
			goto bad;
1060
			goto bad1;
1061
		if (xp != NULL)
1061
		if (xp != NULL)
1062
			vput(tvp);
1062
			vput(tvp);
1063
		/*
1063
		/*
1064
		 * doscheckpath() vput()'s dp,
1064
		 * doscheckpath() vput()'s dp,
Lines 1084-1105 Link Here
1084
		 */
1084
		 */
1085
		if (xp->de_Attributes & ATTR_DIRECTORY) {
1085
		if (xp->de_Attributes & ATTR_DIRECTORY) {
1086
			if (!dosdirempty(xp)) {
1086
			if (!dosdirempty(xp)) {
1087
				error = ENOTEMPTY;
1087
				error = ENOTEMPTY;
1088
				goto bad;
1088
				goto bad1;
1089
			}
1089
			}
1090
			if (!doingdirectory) {
1090
			if (!doingdirectory) {
1091
				error = ENOTDIR;
1091
				error = ENOTDIR;
1092
				goto bad;
1092
				goto bad1;
1093
			}
1093
			}
1094
			cache_purge(tdvp);
1094
			cache_purge(tdvp);
1095
		} else if (doingdirectory) {
1095
		} else if (doingdirectory) {
1096
			error = EISDIR;
1096
			error = EISDIR;
1097
			goto bad;
1097
			goto bad1;
1098
		}
1098
		}
1099
		error = removede(dp, xp);
1099
		error = removede(dp, xp);
1100
		if (error)
1100
		if (error)
1101
			goto bad;
1101
			goto bad1;
1102
		vput(tvp);
1102
		vput(tvp);
1103
		xp = NULL;
1103
		xp = NULL;
1104
	}
1104
	}
1105
1105
Lines 1109-1117 Link Here
1109
	 * file/directory.
1109
	 * file/directory.
1110
	 */
1110
	 */
1111
	error = uniqdosname(VTODE(tdvp), tcnp, toname);
1111
	error = uniqdosname(VTODE(tdvp), tcnp, toname);
1112
	if (error)
1112
	if (error)
1113
		goto abortit;
1113
		goto bad1;
1114
1114
1115
	/*
1115
	/*
1116
	 * Since from wasn't locked at various places above,
1116
	 * Since from wasn't locked at various places above,
1117
	 * have to do a relookup here.
1117
	 * have to do a relookup here.
Lines 1151-1159 Link Here
1151
	if (xp != ip) {
1151
	if (xp != ip) {
1152
		if (doingdirectory)
1152
		if (doingdirectory)
1153
			panic("rename: lost dir entry");
1153
			panic("rename: lost dir entry");
1154
		vrele(ap->a_fvp);
1154
		vrele(ap->a_fvp);
1155
		VOP_UNLOCK(fvp, 0, p);
1156
		if (newparent)
1155
		if (newparent)
1157
			VOP_UNLOCK(fdvp, 0, p);
1156
			VOP_UNLOCK(fdvp, 0, p);
1158
		xp = NULL;
1157
		xp = NULL;
1159
	} else {
1158
	} else {
Lines 1176-1184 Link Here
1176
		if (error) {
1175
		if (error) {
1177
			bcopy(oldname, ip->de_Name, 11);
1176
			bcopy(oldname, ip->de_Name, 11);
1178
			if (newparent)
1177
			if (newparent)
1179
				VOP_UNLOCK(fdvp, 0, p);
1178
				VOP_UNLOCK(fdvp, 0, p);
1180
			VOP_UNLOCK(fvp, 0, p);
1181
			goto bad;
1179
			goto bad;
1182
		}
1180
		}
1183
		ip->de_refcnt++;
1181
		ip->de_refcnt++;
1184
		zp->de_fndoffset = from_diroffset;
1182
		zp->de_fndoffset = from_diroffset;
Lines 1186-1194 Link Here
1186
		if (error) {
1184
		if (error) {
1187
			/* XXX should really panic here, fs is corrupt */
1185
			/* XXX should really panic here, fs is corrupt */
1188
			if (newparent)
1186
			if (newparent)
1189
				VOP_UNLOCK(fdvp, 0, p);
1187
				VOP_UNLOCK(fdvp, 0, p);
1190
			VOP_UNLOCK(fvp, 0, p);
1191
			goto bad;
1188
			goto bad;
1192
		}
1189
		}
1193
		if (!doingdirectory) {
1190
		if (!doingdirectory) {
1194
			error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0,
1191
			error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0,
Lines 1196-1204 Link Here
1196
			if (error) {
1193
			if (error) {
1197
				/* XXX should really panic here, fs is corrupt */
1194
				/* XXX should really panic here, fs is corrupt */
1198
				if (newparent)
1195
				if (newparent)
1199
					VOP_UNLOCK(fdvp, 0, p);
1196
					VOP_UNLOCK(fdvp, 0, p);
1200
				VOP_UNLOCK(fvp, 0, p);
1201
				goto bad;
1197
				goto bad;
1202
			}
1198
			}
1203
			if (ip->de_dirclust == MSDOSFSROOT)
1199
			if (ip->de_dirclust == MSDOSFSROOT)
1204
				ip->de_diroffset = to_diroffset;
1200
				ip->de_diroffset = to_diroffset;
Lines 1225-1233 Link Here
1225
			      NOCRED, &bp);
1221
			      NOCRED, &bp);
1226
		if (error) {
1222
		if (error) {
1227
			/* XXX should really panic here, fs is corrupt */
1223
			/* XXX should really panic here, fs is corrupt */
1228
			brelse(bp);
1224
			brelse(bp);
1229
			VOP_UNLOCK(fvp, 0, p);
1230
			goto bad;
1225
			goto bad;
1231
		}
1226
		}
1232
		dotdotp = (struct direntry *)bp->b_data + 1;
1227
		dotdotp = (struct direntry *)bp->b_data + 1;
1233
		putushort(dotdotp->deStartCluster, dp->de_StartCluster);
1228
		putushort(dotdotp->deStartCluster, dp->de_StartCluster);
Lines 1235-1255 Link Here
1235
			putushort(dotdotp->deHighClust, dp->de_StartCluster >> 16);
1230
			putushort(dotdotp->deHighClust, dp->de_StartCluster >> 16);
1236
		error = bwrite(bp);
1231
		error = bwrite(bp);
1237
		if (error) {
1232
		if (error) {
1238
			/* XXX should really panic here, fs is corrupt */
1233
			/* XXX should really panic here, fs is corrupt */
1239
			VOP_UNLOCK(fvp, 0, p);
1240
			goto bad;
1234
			goto bad;
1241
		}
1235
		}
1242
	}
1236
	}
1243
1237
1244
	VOP_UNLOCK(fvp, 0, p);
1245
bad:
1238
bad:
1239
	VOP_UNLOCK(fvp, 0, p);
1240
	vrele(fdvp);
1241
bad1:
1246
	if (xp)
1242
	if (xp)
1247
		vput(tvp);
1243
		vput(tvp);
1248
	vput(tdvp);
1244
	vput(tdvp);
1249
out:
1245
out:
1250
	ip->de_flag &= ~DE_RENAME;
1246
	ip->de_flag &= ~DE_RENAME;
1251
	vrele(fdvp);
1252
	vrele(fvp);
1247
	vrele(fvp);
1253
	return (error);
1248
	return (error);
1254
1249
1255
}
1250
}

Return to bug 21808