VFS write not being called (was: VFS imlpementation and caching?)

Brad Sahr bsahr at macromedia.com
Fri Aug 25 22:35:02 GMT 2000


The following seems to work. The loop was lifted
directly from util_sock.c. Jeremy, will you update
fileio.c and let me know when it is updated? If
not, could you give me some guidance on doing so?
I believe there is going to be more changes needed
to fully support the VFS feature (preview: unlink
is not getting called within the VFS).

Brad

static ssize_t real_write_file(files_struct *fsp,char *data,SMB_OFF_T pos,
size_t n)
{
  size_t total=0;
  ssize_t ret;

  if ((pos != -1) && (seek_file(fsp,pos) == -1))
    return -1;

  while (total < n)
  {
    ret = fsp->conn->vfs_ops.write(fsp->fd,data + total,n - total);

    if (ret == -1) {
      DEBUG(0,("real_write_file: write failure. Error = %s\n",
         strerror(errno) ));
      return -1;
    }
    if (ret == 0)
      return (ssize_t)total;

    total += ret;
  }
  return (ssize_t)total;
}

-----Original Message-----
From: jeremy at valinux.com [mailto:jeremy at valinux.com]
Sent: Friday, August 25, 2000 10:18 AM
To: Brad Sahr
Cc: Samba Technical List
Subject: Re: VFS write not being called (was: VFS imlpementation and
caching?)


Brad Sahr wrote:
>
> I'm pretty new to the Samba source base, but here's my take
> on what's happening. Will you let me know if I'm on track here?
>
> The real_write_file() function in fileio.c looks like the
> politically correct place to make the call to the VFS.
>
> But, if real_write_file() in fileio.c is modified to call
> fsp->conn->vfs_ops.write(), the functionality currently
> provided by write_data() in util_sock.c will be bypassed.
> The write_data() function iteratively calls write() 'til
> all bytes are written.
>
> Existing chain of function calls:
> write_file()
>   real_write_file()
>     write_data()
>       write()
>         etc...
>
> Chain of function calls through VFS -if- vfs_ops.write() called in
fileio.c:
> write_file()
>   real_write_file()
>     vfswrap_write() (fsp->conn->vfs_ops.write())
>       write()
>         etc...
>
> How should this be addressed?

Easiest way is to duplicate the "until all bytes written"
semantics of write_data in real_write_file() and leave
the semantics of vfs_ops.write() alone (ie. may return less
written than was requested).

Jeremy.

--
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------





More information about the samba-technical mailing list