}
}
- if (NULL == (upath = mtoupath(vol, newname, curdir->d_did, utf8_encoding()))){
- return AFPERR_PARAM;
+ if (NULL == (upath = mtoupath(vol, newname, curdir->d_did, utf8_encoding()))){
+ rc = AFPERR_PARAM;
+ goto exit;
}
path.u_name = upath;
- st = &path.st;
+ st = &path.st;
if (0 != (rc = check_name(vol, upath))) {
- return rc;
+ goto exit;
}
/* source == destination. we just silently accept this. */
- if ((!isdir && curdir == sdir) || (isdir && curdir == sdir->d_parent)) {
+ if ((!isdir && curdir == sdir) || (isdir && curdir->d_did == sdir->d_pdid)) {
- if (strcmp(oldname, newname) == 0)
- return AFP_OK;
+ if (strcmp(oldname, newname) == 0) {
+ rc = AFP_OK;
+ goto exit;
+ }
if (stat(upath, st) == 0 || caseenumerate(vol, &path, curdir) == 0) {
if (!stat(p, &nst) && !(nst.st_dev == st->st_dev && nst.st_ino == st->st_ino) ) {
}
if ( rc == AFP_OK && id ) {
/* renaming may have moved the file/dir across a filesystem */
- if (stat(upath, st) < 0)
- return AFPERR_MISC;
+ if (stat(upath, st) < 0) {
+ rc = AFPERR_MISC;
+ goto exit;
+ }
+
+ if (dir_modify(vol,
+ sdir,
+ curdir->d_did,
+ 0,
+ newname,
+ upath,
+ S_ISDIR(st->st_mode) ? curdir->d_fullpath : NULL) != 0) {
+ LOG(log_error, logtype_afpd, "moveandrename: dir_modify error: %s -> %s",
+ p, upath);
+ return AFPERR_MISC;
+ }
+
/* fix up the catalog entry */
cnid_update(vol->v_cdb, id, st, curdir->d_did, upath, strlen(upath));
}