From: Peter Staubach <staubach@redhat.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: "Lever, Charles" <Charles.Lever@netapp.com>, nfs@lists.sourceforge.net
Subject: Re: historical question: nfs_rename()
Date: Tue, 18 Oct 2005 12:57:18 -0400 [thread overview]
Message-ID: <4355296E.4020606@redhat.com> (raw)
In-Reply-To: <1129651829.8989.17.camel@lade.trondhjem.org>
Trond Myklebust wrote:
>m=E5 den 17.10.2005 klokka 12:12 (-0700) skreiv Lever, Charles:
> =20
>
>>a customer recently pointed out that the rename(2) system call does not
>>allow replacing directories, even if they are empty. RFC1813 at least
>>suggests that the server and protocol do allow directory replacement, a=
s
>>long as the target is empty.
>>
>>the culprit appears to be this check in nfs_rename()
>>
>> if (S_ISDIR(new_inode->i_mode))
>> goto out;
>>
>>which causes nfs_rename() to return -EBUSY if the target is a directory.
>>
>>is there a historical reason why the Linux NFS client does not allow
>>directory replacement? shouldn't the error code be -EISDIR for this
>>case?
>> =20
>>
>
>Yes, the error should be EISDIR. I'm not sure that I agree with your
>assertion that rename failing is an NFS-only issue, though. The attached
>testcase fails on both XFS and ext3 too with the error "Rename failed:
>Is a directory".
>
>Cheers,
> Trond
>
> =20
>
>------------------------------------------------------------------------
>
>#include <sys/types.h>
>#include <sys/stat.h>
>#include <fcntl.h>
>#include <stdio.h>
>#include <stdlib.h>
>
>#define FILENAME "gnurr"
>#define DIRNAME "gnarg"
>
>void die(char *errmsg)
>{
> perror(errmsg);
> exit(1);
>}
>
>int main()
>{
> int fd;
> int err;
>
> fd =3D open(FILENAME, O_CREAT|O_EXCL|O_RDWR, 0644);
> if (fd < 0)
> die("File creation failed");
> close(fd);
> err =3D mkdir(DIRNAME, 0700);
> if (err !=3D 0)
> die("Directory creation failed");
> err =3D rename("gnurr", "gnarg");
> if (err !=3D 0)
> die("Rename failed");
>}
> =20
>
Actually, this case should fail with EISDIR, as it does. Mixing
directory and files in a rename(2) will fail with EISDIR or ENOTDIR.
However, renaming one directory to another directory, when the target
directory is "empty", should not fail.
ps
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
next prev parent reply other threads:[~2005-10-18 16:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-17 19:12 historical question: nfs_rename() Lever, Charles
2005-10-17 19:18 ` Peter Staubach
2005-10-18 16:10 ` Trond Myklebust
2005-10-18 16:57 ` Peter Staubach [this message]
2005-10-18 18:06 ` Trond Myklebust
-- strict thread matches above, loose matches on Subject: below --
2005-10-18 17:59 Lever, Charles
2005-10-18 18:03 ` Peter Staubach
2005-10-18 18:11 ` Trond Myklebust
2005-10-18 18:15 Lever, Charles
2005-10-18 18:36 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4355296E.4020606@redhat.com \
--to=staubach@redhat.com \
--cc=Charles.Lever@netapp.com \
--cc=nfs@lists.sourceforge.net \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.