|
From: Jan-Benedict G. <jb...@us...> - 2004-09-23 13:43:10
|
Update of /cvsroot/linux-vax/kernel-2.5/fs/ods2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6789 Modified Files: Makefile inode.c ods2.h util.c Log Message: - Implement some functions for timestamp handling / conversion between VMS' timestamps and the struct timespec Linux uses in it's VFS. However, I don't know if this is actually *correct* as it is implemented right now. Index: inode.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/inode.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- inode.c 23 Sep 2004 02:06:27 -0000 1.9 +++ inode.c 23 Sep 2004 13:43:02 -0000 1.10 @@ -230,12 +230,9 @@ inode->i_uid = le16_to_cpu (fh2p->u5.s1.fh2_w_mem); inode->i_gid = le16_to_cpu (fh2p->u5.s1.fh2_w_grp); - inode->i_ctime.tv_sec = vms2unix_sec (fi2p->fi2_q_credate); - inode->i_ctime.tv_nsec = vms2unix_nsec (fi2p->fi2_q_credate); - inode->i_mtime.tv_sec = vms2unix_sec (fi2p->fi2_q_revdate); - inode->i_mtime.tv_nsec = vms2unix_nsec (fi2p->fi2_q_revdate); - inode->i_atime.tv_sec = vms2unix_sec (fi2p->fi2_q_revdate); - inode->i_atime.tv_nsec = vms2unix_nsec (fi2p->fi2_q_revdate); + vms2timespec (&inode->i_ctime, fi2p->fi2_q_credate); + vms2timespec (&inode->i_mtime, fi2p->fi2_q_revdate); + vms2timespec (&inode->i_atime, fi2p->fi2_q_revdate); /* * Note that we don't use the system Index: util.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/util.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- util.c 23 Sep 2004 02:07:49 -0000 1.11 +++ util.c 23 Sep 2004 13:43:02 -0000 1.12 @@ -20,17 +20,6 @@ #include <linux/buffer_head.h> #include "ods2.h" -static u64 -div64 (u64 a, u32 b0) { - u32 a1, a2; - u32 res; - - a1 = ((u32 *)&a)[0]; - a2 = ((u32 *)&a)[1]; - res = a1/b0 + (u64)a2 * (u64)(0xffffffff/b0) + a2 / b0 + (a2 * (0xffffffff % b0)) / b0; - return res; -} - u32 vbn2lbn (struct super_block *sb, struct ods2map *map, u32 vbn) { @@ -208,22 +197,24 @@ * It works for a file created 1-jan-1971 and for a file created 1-jan-2038 * as well as for files created 1992 and 2003. * - * FIXME: Needs 2.4.x i_[cma]time -> 2.6.x i_[cma]time porting!!! - * FIXME: "u16 *vms_timestamp" is an array in real life, which gets - * casted to a u64 later on... */ -time_t -vms2unix_sec (u16 *vms_timestamp) +void +vms2timespec (struct timespec *dest, vms_timestamp_t src) { - printk (KERN_ERR "%s probably isn't yet correct, because it uses 2.4.x style i_[mca]time!\n", __FUNCTION__); - return (u64)div64((le64_to_cpu(*(u64 *)&(vms_timestamp)) - 0x007c953d63a19980ull) >> 7, 78125) + 2; + /* time_t = (vms-350669880092000)/10000000 + 2 */ + dest->tv_sec = (le64_to_cpu (src) - 35066988009200000ull) / 10000000 + 2; + dest->tv_nsec = (le64_to_cpu (src) - 35066988009200000ull) % 10000000; } -long -vms2unix_nsec (u16 *vms_timestamp) +void +timespec2vms (vms_timestamp_t *dest, struct timespec *src) { - printk (KERN_ERR "%s isn't yet correct!\n", __FUNCTION__); - return 0; + vms_timestamp_t temp; + + /* vms = 10000000 * (time_t - 2) + 35066988009200000 */ + temp = (src->tv_sec - 2) * 10000000 + 35066988009200000ull; + temp += src->tv_nsec / 100; + *dest = cpu_to_le64 (temp); } int Index: Makefile =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile 22 Sep 2004 06:24:30 -0000 1.3 +++ Makefile 23 Sep 2004 13:43:02 -0000 1.4 @@ -6,7 +6,3 @@ ods2-objs := super.o inode.o file.o dir.o util.o -# Intentionally misspelled, only for local compile testing -lcean: - -rm -f *.o *.lst .*.o.cmd - Index: ods2.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/fs/ods2/ods2.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ods2.h 22 Sep 2004 09:13:39 -0000 1.9 +++ ods2.h 23 Sep 2004 13:43:02 -0000 1.10 @@ -29,6 +29,12 @@ #define ODS2_SB(sb) (sb->s_fs_info) /* + * VMS' timestamps are a 64bit unsigned integer, with little-endian + * on-disk format. So *always* keep a vms_timestamp_t in LE byteorder! + */ +typedef u64 vms_timestamp_t; + +/* * This is the home block on a ODS2 disk. */ struct hm2def { @@ -140,14 +146,14 @@ * fives different tomes as well as the file name. */ struct fi2def { - char fi2_t_filename[20]; - u16 fi2_w_revision; - u16 fi2_q_credate[4]; // really __int64 - u16 fi2_q_revdate[4]; // really __int64 - u16 fi2_q_expdate[4]; // really __int64 - u16 fi2_q_bakdate[4]; // really __int64 - char fi2_filenameext[66]; - //char fi2_t_userlabel[80]; // from http://www.pi-net.dyndns.org/conan/sys$common/syslib/sys$lib_c.tlb?key=FI2DEF&title=Library%20/sys$common/syslib/sys$lib_c.tlb&referer= + char fi2_t_filename[20]; + u16 fi2_w_revision; + vms_timestamp_t fi2_q_credate; + vms_timestamp_t fi2_q_revdate; + vms_timestamp_t fi2_q_expdate; + vms_timestamp_t fi2_q_bakdate; + char fi2_filenameext[66]; + //char fi2_t_userlabel[80]; // from http://www.pi-net.dyndns.org/conan/sys$common/syslib/sys$lib_c.tlb?key=FI2DEF&title=Library%20/sys$common/syslib/sys$lib_c.tlb&referer= }; /* @@ -524,8 +530,8 @@ /* * util.c */ -extern time_t vms2unix_sec (u16 *vms_timestamp); -extern long vms2unix_nsec (u16 *vms_timestamp); +extern void vms2timespec (struct timespec *dest, vms_timestamp_t src); +extern void timespec2vms (vms_timestamp_t *dest, struct timespec *src); /* FIXME: hacks in util.c */ extern int get_hardsect_size (int xx); |