Changeset 818


Ignore:
Timestamp:
Sep 27, 2013, 1:57:24 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Client 2.1: timestamp work

Location:
trunk/client/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/src/help/readme_fr.txt

    r550 r818  
    251251
    252252Traduction fran‡aise : Guillaume Gay <guillaume.gay@bigfoot.com>
    253 Version : 2010-01-11
     253Version : 2012-01-21
  • trunk/client/src/ndpsmb.c

    r800 r818  
    4242void fsphUnixTimeToDosDate( time_t time, FDATE* fdate, FTIME *ftime)
    4343{
    44     struct tm* gmt = localtime( &time);
     44        struct tm* gmt = localtime( &time);
    4545#if 0 // as localtime() already does dst we don't need to add something
    46     if (gmt->tm_isdst>0) {
     46        if (gmt->tm_isdst>0) {
    4747        debug_printf( "daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    4848        time -= 3600;
    4949        gmt = localtime( &time);
    50     }
     50        }
    5151#endif
    52     fdate->day  = gmt->tm_mday;
    53     fdate->month  = gmt->tm_mon+1;
    54     fdate->year = gmt->tm_year + 1900 - 1980;
    55     ftime->twosecs = gmt->tm_sec/2;
    56     ftime->minutes = gmt->tm_min;
    57     ftime->hours = gmt->tm_hour;
     52        fdate->day  = gmt->tm_mday;
     53        fdate->month  = gmt->tm_mon+1;
     54        fdate->year = gmt->tm_year + 1900 - 1980;
     55        ftime->twosecs = gmt->tm_sec/2;
     56        ftime->minutes = gmt->tm_min;
     57        ftime->hours = gmt->tm_hour;
    5858}
    5959
    6060void fsphDosDateToUnixTime( FDATE fdate, FTIME ftime, ULONG* time)
    6161{
    62     struct tm gmtime = { 0 };
    63 
    64     debug_printf( "fsphDosDateToUnixTime time %02d:%02d\n", ftime.hours, ftime.minutes);
    65     gmtime.tm_mday = fdate.day;
    66     gmtime.tm_mon = fdate.month-1;
    67     gmtime.tm_year = fdate.year + 1980 - 1900;
    68     gmtime.tm_sec = ftime.twosecs*2;
    69     gmtime.tm_min = ftime.minutes;
    70     gmtime.tm_hour = ftime.hours;
    71     gmtime.tm_isdst = -1; // force libc to check dst saving
    72 
    73     *time = mktime( &gmtime);
    74     debug_printf( "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
     62        struct tm gmtime = { 0 };
     63
     64        debug_printf( "fsphDosDateToUnixTime time %02d:%02d:%02d\n", ftime.hours, ftime.minutes, ftime.twosecs*2);
     65        gmtime.tm_mday = fdate.day;
     66        gmtime.tm_mon = fdate.month-1;
     67        gmtime.tm_year = fdate.year + 1980 - 1900;
     68        gmtime.tm_sec = ftime.twosecs*2;
     69        gmtime.tm_min = ftime.minutes;
     70        gmtime.tm_hour = ftime.hours;
     71        gmtime.tm_isdst = -1; // force libc to check dst saving
     72
     73        *time = mktime( &gmtime);
     74        debug_printf( "fsphDosDateToUnixTime time1 %d %s", *time, ctime( (time_t*)time));
    7575#if 0 // as mktime() already does dst we don't need to add something
    76     struct tm* gmt;
    77     gmt = localtime( (time_t*) time);
    78     if (gmt->tm_isdst>0) {
     76        struct tm* gmt;
     77        gmt = localtime( (time_t*) time);
     78        if (gmt->tm_isdst>0) {
    7979        debug_printf( "fsphDosDateToUnixTime daylight saving in effect %d, timezone %d\n",gmt->tm_isdst, timezone);
    8080        *time += 3600;
    81     }
     81        }
     82        debug_printf( "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
    8283#endif
    83     debug_printf( "fsphDosDateToUnixTime time2 %d %s", *time, ctime( (time_t*)time));
    8484}
    8585       
     
    104104        {ND_PROP_STRING, 0, "USER", "guest"},
    105105        {ND_PROP_STRING, 0, "PASSWORD", ""},
    106         {ND_PROP_STRING, 0, "SPASSWORD",  ""},
     106        {ND_PROP_STRING, 0, "SPASSWORD",  ""},
    107107        {ND_PROP_STRING, 0, "MASTER", "WORKGROUP"},
    108108        {ND_PROP_ULONG, 0, "MASTERTYPE", "1"},
    109         {ND_PROP_ULONG, 0, "CTO", "10"},
    110         {ND_PROP_ULONG, 0, "CLD", "32"},
     109        {ND_PROP_ULONG, 0, "CTO", "10"},
     110        {ND_PROP_ULONG, 0, "CLD", "32"},
    111111        {ND_PROP_ULONG, 0, "EASUPPORT", "1"},
    112112        {ND_PROP_STRING, 0, NULL, NULL}
     
    126126/* A mutex to serialize plugin calls because libsmb may not be thread safe. */
    127127static NDMUTEX mutex;
    128        
     128
    129129static int lockInit (void)
    130130{
    131     return ph->fsphCreateMutex (&mutex);
    132 }
    133        
     131        return ph->fsphCreateMutex (&mutex);
     132}
     133
    134134static void lockClose (void)
    135135{
    136     ph->fsphCloseMutex (mutex);
    137 }
    138        
     136        ph->fsphCloseMutex (mutex);
     137}
     138
    139139static int lockRequest (void)
    140140{
    141     return ph->fsphRequestMutex (mutex, SEM_INDEFINITE_WAIT);
     141        return ph->fsphRequestMutex (mutex, SEM_INDEFINITE_WAIT);
    142142}
    143143
    144144static void lockRelease (void)
    145145{
    146     ph->fsphReleaseMutex (mutex);
     146        ph->fsphReleaseMutex (mutex);
    147147}
    148148
    149149#if LIBSMB_THREAD_SAFE==0
    150150
    151 #define ENTER() do {            \
    152     int rcLock = lockRequest(); \
    153     if (rcLock != NO_ERROR)     \
    154         return rcLock;          \
     151#define ENTER() do {                    \
     152        int rcLock = lockRequest();     \
     153        if (rcLock != NO_ERROR)         \
     154                return rcLock;          \
    155155} while (0)
    156156
    157 #define LEAVE() do { \
    158     lockRelease();    \
     157#define LEAVE() do {    \
     158        lockRelease();  \
    159159} while (0)
    160160
     
    181181                ifL = 1;
    182182        }
    183         lockInit();
    184         debugInit();
     183        lockInit();
     184        debugInit();
    185185        debuglocal(9,"Working with %s bit fileio NDFS\n", ifL ? "64" : "32");
    186186        return NO_ERROR;
     
    190190int APIENTRY NdpPluginFree (void)
    191191{
    192         debugDelete();
    193         lockClose();
     192        debugDelete();
     193        lockClose();
    194194        return NO_ERROR;
    195195}
     
    218218        stat->attrFile = (finfo->attr & 0x37);
    219219
    220         fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
    221         fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
    222         fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
     220        fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
     221        fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
     222        fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
    223223}
    224224
     
    248248        stat.attrFile = (finfo->attr & 0x37);
    249249
    250         fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
    251         fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
    252         fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
     250        fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
     251        fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
     252        fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
    253253        debug_printf( "fname %s\n", finfo->fname);
    254254        debug_printf( "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
     
    261261static unsigned char fromhex (char c)
    262262{
    263     if ('0' <= c && c <= '9')
    264     {
    265          return c - '0';
    266     }
    267    
    268     if ('A' <= c && c <= 'F')
    269     {
    270          return c - 'A' + 0xA;
    271     }
    272    
    273     if ('a' <= c && c <= 'f')
    274     {
    275          return c - 'a' + 0xA;
    276     }
    277    
    278     return 0;
     263        if ('0' <= c && c <= '9')
     264        {
     265                return c - '0';
     266        }
     267
     268        if ('A' <= c && c <= 'F')
     269        {
     270                return c - 'A' + 0xA;
     271        }
     272
     273        if ('a' <= c && c <= 'f')
     274        {
     275                return c - 'a' + 0xA;
     276        }
     277
     278        return 0;
    279279}
    280280
    281281static char tohex (unsigned char b)
    282282{
    283     b &= 0xF;
    284    
    285     if (b <= 9)
    286     {
    287         return b + '0';
    288     }
    289    
    290     return 'A' + (b - 0xA);
     283        b &= 0xF;
     284
     285        if (b <= 9)
     286        {
     287                return b + '0';
     288        }
     289
     290        return 'A' + (b - 0xA);
    291291}
    292292
    293293static void decryptPassword (const char *pszCrypt, char *pszPlain)
    294294{
    295     /* A simple "decryption", character from the hex value. */
    296     const char *s = pszCrypt;
    297     char *d = pszPlain;
    298    
    299     while (*s)
    300     {
    301         *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++));
    302     }
    303    
    304     *d++ = 0;
     295        /* A simple "decryption", character from the hex value. */
     296        const char *s = pszCrypt;
     297        char *d = pszPlain;
     298
     299        while (*s)
     300        {
     301                *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++));
     302        }
     303
     304        *d++ = 0;
    305305}
    306306
    307307static void encryptPassword (const char *pszPlain, char *pszCrypt)
    308308{
    309     /* A simple "encryption" encode each character as hex value. */
    310     const char *s = pszPlain;
    311     char *d = pszCrypt;
    312    
    313     while (*s)
    314     {
    315         *d++ = tohex ((*s) >> 4);
    316         *d++ = tohex (*s);
    317         s++;
    318     }
    319    
    320     *d++ = 0;
     309        /* A simple "encryption" encode each character as hex value. */
     310        const char *s = pszPlain;
     311        char *d = pszCrypt;
     312
     313        while (*s)
     314        {
     315                *d++ = tohex ((*s) >> 4);
     316                *d++ = tohex (*s);
     317                s++;
     318        }
     319
     320        *d++ = 0;
    321321}
    322322
     
    338338        pRes->krb5support = 0;
    339339#endif
    340         pRes->pdc = NULL;
     340        pRes->pdc = NULL;
    341341
    342342        t = 0, q = NULL;
     
    380380
    381381        t = 0, q = NULL;
    382         rc = ph->fsphQueryStringProperty (properties, "SPASSWORD", &q, &t);
    383         if (   rc == NO_ERROR
    384             && *q != '\0'
    385             && defaultPassword)
    386         {
    387             char p[1024];
    388             p[0] = 0;
    389        
    390             decryptPassword (q, p);
    391        
    392             if (*p)
    393             {
    394                 strncpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1);
    395        
    396                 /* clear the plain password */
    397                 ph->fsphSetProperty (properties, "PASSWORD", "");
    398             }
    399         }
    400         else
    401         {
    402             char c[1024];
    403             encryptPassword (pRes->srv.password, c);
    404        
    405             ph->fsphSetProperty (properties, "SPASSWORD", c);
    406        
    407             // clear the plain password
    408             ph->fsphSetProperty (properties, "PASSWORD", "");
    409         }
     382        rc = ph->fsphQueryStringProperty (properties, "SPASSWORD", &q, &t);
     383        if (   rc == NO_ERROR && *q != '\0' && defaultPassword)
     384        {
     385                char p[1024];
     386                p[0] = 0;
     387
     388                decryptPassword (q, p);
     389
     390                if (*p)
     391                {
     392                        strncpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1);
     393
     394                        /* clear the plain password */
     395                        ph->fsphSetProperty (properties, "PASSWORD", "");
     396                }
     397        }
     398        else
     399        {
     400                char c[1024];
     401                encryptPassword (pRes->srv.password, c);
     402
     403                ph->fsphSetProperty (properties, "SPASSWORD", c);
     404
     405                // clear the plain password
     406                ph->fsphSetProperty (properties, "PASSWORD", "");
     407        }
    410408
    411409        t = 0, q = NULL;
     
    473471
    474472        /*
    475         * Create a directory cache with expiration time and cache listings
    476         * the above values come from the gui. default: timeout 10; listings: 32
    477         */
     473        * Create a directory cache with expiration time and cache listings
     474        * the above values come from the gui. default: timeout 10; listings: 32
     475        */
    478476        dircache_create(&pRes->pdc, pRes->cachetimeout, pRes->cachedepth);
    479477
     
    580578                if (newlevel)
    581579                {
    582                         // reconnect to server here, first test new connection
     580                        // reconnect to server here, first test new connection
    583581                        cli_state* tmp_cli = NULL;
    584582                        rc = smbwrp_connect( &tmpRes, &tmp_cli);
     
    615613        rc = smbwrp_connect( pRes, &cli);
    616614/* changed to real error codes SCS
    617     if (rc)
    618         rc = (rc == 7 ? ERROR_BAD_DEV_TYPE : ERROR_ACCESS_DENIED); */
     615        if (rc)
     616                rc = (rc == 7 ? ERROR_BAD_DEV_TYPE : ERROR_ACCESS_DENIED); */
    619617        switch (rc) {
    620618        case 0:
     
    682680                // nd/ndpm do not use main thread
    683681                if (!rc && _gettid()!=1)
    684                     rc = checkMountResource( pRes);
     682                        rc = checkMountResource( pRes);
    685683                if (!rc)
    686684                {
     
    812810        if (rc)
    813811        {
    814             debuglocal(9,"NdpCreateConnection failed rc=%d\n", rc);     
    815             pfsa->cSectorUnit = 1;
    816             pfsa->cUnit = 123456;
    817             pfsa->cUnitAvail = 123456;
    818             pfsa->cbSector = 2048;
    819             rc = (rc == 7 ? ERROR_BAD_DEV_TYPE : ERROR_ACCESS_DENIED);
    820             LEAVE();
    821             return rc;
     812                debuglocal(9,"NdpCreateConnection failed rc=%d\n", rc);
     813                pfsa->cSectorUnit = 1;
     814                pfsa->cUnit = 123456;
     815                pfsa->cUnitAvail = 123456;
     816                pfsa->cbSector = 2048;
     817                rc = (rc == 7 ? ERROR_BAD_DEV_TYPE : ERROR_ACCESS_DENIED);
     818                LEAVE();
     819                return rc;
    822820        }
    823821
     
    918916/*
    919917 * NdpQueryPathInfo is the most important  function :) netdrive always calls
    920  * the function before every operation to find out the path status: does it exist, is it a file, does a
    921  * parent directory exist, etc.
     918 * the function before every operation to find out the path status:
     919 * does it exist, is it a file, does a parent directory exist, etc.
    922920 * Plugin must return one of the following error codes:
    923  * NO_ERROR - path exists and the path information have been successfully retrieved.
     921 * NO_ERROR - path exists and the path information have been successfully
     922 *      retrieved.
    924923 * ERROR_FILE_NOT_FOUND - all but the last component of the path exist and the
    925  *    path without the last component is a directory. dir1_ok\dir2_ok\does_not_exist.
    926  *    the wildcard can not exist, so the plugin returns FILE_NOT_FOUND, if the parent
    927  *    directory exist.
     924 *      path without the last component is a directory. dir1_ok\dir2_ok\does_not_exist.
     925 *      the wildcard can not exist, so the plugin returns FILE_NOT_FOUND, if the parent
     926 *      directory exist.
    928927 * ERROR_PATH_NOT_FOUND - any of not last path components does not exist, or all
    929  *    but the last component exist and is a file: \dir_ok\dir2_ok\file_ok\non_existing.
     928 *      but the last component exist and is a file: \dir_ok\dir2_ok\file_ok\non_existing.
    930929 * ERROR_REM_NOT_LIST - resource is temporarily unavailable for some reasons.
    931930 * Any other error codes means an internal plugin error, not related to the status
     
    997996                                if (rc == ERROR_REM_NOT_LIST)
    998997                                {
    999                                     // free current cli resources
    1000                                     smbwrp_disconnect( pRes, pConn->cli);
    1001                                     // reconnect
    1002                                     rcCon = smbwrp_connect( pRes, &pConn->cli);
    1003                                     if (rcCon != NO_ERROR)
    1004                                     debuglocal(9,"NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
    1005 
    1006                                     // try file list again if reconnecting worked
    1007                                     if (rcCon == NO_ERROR)
    1008                                     rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     998                                        // free current cli resources
     999                                        smbwrp_disconnect( pRes, pConn->cli);
     1000                                        // reconnect
     1001                                        rcCon = smbwrp_connect( pRes, &pConn->cli);
     1002                                        if (rcCon != NO_ERROR)
     1003                                                debuglocal(9,"NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
     1004
     1005                                        // try file list again if reconnecting worked
     1006                                        if (rcCon == NO_ERROR)
     1007                                                rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    10091008                                }
    10101009                                debuglocal(9,"NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
     
    10371036                                        *p = 0;
    10381037                                        rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    1039                                         debuglocal(9,"NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
     1038                                        debuglocal(9,"NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
    10401039                                        if (rc == NO_ERROR)
    10411040                                        {       
    1042                                             rc = (finfo.attr & FILE_DIRECTORY) !=0 ?
    1043                                                 ERROR_FILE_NOT_FOUND:
    1044                                                 ERROR_PATH_NOT_FOUND;
     1041                                                rc = (finfo.attr & FILE_DIRECTORY) !=0 ?
     1042                                                ERROR_FILE_NOT_FOUND:ERROR_PATH_NOT_FOUND;
    10451043                                        }
    1046                                         else if (rc != ERROR_REM_NOT_LIST)
    1047                                         {
    1048                                               rc = ERROR_PATH_NOT_FOUND;
     1044                                        else if (rc != ERROR_REM_NOT_LIST)
     1045                                        {
     1046                                                rc = ERROR_PATH_NOT_FOUND;
    10491047                                        }
    10501048                                }
     
    11331131                }
    11341132                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
    1135                            state.dir, state.dir_mask, state.mask, state.fullpath);
     1133                        state.dir, state.dir_mask, state.mask, state.fullpath);
    11361134                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11371135                // we need to handle reconnection also here, because NdpQueryPathInfo
     
    11391137                if (rc == ERROR_REM_NOT_LIST)
    11401138                {
    1141                     // free current cli resources
    1142                     smbwrp_disconnect( pRes, pConn->cli);
    1143                     // reconnect
    1144                     smbwrp_connect( pRes, &pConn->cli);
    1145                     // try file list again next loop
    1146                     rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    1147                     debuglocal(9,"NdpFindStart remote connection lost, rc = %d\n", rc);
     1139                        // free current cli resources
     1140                        smbwrp_disconnect( pRes, pConn->cli);
     1141                        // reconnect
     1142                        smbwrp_connect( pRes, &pConn->cli);
     1143                        // try file list again next loop
     1144                        rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
     1145                        debuglocal(9,"NdpFindStart remote connection lost, rc = %d\n", rc);
    11481146                }
    11491147
     
    11671165int APIENTRY NdpDiscardResourceData (HRESOURCE resource, NDDATABUF *pdatabuf)
    11681166{
    1169     // The plugin do not have to deallocate anything
    1170     // because resource data did not contain any pointers
    1171     // to plugins data.
    1172     // Data stored by fsphSetResourceData will be
    1173     // deallocated by NetDrive.
     1167        // The plugin do not have to deallocate anything
     1168        // because resource data did not contain any pointers
     1169        // to plugins data.
     1170        // Data stored by fsphSetResourceData will be
     1171        // deallocated by NetDrive.
    11741172
    11751173        debuglocal(9,"NdpDicardresourceData %d\n", 0);
     
    11901188        debug_printf("NdpSetPathInfo in [%p]\n", pConn);
    11911189
    1192         // delete the dir cache
     1190        // delete the dir cache
    11931191        dircache_invalidate(szPathName, pRes->pdc, 1);
    11941192
     
    13061304        debuglocal(9,"NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    13071305
    1308         char *pchBuffer = (char *)malloc(cbBuffer);
    1309         if (!pchBuffer)
    1310         {
    1311                 LEAVE();
    1312                 return ERROR_NOT_ENOUGH_MEMORY;
    1313         }
     1306        char *pchBuffer = (char *)malloc(cbBuffer);
     1307        if (!pchBuffer)
     1308        {
     1309                LEAVE();
     1310                return ERROR_NOT_ENOUGH_MEMORY;
     1311        }
    13141312
    13151313        do {
     
    13421340                }
    13431341        } while (0);
    1344         free(pchBuffer);
     1342        free(pchBuffer);
    13451343        debuglocal(9,"NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
    13461344        LEAVE();
     
    14231421                return ERROR_EAS_NOT_SUPPORTED;
    14241422        }
    1425        
    1426         debuglocal(9, "remove me NdpEASize before fsphGetFileInfoData\n");
     1423
    14271424        rc = ph->fsphGetFileInfoData(pfi, &fdata, 0);
    14281425        if (rc || !fdata.ulSize || !fdata.pData)
     
    14341431        ENTER();
    14351432
    1436         debuglocal(9, "remove me NdpEASize before finfo =\n");
    14371433        finfo = (smbwrp_fileinfo *)fdata.pData;
    1438         debuglocal(9, "remove me NdpEASize after finfo=\n");
    14391434        easize = finfo->easize;
    14401435        finfo->easize = -1;
     
    14501445        debuglocal(9,"NdpEASize in [%p] <%s> \n", pConn, path);
    14511446
    1452         char *pchBuffer = (char *)malloc(cbBuffer);
    1453         if (!pchBuffer)
    1454         {
    1455                 LEAVE();
    1456                 return ERROR_NOT_ENOUGH_MEMORY;
    1457         }
     1447        char *pchBuffer = (char *)malloc(cbBuffer);
     1448        if (!pchBuffer)
     1449        {
     1450                LEAVE();
     1451                return ERROR_NOT_ENOUGH_MEMORY;
     1452        }
    14581453
    14591454        do {
     
    14821477                *pulEASize = pfealist->cbList;
    14831478        } while (0);
    1484         free(pchBuffer);
     1479        free(pchBuffer);
    14851480        debuglocal(9,"NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
    14861481        LEAVE();
     
    17921787int APIENTRY NdpIOCTL (int type, HRESOURCE resource, char *path, int function, void *in, ULONG insize, PULONG poutlen)
    17931788{
    1794     if (function == ND_PL_INIT_THREAD)
    1795        {
    1796           smbwrp_initthread();
    1797           debuglocal(9, "NdpIOCTL init thread\n");
    1798           return NO_ERROR;
    1799        }
    1800 
    1801     debuglocal(9,"NdpIOCTL <%s> %d\n", path, function);
    1802 
    1803     if (in && insize > 4096)
    1804     {
    1805         char out[4096];
    1806         sprintf (out, "SAMBA IOCTL function = %d, parms [%s] insize = %d, *poutlen = %d", function, in, insize, *poutlen);
    1807         *poutlen = strlen(out);
    1808         strcpy (in, out);
    1809         return NO_ERROR;
    1810     }
    1811 
    1812     return ERROR_NOT_SUPPORTED;
     1789        if (function == ND_PL_INIT_THREAD)
     1790        {
     1791                smbwrp_initthread();
     1792                debuglocal(9, "NdpIOCTL init thread\n");
     1793                return NO_ERROR;
     1794        }
     1795
     1796        debuglocal(9,"NdpIOCTL <%s> %d\n", path, function);
     1797
     1798        if (in && insize > 4096)
     1799        {
     1800                char out[4096];
     1801                sprintf (out, "SAMBA IOCTL function = %d, parms [%s] insize = %d, *poutlen = %d", function, in, insize, *poutlen);
     1802                *poutlen = strlen(out);
     1803                strcpy (in, out);
     1804                return NO_ERROR;
     1805        }
     1806
     1807        return ERROR_NOT_SUPPORTED;
    18131808}
    18141809
     
    18631858        debuglocal(9,"NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    18641859
    1865         char *pchBuffer = (char *)malloc(cbBuffer);
    1866         if (!pchBuffer)
    1867                 return ERROR_NOT_ENOUGH_MEMORY;
     1860        char *pchBuffer = (char *)malloc(cbBuffer);
     1861        if (!pchBuffer)
     1862                return ERROR_NOT_ENOUGH_MEMORY;
    18681863
    18691864        ENTER();
     
    19031898                }
    19041899        } while (0);
    1905         free(pchBuffer);
     1900        free(pchBuffer);
    19061901        debuglocal(9,"NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
    19071902        LEAVE();
     
    19781973        debuglocal(9,"NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    19791974
    1980         char *pchBuffer = (char *)malloc(cbBuffer);
    1981         if (!pchBuffer)
    1982                 return ERROR_NOT_ENOUGH_MEMORY;
     1975        char *pchBuffer = (char *)malloc(cbBuffer);
     1976        if (!pchBuffer)
     1977                return ERROR_NOT_ENOUGH_MEMORY;
    19831978
    19841979        ENTER();
     
    20142009                *pulEASize = pFEAList->cbList;
    20152010        } while (0);
    2016         free(pchBuffer);
     2011        free(pchBuffer);
    20172012        debuglocal(9,"NdpFileEASize %d %d\n", *pulEASize, rc);
    20182013        LEAVE();
     
    20312026        debug_printf("NdpFileSetInfo in [%p]\n", pConn);
    20322027
    2033         // delete the dir cache
     2028        // delete the dir cache
    20342029        dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
    20352030
     
    20442039                pConn->file.openattr = attrFile;
    20452040                fsphDosDateToUnixTime(pfi->stat.fdateLastWrite, pfi->stat.ftimeLastWrite, &(pConn->file.mtime));
     2041                fsphDosDateToUnixTime(pfi->stat.fdateCreation, pfi->stat.ftimeCreation, &(pConn->file.ctime));
     2042                pConn->file.updatetime = 2;
    20462043                debug_printf("NdpFileSetInfo mtime %d\n", pConn->file.mtime);
    20472044        } while (0);
     
    21802177                while (ulReadCompleted < ulRead)
    21812178                {
    2182                         ULONG ulActual;
     2179                        ULONG ulActual;
    21832180                        ULONG ulToRead = ulRead - ulReadCompleted;
    21842181                        debuglocal(9,"NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     
    22272224        debuglocal(9,"NdpFileWrite in [%p]\n", pConn);
    22282225
    2229         /* delete the dir cache
    2230         this was moved from NdpFileClose() becasue if there are a lot files in the tree all are reread
    2231         the problem when moved to here is, that last accessed time is not refreshed
    2232         if this is needed, a new function needs to be done to update only one file in the cache */
     2226        /* delete the dir cache
     2227        this was moved from NdpFileClose() becasue if there are a lot files in the tree all are reread
     2228        the problem when moved to here is, that last accessed time is not refreshed
     2229        if this is needed, a new function needs to be done to update only one file in the cache */
    22332230        dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
    22342231
  • trunk/client/src/nversion.tpl

    r756 r818  
    66#define NDPSMB_BUILD    _BUILD_
    77#define NDPSMB_INSTALL  _WPIVERSION_
    8 #define VERSION         "_VERSION_"
     8#define VERSION         "_VERSION_"
    99#define BUILD           "_BUILD_"
    1010#define OS              eCS (OS/2)
  • trunk/client/src/smbwrp.c

    r808 r818  
    3939static int
    4040net_share_enum_rpc(struct cli_state *cli,
    41                    void (*fn)(const char *name,
    42                               uint32 type,
    43                               const char *comment,
    44                               void *state),
    45                    void *state)
     41                void (*fn)(const char *name,
     42                uint32 type,
     43                const char *comment,
     44                void *state),
     45                void *state)
    4646{
    4747        int i;
     
    7878        info_ctr.ctr.ctr1 = &ctr1;
    7979        status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx,
    80                                               pipe_hnd->desthost,
    81                                               &info_ctr,
    82                                               0xffffffff,
    83                                               &total_entries,
    84                                               &resume_handle,
    85                                               &werr);
     80                                                pipe_hnd->desthost,
     81                                                &info_ctr,
     82                                                0xffffffff,
     83                                                &total_entries,
     84                                                &resume_handle,
     85                                                &werr);
    8686
    8787        /* Was it successful? */
     
    128128        char slogfilename[] = "log.smbc";
    129129        char *env = getenv("LOGFILES");
    130                 if (env != NULL)
    131                 {
    132                    strncpy(slogfile, env, sizeof(slogfile) -1);
    133                    strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1);
    134                    strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1);
    135                 }
    136                 else
    137                 {
    138                    strncpy(slogfile, slogfilename, sizeof(slogfile) -1);
    139                 }
    140 
    141                 // init samba for debug messages
    142                 setup_logging(slogfile, false);
    143                 lp_set_logfile(slogfile);
    144                 debug_parse_levels("10");
     130        if (env != NULL)
     131        {
     132                strncpy(slogfile, env, sizeof(slogfile) -1);
     133                strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1);
     134                strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1);
     135        }
     136        else
     137        {
     138                strncpy(slogfile, slogfilename, sizeof(slogfile) -1);
     139        }
     140
     141        // init samba for debug messages
     142        setup_logging(slogfile, false);
     143        lp_set_logfile(slogfile);
     144        debug_parse_levels("10");
    145145
    146146}
     
    201201{
    202202        /*
    203          * Block SIGPIPE (from lib/util_sock.c: write())
    204          * It is not needed and should not stop execution
    205          */
     203        Block SIGPIPE (from lib/util_sock.c: write())
     204        It is not needed and should not stop execution
     205        */
    206206        BlockSignals(True, SIGPIPE);
    207207}
     
    316316        char *rparam=NULL, *rdata=NULL;
    317317        char *p;
    318        
     318
    319319        param = SMB_MALLOC_ARRAY(char, 6+nlen+2);
    320320        if (!param) {
     
    331331
    332332        if (!cli_send_trans(cli, SMBtrans2,
    333                             NULL,                        /* name */
    334                             -1, 0,                      /* fid, flags */
    335                             &setup, 1, 0,                /* setup, length, max */
    336                             param, param_len, 10,        /* param, length, max */
    337                             NULL, data_len, cli->max_xmit /* data, length, max */
    338                            )) {
     333                        NULL,                           /* name */
     334                        -1, 0,                          /* fid, flags */
     335                        &setup, 1, 0,                   /* setup, length, max */
     336                        param, param_len, 10,           /* param, length, max */
     337                        NULL, data_len, cli->max_xmit   /* data, length, max */
     338                        )) {
    339339                return False;
    340340        }
     
    342342        SAFE_FREE(param);
    343343        if (!cli_receive_trans(cli, SMBtrans2,
    344                                &rparam, &param_len,
    345                                &rdata, &data_len)) {
     344                        &rparam, &param_len,
     345                        &rdata, &data_len)) {
    346346                return False;
    347347        }
     
    402402
    403403        if (!cli_send_trans(cli, SMBtrans2,
    404                             NULL,                          /* name */
    405                             -1, 0,                        /* fid, flags */
    406                             &setup, 1, 0,                  /* setup, length, max */
    407                             param, param_len, 2,            /* param, length, max */
    408                             NULL, data_len, cli->max_xmit   /* data, length, max */
    409                            )) {
     404                        NULL,                           /* name */
     405                        -1, 0,                          /* fid, flags */
     406                        &setup, 1, 0,                   /* setup, length, max */
     407                        param, param_len, 2,            /* param, length, max */
     408                        NULL, data_len, cli->max_xmit   /* data, length, max */
     409                        )) {
    410410                return False;
    411411        }
    412412
    413413        if (!cli_receive_trans(cli, SMBtrans2,
    414                                &rparam, &param_len,
    415                                &rdata, &data_len)) {
     414                        &rparam, &param_len,
     415                        &rdata, &data_len)) {
    416416                return False;
    417417        }
     
    635635        }
    636636        file->fd = fd;
    637         file->newmtime = 0;
     637        file->updatetime = 0;
    638638        file->offset = 0;
    639639        return 0;
     
    686686        }
    687687
    688         file->newmtime = 1;
     688        file->updatetime = 1;
    689689        file->offset += ret;
    690690        *result = ret;
     
    703703        }
    704704
     705        debuglocal(4,"smpwrp_close updatetime: %d\n", file->updatetime);
     706
     707        if (file->updatetime == 1)
     708        {
     709                file->mtime = time(NULL);
     710                debuglocal(4,"cli_close new mtime %lu\n", file->mtime);
     711        }
    705712       
    706713        if (!NT_STATUS_IS_OK(cli_close(cli, file->fd)))
    707714        {
    708                 return os2cli_errno(cli);
    709         }
    710         if (file->newmtime)
    711         {
    712                 file->newmtime = 0;
    713                 file->mtime = time(NULL);
    714                 debuglocal(4,"cli_close new mtime %lu\n", file->mtime);
    715         }
     715                rc = os2cli_errno(cli);
     716        }
     717
     718        if (!rc && (file->openattr || file->mtime || file->ctime))
     719        {
     720                debuglocal(4,"Set pathinfo on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->ctime);
     721                if (!NT_STATUS_IS_OK(cli_setpathinfo(cli, file->fname, file->ctime, 0, file->mtime, 0, file->openattr)))
     722                {
     723                        debuglocal(4,"Set pathinfo on close failed %d\n", os2cli_errno(cli));
     724                        //rc = os2cli_errno(cli);
     725                }
     726        }
     727
     728        file->openattr = 0;
     729        file->mtime = 0;
     730        file->ctime = 0;
     731        file->updatetime = 0;
    716732        file->fd = -1;
    717733        file->offset = 0;
    718         if (file->openattr || file->mtime)
    719         {
    720                 debuglocal(4,"Set attr on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->mtime);
    721                 if (!NT_STATUS_IS_OK(cli_setatr(cli, file->fname, file->openattr, file->mtime)))
    722                 {
    723                         debuglocal(4,"Set attr on close failed %d\n", os2cli_errno(cli));
    724                         //rc = os2cli_errno(cli);
    725                 }
    726                
    727                 file->openattr = 0;
    728                 file->mtime = 0;
    729         }
    730734        *file->fname = 0;
    731735        return rc;
  • trunk/client/src/smbwrp.h

    r808 r818  
    9191        int denymode;
    9292        unsigned long mtime;
    93         int newmtime;
     93        unsigned long ctime;
     94        int updatetime;
     95        // 0 = time is not updated upon file close
     96        // 1 = modified time is updated to current time
     97        // 2 = create and modified time are updated according local file
    9498        char fullname[261];
    9599        char fname[261];
Note: See TracChangeset for help on using the changeset viewer.