smbfs mounted file, tail -f STILL does not work

root root at harlantype.com
Mon Nov 20 05:32:04 GMT 2000


Urban,

YES, this fixed the main problem.  There is still a problem with "ro", but I
can live with it.

I upgraded to 2.2.18-22 and then applied your patch.  I mounted the NT share
(RW) and ran the test.  It worked perfectly.  I then unmounted and mounted
with option "ro".  The test again worked, however, the file IS NOT read
only.  I was able to write to the NT file (and in fact, was able to delete
the file) from the linux box even though it was mounted "ro".

As I said, my critical need was to be able to "monitor" remote files, which
your patch does fix (thank you, thank you, thank you!!!).

Jason.


----- Original Message -----
From: "Urban Widmark" <urban at svenskatest.se>
To: "root" <root at harlantype.com>
Cc: <samba at us5.samba.org>
Sent: Sunday, November 19, 2000 10:56 AM
Subject: Re: smbfs mounted file, tail -f STILL does not work


> On Sat, 18 Nov 2000, root wrote:
>
> > No, "ping -t 127.0.0.1" loops internally (just like ping on linux).  It
IS
> > continuously appending to the file.  I am not re-executing the ping
command
>
> Didn't read the -t. Yes, I can see this problem.
>
> Running 'ping -t' and simultaneously a little program that does stat() and
> dumps some interesting info gives:
>
> (edited)
> size:  457
> atime: 974651104        mtime: 974651104        ctime: 974649966
> size:  508
> atime: 974651104        mtime: 974651104        ctime: 974649966
>
> [here the ping was terminated]
>
> size:  559
> atime: 974651114        mtime: 974651114        ctime: 974649966
>
> Notice how the mtime and atime does not change until after the ping is
> terminated. smbfs looks at the mtime only when deciding if it has recent
> info or not.
>
> Below is a patch vs 2.2.18-pre22 (21 is fine too) that changes this to
> also look at size changes, and removes the code that forces all open() to
> be read-write (I'm not sure why that is done ...)
>
> Please test and report.
>
> /Urban
>
>
> diff -urN -X exclude linux-2.2.18-pre22-orig/fs/smbfs/inode.c
linux-2.2.18-pre22-smbfs/fs/smbfs/inode.c
> --- linux-2.2.18-pre22-orig/fs/smbfs/inode.c Sun Nov 19 15:26:19 2000
> +++ linux-2.2.18-pre22-smbfs/fs/smbfs/inode.c Sun Nov 19 16:46:26 2000
> @@ -242,6 +242,7 @@
>  {
>   struct inode *inode = dentry->d_inode;
>   time_t last_time;
> + off_t size;
>   int error = 0;
>
>   DEBUG1("\n");
> @@ -250,8 +251,7 @@
>   * If this is a file opened with write permissions,
>   * the inode will be up-to-date.
>   */
> - if (S_ISREG(inode->i_mode) && smb_is_open(inode))
> - {
> + if (S_ISREG(inode->i_mode) && smb_is_open(inode)) {
>   if (inode->u.smbfs_i.access != SMB_O_RDONLY)
>   goto out;
>   }
> @@ -259,8 +259,7 @@
>   /*
>   * Check whether we've recently refreshed the inode.
>   */
> - if (time_before(jiffies, inode->u.smbfs_i.oldmtime + HZ/10))
> - {
> + if (time_before(jiffies, inode->u.smbfs_i.oldmtime + HZ/10)) {
>   VERBOSE("up-to-date, jiffies=%lu, oldtime=%lu\n",
>   jiffies, inode->u.smbfs_i.oldmtime);
>   goto out;
> @@ -268,15 +267,17 @@
>
>   /*
>   * Save the last modified time, then refresh the inode.
> - * (Note: a size change should have a different mtime.)
> + * (Note: a size change does not necessarily get a different mtime,
> + *  although it certainly should.)
>   */
>   last_time = inode->i_mtime;
> + size = inode->i_size;
>   error = smb_refresh_inode(dentry);
> - if (error || inode->i_mtime != last_time)
> - {
> - VERBOSE("%s/%s changed, old=%ld, new=%ld\n",
> + if (error || inode->i_mtime != last_time || inode->i_size != size) {
> + VERBOSE("%s/%s changed, mtime=%ld/%ld, size=%ld/%ld\n",
>   DENTRY_PATH(dentry),
> - (long) last_time, (long) inode->i_mtime);
> + (long) last_time, (long) inode->i_mtime,
> + last_size, inode->i_size);
>   if (!S_ISDIR(inode->i_mode))
>   invalidate_inode_pages(inode);
>   }
> diff -urN -X exclude linux-2.2.18-pre22-orig/fs/smbfs/proc.c
linux-2.2.18-pre22-smbfs/fs/smbfs/proc.c
> --- linux-2.2.18-pre22-orig/fs/smbfs/proc.c Sun Nov 19 15:26:19 2000
> +++ linux-2.2.18-pre22-smbfs/fs/smbfs/proc.c Sun Nov 19 16:39:27 2000
> @@ -28,6 +28,8 @@
>     config option. */
>  #define SMBFS_POSIX_UNLINK 1
>
> +/* #define SMB_FORCE_READWRITE 1 */
> +
>  #include "smb_debug.h"
>
>  #define SMB_VWV(packet)  ((packet) + SMB_HEADER_LEN)
> @@ -843,7 +845,7 @@
>   mode = read_write;
>   if (!(ino->i_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
>   mode = read_only;
> -#if 0
> +#ifndef SMB_FORCE_READWRITE
>   /* FIXME: why is this code not in? below we fix it so that a caller
>      wanting RO doesn't get RW. smb_revalidate_inode does some
>      optimization based on access mode. tail -f needs it to be correct. */
> @@ -883,8 +885,10 @@
>   /* smb_vwv2 has mtime */
>   /* smb_vwv4 has size  */
>   ino->u.smbfs_i.access = (WVAL(server->packet, smb_vwv6) & SMB_ACCMASK);
> +#ifdef  SMB_FORCE_READWRITE
>   if (!(wish & (O_WRONLY | O_RDWR)))
>   ino->u.smbfs_i.access = SMB_O_RDONLY;
> +#endif
>   ino->u.smbfs_i.open = server->generation;
>
>  out:
>





More information about the samba mailing list