SMBC_rename_ctx() for an already existing target
Har Gagan Sahai
shargagan at novell.com
Mon Jun 15 03:12:16 MDT 2015
Hi Samba Team,
Looking for more information on the way SMBC_rename in libsmbclient library is handling the rename operation when the target location is already existing.
The SMBC_rename_ctx() tries for the rename and then it checks for the errno value. If the value of errno is EEXIST then it deletes file on its own and re-try the rename operation. This is the code snippet from the SMBC_rename_ctx() where this decision is taken place :
if (!NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
int eno = SMBC_errno(ocontext, targetcli1);
if (eno != EEXIST ||
!NT_STATUS_IS_OK(cli_unlink(targetcli1, targetpath2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)) ||
!NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
errno = eno;
TALLOC_FREE(frame);
return -1;
}
}
Looking for some explanation on this approach of deleting the file in the call, rather than giving control to the user to decide whether it wants to delete the target, skip this as no-op etc ? Doesn't it sound like a bug ?
Thanks,
Har Gagan Sahai
More information about the samba-technical
mailing list