Bug 4090 - Wrong timestamps when connecting to an OS/2 server
Wrong timestamps when connecting to an OS/2 server
Status: RESOLVED FIXED
Product: CifsVFS
Classification: Unclassified
Component: kernel fs
2.6
x86 OS/2
: P3 normal
: ---
Assigned To: Steve French
:
: 4091 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-07 17:40 UTC by Guenter Kukkukk
Modified: 2006-11-16 16:41 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guenter Kukkukk 2006-09-07 17:40:56 UTC
Hi Steve,

as you said "...file a bug - so it is not getting lost...". :-)

As already noted in private email, I've started to test the new
cifs additions regarding older SMB dialects.

I have built the cifs module with the option
CONFIG_CIFS_WEAK_PW_HASH
and I'm now able to connect to OS/2 boxes.

There's a glitch in the display of _all_ timestamps!
All are shown as 1970 or 1940 or similar. It depends
a bit on the tool one is using to browse directories.

I'm currently in the process of comparing time related
stuff in smbfs with similar ones in cifs. (Cause smbfs
seems to do it right ... )

Will drop you a note, when I've found a solution.
Probably you are also working on that stuff. (?) :-)

Cheers - Guenter

btw - you can also reach me on irc.freenode.net in channels
#samba-os2
#samba-os2-technical
My nickname is kukks
Comment 1 Guenter Kukkukk 2006-09-09 17:31:12 UTC
*** Bug 4091 has been marked as a duplicate of this bug. ***
Comment 2 Steve French 2006-11-07 10:41:09 UTC
Now that os/2 time stamp code is added am closing this more general bug report. Please create a new bug if the current code is missing a date/time feature that you need.
Comment 3 Guenter Kukkukk 2006-11-14 22:29:32 UTC
Hi Steve,

please tell me, _where_ in the cifs kernel code this problem has been solved.
Atm - there are only some very basic "query file time" routines added to the
"test"-branch.
AFAIK - no code has been written so far for the "set time" case.

Mounting a legacy server (like OS/2) now with all the very special mount 
options leads to a _disaster_ on the foreign file system!

After the 2006 cifs-conference, many very wellknown IT-magazines around
the world, reported ... that smbfs can easily be dropped now ... being
easily replaced by cifs... cifs _now_ does support all the legacy servers, too!

O_o what a mess - and mis-information. (Who sold that to the press?)

I must admit, that I got heavily distracted by other customers needs in the
past 3 weeks - being not able to work and comment on cifs ... and stay
in contact with you.

Friendly spoken - this seems to be no reason to simply mark this bug
report as 'closed' or 'fixed' - nothing is fixed.
(or whatever your intention was...)

Such 'guru' behaviour is making all co-working efforts even more
worse!

Cheers, Guenter Kukkukk 

Sorry - I feel a bit upset ...
Comment 4 Steve French 2006-11-16 14:58:55 UTC
I have not been claiming os/2 support is perfect but need specifics

It is rare to need to set a file time from the client
(the utime/utimes calls AFAIK are the only cases) - as file times are 
set implicitly to what the server thinks they should be then read back.
I can fix the utimes case, but please let me know if there is another case
to fix.

Comment 5 Steve French 2006-11-16 15:45:23 UTC
OK - I see at least one bug in this sequence (timezone seems off on one of the new files - see below).

smf-t41p:/mnt/test # date
Thu Nov 16 15:38:34 CST 2006
smf-t41p:/mnt/test # touch testfile
smf-t41p:/mnt/test # ls -l
total 0
-rw-r--r-- 1 root root 0 2006-11-16 15:38 testfile

/* Copy file TODO from other window via smbclient */

smf-t41p:/mnt/test # ls -l
total 4
-rw-r--r-- 1 root root   0 2006-11-16 15:38 testfile
-rwxrwSrwt 1 root root 116 2006-11-16 15:39 TODO
smf-t41p:/mnt/test # mkdir newdir
smf-t41p:/mnt/test # ls -l
total 4
drwxr-xr-x 2 root root   0 2006-11-16 15:40 newdir
-rw-r--r-- 1 root root   0 2006-11-16 15:38 testfile
-rwxrwSrwt 1 root root 116 2006-11-16 15:39 TODO
smf-t41p:/mnt/test # stat /mnt/testfile
stat: cannot stat `/mnt/testfile': No such file or directory
smf-t41p:/mnt/test # stat /mnt/test/testfile
  File: `/mnt/test/testfile'
  Size: 0               Blocks: 0          IO Block: 16384  regular empty file
Device: 13h/19d Inode: 14844       Links: 0
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2006-11-16 15:41:10.456500356 -0600
Modify: 2006-11-16 10:38:32.000000000 -0600
Change: 2006-11-16 10:38:32.000000000 -0600
smf-t41p:/mnt/test # cd ~
smf-t41p:~ # umount /mnt
smf-t41p:~ # ~stevef/mount-script
smf-t41p:~ # stat /mnt/test/testfile
  File: `/mnt/test/testfile'
  Size: 0               Blocks: 0          IO Block: 16384  regular empty file
Device: 13h/19d Inode: 14975       Links: 0
Access: (3767/-rwxrwSrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2006-11-16 15:42:00.635359886 -0600
Modify: 2006-11-16 10:38:32.000000000 -0600
Change: 2006-11-16 10:38:32.000000000 -0600
smf-t41p:~ # cd /mnt/test
smf-t41p:/mnt/test # ls -l
total 4
drwxrwxrwx 1 root root   0 2006-11-16 15:40 newdir
-rwxrwSrwt 0 root root   0 2006-11-16 10:38 testfile
-rwxrwSrwt 1 root root 116 2006-11-16 15:39 TODO
Comment 6 Steve French 2006-11-16 16:31:50 UTC
This seems to work, but I need to clean it up (due to differences in which field are returned in findfirst vs. queryattribute it sets the access time to the local time on the client + TZ which is wrong, but the other two timestamps are right)

diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index f1f8225..d31a26f 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -90,6 +90,7 @@ extern int cifs_get_inode_info(struct in
 extern int cifs_get_inode_info_unix(struct inode **pinode,
                        const unsigned char *search_path,
                        struct super_block *sb,int xid);
+extern void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode);

 extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
                        const char *);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 1ad8c9f..a62915f 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -318,6 +318,7 @@ int cifs_get_inode_info(struct inode **p
        struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
        char *tmp_path;
        char *buf = NULL;
+       int adjustTZ = FALSE;

        pTcon = cifs_sb->tcon;
        cFYI(1,("Getting info on %s", search_path));
@@ -348,6 +349,7 @@ int cifs_get_inode_info(struct inode **p
                                        pfindData, cifs_sb->local_nls,
                                        cifs_sb->mnt_cifs_flags &
                                          CIFS_MOUNT_MAP_SPECIAL_CHR);
+                       adjustTZ = TRUE;
                }

        }
@@ -444,6 +446,8 @@ int cifs_get_inode_info(struct inode **p
                inode->i_ctime =
                    cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
                cFYI(0, ("Attributes came in as 0x%x", attr));
+               if(adjustTZ)
+                       AdjustForTZ(pTcon, inode);

                /* set default mode. will override for dirs below */
                if (atomic_read(&cifsInfo->inUse) == 0)
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index ed18c39..69835cf 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -106,7 +106,7 @@ static int construct_dentry(struct qstr
        return rc;
 }

-static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
+void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
 {
        if((tcon) && (tcon->ses) && (tcon->ses->server)) {
                inode->i_ctime.tv_sec += tcon->ses->server->timeAdj
Comment 7 Steve French 2006-11-16 16:41:01 UTC
A little confusing since the local access time is set in querypathinfo case (stat) and it is somehow not taking into account daylight savings time (or the os/2 server isn't)

but in any case the patch seems to work now

smf-t41p:/home/stevef/cifs-2.6 # stat /mnt/test/newfile
  File: `/mnt/test/newfile'
  Size: 0               Blocks: 0          IO Block: 16384  regular empty file
Device: 12h/18d Inode: 17830       Links: 0
Access: (3767/-rwxrwSrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2006-11-16 16:40:03.825855600 -0600
Modify: 2006-11-16 15:47:18.000000000 -0600
Change: 2006-11-16 15:47:18.000000000 -0600
smf-t41p:/home/stevef/cifs-2.6 # ls /mnt/test -l
total 4
drwxrwxrwx 1 root root   0 2006-11-16 15:40 newdir
-rwxrwSrwt 1 root root   0 2006-11-16 15:47 newerfile
-rwxrwSrwt 0 root root   0 2006-11-16 15:47 newfile
-rwxrwSrwt 1 root root   0 2006-11-16 15:38 testfile
-rwxrwSrwt 1 root root 116 2006-11-16 15:39 TODO