aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/netmisc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-10-13 11:09:29 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-13 11:09:29 -0400
commit12e36b2f41b6cbc67386fcb9c59c32a3e2033905 (patch)
treeec1794bae2f96eef6cc2afb2fa5c48e6fd346316 /fs/cifs/netmisc.c
parent1baaf0b424fe611a99cf3e2e59e84df0561d679a (diff)
parent1a4e15a04ec69cb3552f4120079f5472377df5f7 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: (27 commits) [CIFS] Missing flags2 for DFS [CIFS] Workaround incomplete byte length returned by some [CIFS] cifs Kconfig: don't select CONNECTOR [CIFS] Level 1 QPathInfo needed for proper OS2 support [CIFS] fix typo in previous patch [CIFS] Fix old DOS time conversion to handle timezone [CIFS] Do not need to adjust for Jan/Feb for leap day [CIFS] Fix leaps year calculation for years after 2100 [CIFS] readdir (ffirst) enablement of accurate timestamps from legacy servers [CIFS] Fix compiler warning with previous patch [CIFS] Fix typo [CIFS] Allow for 15 minute TZs (e.g. Nepal) and be more explicit about [CIFS] Fix readdir of large directories for backlevel servers [CIFS] Allow LANMAN21 support even in both POSIX non-POSIX path [CIFS] Make use of newer QFSInfo dependent on capability bit instead of [CIFS] Do not send newer QFSInfo to legacy servers which can not support it [CIFS] Fix typo in name of new cifs_show_stats [CIFS] Rename server time zone field [CIFS] Handle legacy servers which return undefined time zone [CIFS] CIFS support for /proc/<pid>/mountstats part 1 ... Manual conflict resolution in fs/cifs/connect.c
Diffstat (limited to 'fs/cifs/netmisc.c')
-rw-r--r--fs/cifs/netmisc.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index ce87550e918f..992e80edc720 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -909,3 +909,61 @@ cifs_UnixTimeToNT(struct timespec t)
909 /* Convert to 100ns intervals and then add the NTFS time offset. */ 909 /* Convert to 100ns intervals and then add the NTFS time offset. */
910 return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET; 910 return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
911} 911}
912
913static int total_days_of_prev_months[] =
914{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
915
916
917__le64 cnvrtDosCifsTm(__u16 date, __u16 time)
918{
919 return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time)));
920}
921
922struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
923{
924 struct timespec ts;
925 int sec, min, days, month, year;
926 SMB_TIME * st = (SMB_TIME *)&time;
927 SMB_DATE * sd = (SMB_DATE *)&date;
928
929 cFYI(1,("date %d time %d",date, time));
930
931 sec = 2 * st->TwoSeconds;
932 min = st->Minutes;
933 if((sec > 59) || (min > 59))
934 cERROR(1,("illegal time min %d sec %d", min, sec));
935 sec += (min * 60);
936 sec += 60 * 60 * st->Hours;
937 if(st->Hours > 24)
938 cERROR(1,("illegal hours %d",st->Hours));
939 days = sd->Day;
940 month = sd->Month;
941 if((days > 31) || (month > 12))
942 cERROR(1,("illegal date, month %d day: %d", month, days));
943 month -= 1;
944 days += total_days_of_prev_months[month];
945 days += 3652; /* account for difference in days between 1980 and 1970 */
946 year = sd->Year;
947 days += year * 365;
948 days += (year/4); /* leap year */
949 /* generalized leap year calculation is more complex, ie no leap year
950 for years/100 except for years/400, but since the maximum number for DOS
951 year is 2**7, the last year is 1980+127, which means we need only
952 consider 2 special case years, ie the years 2000 and 2100, and only
953 adjust for the lack of leap year for the year 2100, as 2000 was a
954 leap year (divisable by 400) */
955 if(year >= 120) /* the year 2100 */
956 days = days - 1; /* do not count leap year for the year 2100 */
957
958 /* adjust for leap year where we are still before leap day */
959 if(year != 120)
960 days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
961 sec += 24 * 60 * 60 * days;
962
963 ts.tv_sec = sec;
964
965 /* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */
966
967 ts.tv_nsec = 0;
968 return ts;
969}