replacing file contents in a vfs module

Jakub Szarlat jakubjs at wehi.EDU.AU
Tue Apr 21 22:46:26 MDT 2015


Hi Richard.

Thanks for the pointer. I was trying to work out how the length was being set. I now added a fstat function into my module and for testing just set the size to 16 (btw this was the value of my result) and the entire contents was returned. Now that I got all my pieces working I can actually go and code the real thing.

cheers,
Jakub


----- Original Message -----
From: "Richard Sharpe" <realrichardsharpe at gmail.com>
To: "Jakub Szarlat" <jakubjs at wehi.edu.au>
Cc: "samba-technical" <samba-technical at lists.samba.org>
Sent: Wednesday, 22 April, 2015 12:20:54 PM
Subject: Re: replacing file contents in a vfs module

On Tue, Apr 21, 2015 at 6:48 PM, Jakub Szarlat <jakubjs at wehi.edu.au> wrote:
> Hi Richard.
>
> The issue I'm still having is the length value passed to pread. Even though my pread function stores the full string into the data variable. The data sent to the client is only equal to the length value. I'm not sure where this is set to and passed as the 4th parameter.
>
> This is my test pread function
>
>
> static ssize_t stornext_pread(vfs_handle_struct *handle, files_struct *fsp,
>                            void *data, size_t n, off_t offset)
> {
>         ssize_t result;
>         int fh;
>
>
>         if( strcmp(fsp->fsp_name->base_name,"aaa/test.txt")==0){
>                 fh = open("/tmp/test.txt",O_RDONLY);
>                 //result= pread(fh,data,n,offset);
>                 result= read(fh,data,1024);
>                 close(fh);
>                 DEBUG(1, ("PREAD file name: '%s' %d %d %d\n",  data,n,fsp->fh->pos,strlen(data)));
>                 fsp->fh->pos=0;
>                 return result;
>         }else{
>                 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
>         }
>         //result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
>
>         return result;
> }
>
> This is the debug data I get from my PREAD
>   PREAD file name: 'Tes hello there
>   ����� ' 12 0 22
>
> but client reading the file only gets
> Tes hello th

So, you didn't print out the value of result, so you do not know how
many bytes the read actually returned. Maybe it only returned  12
bytes, which appears to be what was asked for.

It seems like your earlier stat call is saying that the file is only
12 bytes long.

Even though you asked it to read 1024 bytes and there was 15 bytes in
the file, if the client only asks for 12, that is all it will get, I
guess.

Did you grab a capture to see what was being returned in the Get Info call etc?

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)

______________________________________________________________________
The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
______________________________________________________________________


More information about the samba-technical mailing list