[linux-cifs-client] mkdir -p problem
diff mbox

Message ID 200902270024.58900.piastry@etersoft.ru
State New, archived
Headers show

Commit Message

Pavel Shilovsky Feb. 26, 2009, 9:24 p.m. UTC
Hello!

I have such a situation.

I mount samba share with uid options and try to exec mkdir command. I have 
that cifs driver don't set uid during the one second - that's why i have a 
problem with creating hierarchy of directories. Cifs creates the first 
directory and when it try to create the second in it gets permission denied 
because driver don't set uid that I chose during mounting.

I looked on the code and found such an interesting thing:
when driver create directory, it calls posix_fill_in_inode() function that 
calls cifs_unix_info_to_inode() with force_uid_gid = 1 - driver don't set 
mnt_uid and mnt_gid after creating even if they were chosen.

That's why when I tried to "mkdir -p 1/2/3" in root share directory it failed.

I patched it with:


and mkdir -p worked successful. Is it a bug or there are some other reason to 
do this?

Comments

Günter Kukkukk Feb. 27, 2009, 6:21 p.m. UTC | #1
Am Donnerstag, 26. Februar 2009 schrieb Pavel Shilovsky:
> Hello!
> 
> I have such a situation.
> 
> I mount samba share with uid options and try to exec mkdir command. I have 
> that cifs driver don't set uid during the one second - that's why i have a 
> problem with creating hierarchy of directories. Cifs creates the first 
> directory and when it try to create the second in it gets permission denied 
> because driver don't set uid that I chose during mounting.
> 
> I looked on the code and found such an interesting thing:
> when driver create directory, it calls posix_fill_in_inode() function that 
> calls cifs_unix_info_to_inode() with force_uid_gid = 1 - driver don't set 
> mnt_uid and mnt_gid after creating even if they were chosen.
> 
> That's why when I tried to "mkdir -p 1/2/3" in root share directory it failed.
> 
> I patched it with:
> 
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 9c548f1..e02de2b 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -843,7 +843,7 @@ static void posix_fill_in_inode(struct inode *tmp_inode,
>         local_mtime = tmp_inode->i_mtime;
>         local_size  = tmp_inode->i_size;
> 
> -       cifs_unix_info_to_inode(tmp_inode, pData, 1);
> +       cifs_unix_info_to_inode(tmp_inode, pData, 0);
>         cifs_set_ops(tmp_inode, false);
> 
>         if (!S_ISREG(tmp_inode->i_mode))
> 
> and mkdir -p worked successful. Is it a bug or there are some other reason to 
> do this?
> 

you haven't mentioned the version of cifs vfs you are running.
'modinfo cifs' will tell.

Cheers, Günter
Pavel Shilovsky Feb. 27, 2009, 8:41 p.m. UTC | #2
On Friday 27 February 2009 21:21:57 Günter Kukkukk wrote:
> Am Donnerstag, 26. Februar 2009 schrieb Pavel Shilovsky:
> > Hello!
> >
> > I have such a situation.
> >
> > I mount samba share with uid options and try to exec mkdir command. I
> > have that cifs driver don't set uid during the one second - that's why i
> > have a problem with creating hierarchy of directories. Cifs creates the
> > first directory and when it try to create the second in it gets
> > permission denied because driver don't set uid that I chose during
> > mounting.
> >
> > I looked on the code and found such an interesting thing:
> > when driver create directory, it calls posix_fill_in_inode() function
> > that calls cifs_unix_info_to_inode() with force_uid_gid = 1 - driver
> > don't set mnt_uid and mnt_gid after creating even if they were chosen.
> >
> > That's why when I tried to "mkdir -p 1/2/3" in root share directory it
> > failed.
> >
> > I patched it with:
> >
> > diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> > index 9c548f1..e02de2b 100644
> > --- a/fs/cifs/inode.c
> > +++ b/fs/cifs/inode.c
> > @@ -843,7 +843,7 @@ static void posix_fill_in_inode(struct inode
> > *tmp_inode, local_mtime = tmp_inode->i_mtime;
> >         local_size  = tmp_inode->i_size;
> >
> > -       cifs_unix_info_to_inode(tmp_inode, pData, 1);
> > +       cifs_unix_info_to_inode(tmp_inode, pData, 0);
> >         cifs_set_ops(tmp_inode, false);
> >
> >         if (!S_ISREG(tmp_inode->i_mode))
> >
> > and mkdir -p worked successful. Is it a bug or there are some other
> > reason to do this?
>
> you haven't mentioned the version of cifs vfs you are running.
> 'modinfo cifs' will tell.
Sorry, this is 1.54 version of cifs driver and I tested on 2.6.27 kernel.
>
> Cheers, Günter
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
Pavel Shilovsky March 3, 2009, 7:15 p.m. UTC | #3
What's about this problem?

Patch
diff mbox

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9c548f1..e02de2b 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -843,7 +843,7 @@  static void posix_fill_in_inode(struct inode *tmp_inode,
        local_mtime = tmp_inode->i_mtime;
        local_size  = tmp_inode->i_size;

-       cifs_unix_info_to_inode(tmp_inode, pData, 1);
+       cifs_unix_info_to_inode(tmp_inode, pData, 0);
        cifs_set_ops(tmp_inode, false);

        if (!S_ISREG(tmp_inode->i_mode))