]> err.no Git - linux-2.6/blobdiff - fs/cifs/netmisc.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6] / fs / cifs / netmisc.c
index 32562d19955209b267ee190aee47aaaa81709356..53e304d59544cbeddff71ea909904ad084106d42 100644 (file)
@@ -30,6 +30,9 @@
 #include <linux/fs.h>
 #include <asm/div64.h>
 #include <asm/byteorder.h>
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+#include <linux/inet.h>
+#endif
 #include "cifsfs.h"
 #include "cifspdu.h"
 #include "cifsglob.h"
@@ -129,11 +132,27 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
 /* Convert string containing dotted ip address to binary form */
 /* returns 0 if invalid address */
 
-/* BB add address family, change rc to status flag and return union or for ipv6 */
-/*  will need parent to call something like inet_pton to convert ipv6 address  BB */
 int
 cifs_inet_pton(int address_family, char *cp,void *dst)
 {
+#ifdef CONFIG_CIFS_EXPERIMENTAL
+       int ret = 0;
+
+       /* calculate length by finding first slash or NULL */
+       /* BB Should we convert '/' slash to '\' here since it seems already done
+          before this */
+       if( address_family == AF_INET ){
+               ret = in4_pton(cp, -1 /* len */, dst , '\\', NULL);     
+       } else if( address_family == AF_INET6 ){
+               ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
+       }
+#ifdef CONFIG_CIFS_DEBUG2
+       cFYI(1,("address conversion returned %d for %s", ret, cp));
+#endif
+       if (ret > 0)
+               ret = 1;
+       return ret;
+#else
        int value;
        int digit;
        int i;
@@ -192,6 +211,7 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
 
        *((__be32 *)dst) = *((__be32 *) bytes) | htonl(value);
        return 1; /* success */
+#endif /* EXPERIMENTAL */      
 }
 
 /*****************************************************************************
@@ -942,7 +962,7 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
                cERROR(1,("illegal date, month %d day: %d", month, days));
        month -= 1;
        days += total_days_of_prev_months[month];
-       days += 3653; /* account for difference in days between 1980 and 1970 */
+       days += 3652; /* account for difference in days between 1980 and 1970 */
        year = sd->Year;
        days += year * 365;
        days += (year/4); /* leap year */
@@ -956,7 +976,8 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
                days = days - 1;  /* do not count leap year for the year 2100 */
 
        /* adjust for leap year where we are still before leap day */
-       days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
+       if(year != 120)
+               days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
        sec += 24 * 60 * 60 * days; 
 
        ts.tv_sec = sec;