diff options
author | Steve French <sfrench@us.ibm.com> | 2006-10-06 17:47:09 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-10-06 17:47:09 -0400 |
commit | 268f3be177ce93791da38facc34126b5038cd851 (patch) | |
tree | 93603e3ac7209dd390125d8c71cfaee3ceff7547 /fs/cifs/netmisc.c | |
parent | 1a70d6529ad9f5978af846440f8a809784d6e813 (diff) |
[CIFS] readdir (ffirst) enablement of accurate timestamps from legacy servers
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/netmisc.c')
-rw-r--r-- | fs/cifs/netmisc.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index fa5124d9af19..3d86b31cf2e4 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -918,45 +918,42 @@ __le64 cnvrtDosCifsTm(__u16 date, __u16 time) | |||
918 | { | 918 | { |
919 | return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time))); | 919 | return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time))); |
920 | } | 920 | } |
921 | |||
921 | struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) | 922 | struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) |
922 | { | 923 | { |
923 | __u8 dt[2]; | ||
924 | __u8 tm[2]; | ||
925 | struct timespec ts; | 924 | struct timespec ts; |
926 | int sec,min, days, month, year; | 925 | int sec, min, days, month, year; |
927 | struct timespec removeme; /* BB removeme BB */ | 926 | SMB_TIME * st = (SMB_TIME *)&time; |
928 | /* SMB_TIME * st = (SMB_TIME *)&time;*/ | 927 | SMB_DATE * sd = (SMB_DATE *)&date; |
929 | 928 | ||
930 | cFYI(1,("date %d time %d",date, time)); | 929 | cFYI(1,("date %d time %d",date, time)); |
931 | 930 | ||
932 | dt[0] = date & 0xFF; | 931 | sec = 2 * st->TwoSeconds; |
933 | dt[1] = (date & 0xFF00) >> 8; | 932 | min = st->Minutes; |
934 | tm[0] = time & 0xFF; | 933 | if((sec > 59) || (min > 59)) |
935 | tm[1] = (time & 0xFF00) >> 8; | 934 | cERROR(1,("illegal time min %d sec %d", min, sec)); |
936 | |||
937 | sec = tm[0] & 0x1F; | ||
938 | sec = 2 * sec; | ||
939 | min = ((tm[0] >>5)&0xFF) + ((tm[1] & 0x7)<<3); | ||
940 | |||
941 | sec += (min * 60); | 935 | sec += (min * 60); |
942 | sec += 60 * 60 * ((tm[1] >> 3) &0xFF) /* hours */; | 936 | sec += 60 * 60 * st->Hours; |
943 | days = (dt[0] & 0x1F) - 1; | 937 | if(st->Hours > 24) |
944 | month = ((dt[0] >> 5) & 0xFF) + ((dt[1] & 0x1) <<3); | 938 | cERROR(1,("illegal hours %d",st->Hours)); |
945 | if(month > 12) | 939 | days = sd->Day; |
946 | cERROR(1,("illegal month %d in date", month)); | 940 | month = sd->Month; |
941 | if((days > 31) || (month > 12)) | ||
942 | cERROR(1,("illegal date, month %d day: %d", month, days)); | ||
947 | month -= 1; | 943 | month -= 1; |
948 | days += total_days_of_prev_months[month]; | 944 | days += total_days_of_prev_months[month]; |
949 | days += 3653; /* account for difference in days between 1980 and 1970 */ | 945 | days += 3653; /* account for difference in days between 1980 and 1970 */ |
950 | year = (dt[1]>>1) & 0xFF; | 946 | year = sd->Year; |
951 | days += year * 365; | 947 | days += year * 365; |
952 | days += (year/4); /* leap year */ | 948 | days += (year/4); /* leap year */ |
953 | /* adjust for leap year where we are still before leap day */ | 949 | /* adjust for leap year where we are still before leap day */ |
954 | days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); | 950 | days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); |
955 | sec += 24 * 60 * 60 * days; | 951 | sec += 24 * 60 * 60 * days; |
956 | 952 | ||
957 | removeme = CURRENT_TIME; /* BB removeme BB */ | ||
958 | ts.tv_sec = sec; | 953 | ts.tv_sec = sec; |
959 | 954 | ||
955 | /* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */ | ||
956 | |||
960 | ts.tv_nsec = 0; | 957 | ts.tv_nsec = 0; |
961 | return ts; | 958 | return ts; |
962 | } | 959 | } |