Changeset 1326


Ignore:
Timestamp:
Mar 22, 2004, 1:07:03 AM (21 years ago)
Author:
bird
Message:

#991: Rewrite input paths.
#992: Logging.

Location:
trunk/src/emx/src/lib/sys
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/__chdir.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1325 r1326  
    1 /* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
     2                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
    23
    34#include "libc-alias.h"
    45#define INCL_FSMACROS
    56#include <os2emx.h>
     7#include <stdlib.h>
     8#include <errno.h>
    69#include <emx/syscalls.h>
    710#include "syscalls.h"
     11#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     12#include <InnoTekLIBC/logstrict.h>
     13#include <InnoTekLIBC/pathrewrite.h>
    814
    915
    10 int __chdir (const char *name)
     16int __chdir (const char *pszPath)
    1117{
    12   ULONG rc;
    13   FS_VAR();
     18    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
     19    ULONG   rc;
     20    int     cch;
     21    FS_VAR();
    1422
    15   FS_SAVE_LOAD();
    16   rc = DosSetCurrentDir (name);
    17   FS_RESTORE();
    18   if (rc != 0)
     23    /*
     24     * Rewrite the specified file path.
     25     */
     26    cch = __libc_PathRewrite(pszPath, NULL, 0);
     27    if (cch > 0)
    1928    {
    20       _sys_set_errno (rc);
    21       return -1;
     29        char *pszRewritten = alloca(cch);
     30        if (!pszRewritten)
     31        {
     32            errno = ENOMEM;
     33            LIBCLOG_RETURN_INT(-1);
     34        }
     35        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     36        if (cch > 0)
     37            pszPath = pszRewritten;
     38        /* else happens when someone changes the rules between the two calls. */
     39        else if (cch < 0)
     40        {
     41            errno = EAGAIN;             /* non-standard, I'm sure. */
     42            LIBCLOG_RETURN_INT(-1);
     43        }
    2244    }
    23   return 0;
     45
     46    /*
     47     * Change the current directory.
     48     */
     49    FS_SAVE_LOAD();
     50    rc = DosSetCurrentDir((PCSZ)pszPath);
     51    FS_RESTORE();
     52    if (rc != 0)
     53    {
     54        _sys_set_errno(rc);
     55        LIBCLOG_RETURN_INT(-1);
     56
     57    }
     58    LIBCLOG_RETURN_INT(0);
    2459}
  • trunk/src/emx/src/lib/sys/__chmod.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1325 r1326  
    1 /* sys/chmod.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* sys/chmod.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
     2                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
    23
     4/*******************************************************************************
     5*   Header Files                                                               *
     6*******************************************************************************/
    37#include "libc-alias.h"
    48#include <string.h>
    59#include <errno.h>
     10#include <stdlib.h>
    611#define INCL_FSMACROS
    712#include <os2emx.h>
    813#include <emx/syscalls.h>
    914#include "syscalls.h"
     15#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     16#include <InnoTekLIBC/logstrict.h>
     17#include <InnoTekLIBC/pathrewrite.h>
    1018
    11 int __chmod (const char *name, int flag, int attr)
     19
     20int __chmod(const char *pszPath, int flag, int attr)
    1221{
    13   ULONG rc;
    14   FILESTATUS3 info;
    15   FS_VAR();
     22    LIBCLOG_ENTER("pszPath=%s flag=%#x attr=%#x\n", pszPath, flag, attr);
     23    ULONG       rc;
     24    int         cch;
     25    FILESTATUS3 info;
     26    FS_VAR();
    1627
    17   if (flag < 0 || flag > 1)
     28    /*
     29     * Rewrite the specified file path.
     30     */
     31    cch = __libc_PathRewrite(pszPath, NULL, 0);
     32    if (cch > 0)
    1833    {
    19       errno = EINVAL;
    20       return -1;
     34        char *pszRewritten = alloca(cch);
     35        if (!pszRewritten)
     36        {
     37            errno = ENOMEM;
     38            LIBCLOG_RETURN_INT(-1);
     39        }
     40        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     41        if (cch > 0)
     42            pszPath = pszRewritten;
     43        /* else happens when someone changes the rules between the two calls. */
     44        else if (cch < 0)
     45        {
     46            errno = EAGAIN;             /* non-standard, I'm sure. */
     47            LIBCLOG_RETURN_INT(-1);
     48        }
    2149    }
    22   if ((name[0] == '/' || name[0] == '\\') && strlen (name) >= 6 &&
    23       memicmp (name+1, "pipe", 4) == 0 && (name[5] == '/' || name[5] == '\\'))
     50
     51    /*
     52     * Validate input.
     53     */
     54    if (flag < 0 || flag > 1)
    2455    {
    25       errno = ENOENT;
    26       return -1;
     56        errno = EINVAL;
     57        LIBCLOG_RETURN_INT(-1);
    2758    }
    28   FS_SAVE_LOAD();
    29   rc = DosQueryPathInfo (name, FIL_STANDARD, &info, sizeof (info));
    30   if (rc != 0)
     59    if (    (pszPath[0] == '/' || pszPath[0] == '\\')
     60        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
     61        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
     62        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
     63        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
     64        &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
    3165    {
    32       FS_RESTORE();
    33       _sys_set_errno (rc);
    34       return -1;
     66        errno = ENOENT;
     67        LIBCLOG_RETURN_INT(-1);
    3568    }
    36   if (flag == 0)
     69
     70    /*
     71     * Query current attributes.
     72     */
     73    FS_SAVE_LOAD();
     74    rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info));
     75    if (rc != 0)
    3776    {
    38       FS_RESTORE();
    39       return info.attrFile;
     77        FS_RESTORE();
     78        _sys_set_errno(rc);
     79        LIBCLOG_RETURN_INT(-1);
    4080    }
    41   info.attrFile = attr;
    42   rc = DosSetPathInfo (name, FIL_STANDARD, &info, sizeof (info), 0);
    43   FS_RESTORE();
    44   if (rc != 0)
     81    if (flag == 0)
    4582    {
    46       _sys_set_errno (rc);
    47       return -1;
     83        FS_RESTORE();
     84        LIBCLOG_RETURN_INT((int)info.attrFile);
    4885    }
    49   return 0;
     86
     87    /*
     88     * Change attributes.
     89     */
     90    info.attrFile = attr;
     91    rc = DosSetPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info), 0);
     92    FS_RESTORE();
     93    if (rc != 0)
     94    {
     95        _sys_set_errno(rc);
     96        LIBCLOG_RETURN_INT(-1);
     97    }
     98    LIBCLOG_RETURN_INT(0);
    5099}
  • trunk/src/emx/src/lib/sys/__fstat.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1325 r1326  
    11/* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    sys/__fstat.c (libc)  -- Copyright (c) 2003 by knut st. osmundsen
     2 * sys/__fstat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
    33 */
    44
     5/*******************************************************************************
     6*   Header Files                                                               *
     7*******************************************************************************/
    58#include "libc-alias.h"
    69#define INCL_FSMACROS
     
    1417#include <limits.h>
    1518#include "syscalls.h"
     19#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     20#include <InnoTekLIBC/logstrict.h>
    1621
    1722int __fstat(int hFile, struct stat *pStat)
    1823{
     24    LIBCLOG_ENTER("hFile=%d pStat=%p\n", hFile, (void *)pStat);
    1925    ULONG   rc;
    2026    ULONG   ulType;
     
    3036    {
    3137        errno = EBADF;
    32         return -1;
     38        LIBCLOG_RETURN_INT(-1);
    3339    }
    3440
     
    4450            FS_RESTORE();
    4551            _sys_set_errno(rc);
    46             return -1;
     52            LIBCLOG_RETURN_INT(-1);
    4753        }
    4854        switch (pFH->fFlags & F_TYPEMASK)
     
    8389                FS_RESTORE();
    8490                _sys_set_errno (rc);
    85                 return -1;
     91                LIBCLOG_RETURN_INT(-1);
    8692            }
    8793
     
    133139                FS_RESTORE();
    134140                _sys_set_errno (rc);
    135                 return -1;
     141                LIBCLOG_RETURN_INT(-1);
    136142            }
    137143            if ((flFlags & 7) == OPEN_ACCESS_READONLY)
     
    159165         */
    160166        errno = EPERM;
    161         return -1;
     167        LIBCLOG_RETURN_INT(-1);
    162168    }
    163169
    164     return 0;
     170    LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
     171    LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
     172    LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
     173    LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
     174    LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
     175    LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
     176    LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
     177    LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
     178    LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
     179    LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
     180    LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
     181    LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
     182    LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
     183    LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
     184    LIBCLOG_RETURN_INT(0);
    165185}
  • trunk/src/emx/src/lib/sys/__mkdir.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1325 r1326  
    1 /* sys/mkdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* sys/mkdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
     2                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
    23
    34#include "libc-alias.h"
    45#define INCL_FSMACROS
    56#include <os2emx.h>
     7#include <stdlib.h>
     8#include <errno.h>
    69#include <emx/syscalls.h>
    710#include "syscalls.h"
     11#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     12#include <InnoTekLIBC/logstrict.h>
     13#include <InnoTekLIBC/pathrewrite.h>
    814
    9 int __mkdir (const char *name)
     15
     16int __mkdir(const char *pszPath)
    1017{
    11   ULONG rc;
    12   FS_VAR();
     18    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
     19    ULONG   rc;
     20    int     cch;
     21    FS_VAR();
    1322
    14   FS_SAVE_LOAD();
    15   rc = DosCreateDir (name, NULL);
    16   FS_RESTORE();
    17   if (rc != 0)
     23    /*
     24     * Rewrite the specified file path.
     25     */
     26    cch = __libc_PathRewrite(pszPath, NULL, 0);
     27    if (cch > 0)
    1828    {
    19       _sys_set_errno (rc);
    20       return -1;
     29        char *pszRewritten = alloca(cch);
     30        if (!pszRewritten)
     31        {
     32            errno = ENOMEM;
     33            LIBCLOG_RETURN_INT(-1);
     34        }
     35        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     36        if (cch > 0)
     37            pszPath = pszRewritten;
     38        /* else happens when someone changes the rules between the two calls. */
     39        else if (cch < 0)
     40        {
     41            errno = EAGAIN;             /* non-standard, I'm sure. */
     42            LIBCLOG_RETURN_INT(-1);
     43        }
    2144    }
    22   return 0;
     45
     46    /*
     47     * Do It.
     48     */
     49    FS_SAVE_LOAD();
     50    rc = DosCreateDir((PCSZ)pszPath, NULL);
     51    FS_RESTORE();
     52    if (rc != 0)
     53    {
     54        _sys_set_errno(rc);
     55        LIBCLOG_RETURN_INT(-1);
     56    }
     57    LIBCLOG_RETURN_INT(0);
    2358}
  • trunk/src/emx/src/lib/sys/__open.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1325 r1326  
    11/* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    22   Copyright (c) 2003 Dimitry Froloff
    3    Copyright (c) 2003 knut st. osmundsen
     3   Copyright (c) 2003-2004 knut st. osmundsen
    44 */
    55
     6/*******************************************************************************
     7*   Header Files                                                               *
     8*******************************************************************************/
    69#include "libc-alias.h"
    710#define INCL_DOSERRORS
     
    1821#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    1922#include <InnoTekLIBC/logstrict.h>
     23
    2024
    2125int __open(const char *pszFile, int flags, off_t cbInitial, unsigned fLibc, PLIBCFH *ppFH)
  • trunk/src/emx/src/lib/sys/__rmdir.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1325 r1326  
    44#define INCL_FSMACROS
    55#include <os2emx.h>
     6#include <stdlib.h>
     7#include <errno.h>
    68#include <emx/syscalls.h>
    79#include "syscalls.h"
     10#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     11#include <InnoTekLIBC/logstrict.h>
     12#include <InnoTekLIBC/pathrewrite.h>
    813
    9 int __rmdir (const char *name)
     14int __rmdir(const char *pszPath)
    1015{
    11   ULONG rc;
    12   FS_VAR();
     16    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
     17    ULONG   rc;
     18    int     cch;
     19    FS_VAR();
    1320
    14   FS_SAVE_LOAD();
    15   rc = DosDeleteDir (name);
    16   FS_RESTORE();
    17   if (rc != 0)
     21    /*
     22     * Rewrite the specified file path.
     23     */
     24    cch = __libc_PathRewrite(pszPath, NULL, 0);
     25    if (cch > 0)
    1826    {
    19       _sys_set_errno (rc);
    20       return -1;
     27        char *pszRewritten = alloca(cch);
     28        if (!pszRewritten)
     29        {
     30            errno = ENOMEM;
     31            LIBCLOG_RETURN_INT(-1);
     32        }
     33        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     34        if (cch > 0)
     35            pszPath = pszRewritten;
     36        /* else happens when someone changes the rules between the two calls. */
     37        else if (cch < 0)
     38        {
     39            errno = EAGAIN;             /* non-standard, I'm sure. */
     40            LIBCLOG_RETURN_INT(-1);
     41        }
    2142    }
    22   return 0;
     43
     44    /*
     45     * Do It.
     46     */
     47    FS_SAVE_LOAD();
     48    rc = DosDeleteDir((PCSZ)pszPath);
     49    FS_RESTORE();
     50    if (rc)
     51    {
     52        _sys_set_errno(rc);
     53        LIBCLOG_RETURN_INT(-1);
     54    }
     55    LIBCLOG_RETURN_INT(0);
    2356}
  • trunk/src/emx/src/lib/sys/__stat.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1325 r1326  
    11/* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    sys/__stat.c (libc)  -- Copyright (c) 2003 by knut st. osmundsen
     2 * sys/__stat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
    33 */
    44
     5/*******************************************************************************
     6*   Header Files                                                               *
     7*******************************************************************************/
    58#include "libc-alias.h"
    69#define INCL_FSMACROS
     
    811#include <string.h>
    912#include <errno.h>
     13#include <stdlib.h>
    1014#include <sys/types.h>
    1115#include <sys/stat.h>
     
    1317#include <limits.h>
    1418#include "syscalls.h"
     19#include <InnoTekLIBC/pathrewrite.h>
     20#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     21#include <InnoTekLIBC/logstrict.h>
    1522
    1623int __stat(const char *pszPath, struct stat *pStat)
    1724{
     25    LIBCLOG_ENTER("pszPath=%s pStat=%p\n", pszPath, (void *)pStat);
    1826    ULONG   rc;
     27    int     cch;
    1928    union
    2029    {
     
    2736    FS_VAR();
    2837
     38    memset(pStat, 0, sizeof(*pStat));
     39
     40    /*
     41     * Rewrite the specified file path.
     42     */
     43    cch = __libc_PathRewrite(pszPath, NULL, 0);
     44    if (cch > 0)
     45    {
     46        char *pszRewritten = alloca(cch);
     47        if (!pszRewritten)
     48        {
     49            errno = ENOMEM;
     50            LIBCLOG_RETURN_INT(-1);
     51        }
     52        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     53        if (cch > 0)
     54            pszPath = pszRewritten;
     55        /* else happens when someone changes the rules between the two calls. */
     56        else if (cch < 0)
     57        {
     58            errno = EAGAIN;             /* non-standard, I'm sure. */
     59            LIBCLOG_RETURN_INT(-1);
     60        }
     61    }
     62
    2963    /*
    3064     * Validate input, refusing named pipes.
    3165     */
    32     memset(pStat, 0, sizeof(*pStat));
    3366    if (    (pszPath[0] == '/' || pszPath[0] == '\\')
    34         &&  !strnicmp(pszPath+1, "pipe", 4)
     67        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
     68        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
     69        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
     70        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
    3571        &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
    3672    {
    3773        errno = ENOENT;
    38         return -1;
     74        LIBCLOG_RETURN_INT(-1);
    3975    }
    4076
     
    4682    if (__pfnDosOpenL)
    4783    {
    48         rc = DosQueryPathInfo(pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));
     84        rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));
    4985        fLarge = 1;
    5086    }
    5187    else
    5288#endif
    53         rc = DosQueryPathInfo(pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));
     89        rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));
    5490    FS_RESTORE();
    5591    if (rc)
    5692    {
    5793        _sys_set_errno(rc);
    58         return -1;
     94        LIBCLOG_RETURN_INT(-1);
    5995    }
    6096
     
    121157    pStat->st_nlink = 1;
    122158    pStat->st_blksize = 4096*48;
    123     return 0;
     159
     160    LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
     161    LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
     162    LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
     163    LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
     164    LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
     165    LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
     166    LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
     167    LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
     168    LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
     169    LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
     170    LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
     171    LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
     172    LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
     173    LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
     174    LIBCLOG_RETURN_INT(0);
    124175}
  • trunk/src/emx/src/lib/sys/__utimes.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1325 r1326  
    55#include <os2emx.h>
    66#include <string.h>
     7#include <stdlib.h>
    78#include <errno.h>
    89#include <time.h>
     
    1011#include <emx/syscalls.h>
    1112#include "syscalls.h"
     13#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     14#include <InnoTekLIBC/logstrict.h>
     15#include <InnoTekLIBC/pathrewrite.h>
    1216
    13 static void _sys_t2p (long sec, PFTIME time, PFDATE date)
     17
     18static void _sys_t2p(long sec, PFTIME time, PFDATE date)
    1419{
    15   struct tm *p;
    16   USHORT tmp;
     20    struct tm *p;
     21    USHORT tmp;
    1722
    18   p = gmtime (&sec);
     23    p = gmtime(&sec);
    1924#if 0                           /* This didn't work in GCC versions <= 2.4 */
    20   time->twosecs = p->tm_sec / 2;
    21   time->minutes = p->tm_min;
    22   time->hours = p->tm_hour;
    23   date->day = p->tm_mday;
    24   date->month = p->tm_mon + 1;
    25   date->year = p->tm_year - 1980 + 1900;
     25    time->twosecs  = p->tm_sec / 2;
     26    time->minutes  = p->tm_min;
     27    time->hours    = p->tm_hour;
     28    date->day      = p->tm_mday;
     29    date->month    = p->tm_mon + 1;
     30    date->year      = p->tm_year - 1980 + 1900;
    2631#else
    27   tmp = (p->tm_sec / 2) + (p->tm_min << 5) + (p->tm_hour << 11);
    28   *(USHORT *)time = tmp;
    29   tmp = p->tm_mday + ((p->tm_mon + 1) << 5) + ((p->tm_year - 80) << 9);
    30   *(USHORT *)date = tmp;
     32    tmp = (p->tm_sec / 2) + (p->tm_min << 5) + (p->tm_hour << 11);
     33    *(USHORT *)time = tmp;
     34    tmp = p->tm_mday + ((p->tm_mon + 1) << 5) + ((p->tm_year - 80) << 9);
     35    *(USHORT *)date = tmp;
    3136#endif
    3237}
    3338
    3439
    35 int __utimes (const char *name, const struct timeval *tvp)
     40int __utimes(const char *pszPath, const struct timeval *tvp)
    3641{
    37   ULONG rc;
    38   FILESTATUS3 info;
    39   FS_VAR();
     42    LIBCLOG_ENTER("pszPath=%s tvp=%p {{%ld,%ld}, {%ld,%ld}}\n", pszPath, (void*)tvp,
     43                  tvp ? tvp[0].tv_sec : ~0, tvp ? tvp[0].tv_usec : ~0,
     44                  tvp ? tvp[1].tv_sec : ~0, tvp ? tvp[1].tv_usec : ~0);
     45    int         cch;
     46    ULONG       rc;
     47    FILESTATUS3 info;
     48    FS_VAR();
    4049
    41   if ((name[0] == '/' || name[0] == '\\') && strlen (name) >= 6 &&
    42       memicmp (name+1, "pipe", 4) == 0 && (name[5] == '/' || name[5] == '\\'))
     50    /*
     51     * Rewrite the specified file path.
     52     */
     53    cch = __libc_PathRewrite(pszPath, NULL, 0);
     54    if (cch > 0)
    4355    {
    44       errno = ENOENT;
    45       return -1;
     56        char *pszRewritten = alloca(cch);
     57        if (!pszRewritten)
     58        {
     59            errno = ENOMEM;
     60            LIBCLOG_RETURN_INT(-1);
     61        }
     62        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
     63        if (cch > 0)
     64            pszPath = pszRewritten;
     65        /* else happens when someone changes the rules between the two calls. */
     66        else if (cch < 0)
     67        {
     68            errno = EAGAIN;             /* non-standard, I'm sure. */
     69            LIBCLOG_RETURN_INT(-1);
     70        }
    4671    }
    47   FS_SAVE_LOAD();
    48   rc = DosQueryPathInfo (name, FIL_STANDARD, &info, sizeof (info));
    49   if (rc != 0)
     72
     73    /*
     74     * Validate input.
     75     */
     76    if (    (pszPath[0] == '/' || pszPath[0] == '\\')
     77        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
     78        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
     79        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
     80        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
     81        &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
    5082    {
    51       FS_RESTORE();
    52       _sys_set_errno (rc);
    53       return -1;
     83        errno = ENOENT;
     84        return -1;
    5485    }
    55   _sys_t2p (tvp[0].tv_sec, &info.ftimeLastAccess, &info.fdateLastAccess);
    56   _sys_t2p (tvp[1].tv_sec, &info.ftimeLastWrite, &info.fdateLastWrite);
    57   rc = DosSetPathInfo (name, FIL_STANDARD, &info, sizeof (info), 0);
    58   FS_RESTORE();
    59   if (rc != 0)
     86
     87    /*
     88     * Query current path info.
     89     */
     90    FS_SAVE_LOAD();
     91    rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info));
     92    if (rc)
    6093    {
    61       _sys_set_errno (rc);
    62       return -1;
     94        FS_RESTORE();
     95        _sys_set_errno(rc);
     96        LIBCLOG_RETURN_INT(-1);
    6397    }
    64   return 0;
     98
     99    /*
     100     * Apply the new times and update.
     101     */
     102    _sys_t2p(tvp[0].tv_sec, &info.ftimeLastAccess, &info.fdateLastAccess);
     103    _sys_t2p(tvp[1].tv_sec, &info.ftimeLastWrite,  &info.fdateLastWrite);
     104    rc = DosSetPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info), 0);
     105    FS_RESTORE();
     106    if (rc)
     107    {
     108        _sys_set_errno(rc);
     109        LIBCLOG_RETURN_INT(-1);
     110    }
     111    LIBCLOG_RETURN_INT(0);
    65112}
  • trunk/src/emx/src/lib/sys/filefind.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1325 r1326  
    11/* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    sys/filefind.c (libc)    -- Copyright (c) 2003 by knut st. osmundsen
     2   sys/filefind.c (libc)    -- Copyright (c) 2003-2004 by knut st. osmundsen
    33*/
    44
     5/*******************************************************************************
     6*   Header Files                                                               *
     7*******************************************************************************/
    58#include "libc-alias.h"
     9#include <stdlib.h>
    610#include <string.h>
    711#include <errno.h>
     
    1317#include "syscalls.h"
    1418#include <InnoTekLIBC/thread.h>
     19#include <InnoTekLIBC/pathrewrite.h>
     20#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     21#include <InnoTekLIBC/logstrict.h>
    1522
    1623/**
     
    114121int __findfirst(const char *pszName, int attr, struct _find *fp)
    115122{
    116     ULONG               rc;
     123    LIBCLOG_ENTER("pszName=%s attr=%#x fp=%p\n", pszName, attr, (void *)fp);
     124    int                 rc;
     125    int                 cch;
    117126    struct find_data   *pFD = &__libc_threadCurrent()->b.sys.fd;
    118127    FS_VAR();
     128
     129    /*
     130     * Rewrite the specified file path.
     131     */
     132    cch = __libc_PathRewrite(pszName, NULL, 0);
     133    if (cch > 0)
     134    {
     135        char *pszRewritten = alloca(cch);
     136        if (!pszRewritten)
     137        {
     138            errno = ENOMEM;
     139            LIBCLOG_RETURN_INT(-1);
     140        }
     141        cch = __libc_PathRewrite(pszName, pszRewritten, cch);
     142        if (cch > 0)
     143            pszName = pszRewritten;
     144        /* else happens when someone changes the rules between the two calls. */
     145        else if (cch < 0)
     146        {
     147            errno = EAGAIN;             /* non-standard, I'm sure. */
     148            LIBCLOG_RETURN_INT(-1);
     149        }
     150    }
    119151
    120152    /*
     
    160192        pFD->pchNext = NULL;
    161193        _sys_set_errno(rc);
    162         return -1;
     194        LIBCLOG_RETURN_INT(-1);
    163195    }
    164196    pFD->pchNext = &pFD->achBuffer[0];
    165     return find_conv(pFD, fp);
     197    rc = find_conv(pFD, fp);
     198    LIBCLOG_RETURN_INT(rc);
    166199}
    167200
  • trunk/src/emx/src/lib/sys/remove.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1325 r1326  
    11/* sys/remove.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2                           -- Copyright (c) 2003 by Knut St. Osmundsen */
     2                          -- Copyright (c) 2003-2004 by Knut St. Osmundsen */
    33
     4/*******************************************************************************
     5*   Header Files                                                               *
     6*******************************************************************************/
    47#include "libc-alias.h"
    58#define INCL_FSMACROS
     
    710#include <os2safe.h>
    811#include <os2emx.h>
     12#include <stdlib.h>
    913#include <stdio.h>
     14#include <errno.h>
    1015#include <emx/syscalls.h>
    1116#include "syscalls.h"
     17#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     18#include <InnoTekLIBC/logstrict.h>
     19#include <InnoTekLIBC/pathrewrite.h>
    1220
    13 int _STD(remove)(const char *name)
     21int _STD(remove)(const char *pszFile)
    1422{
    15     static int    fUseForce; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */
    16     ULONG         rc;
     23    LIBCLOG_ENTER("pszFile=%s\n", pszFile);
     24    static int  fUseForce; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */
     25    ULONG       rc;
     26    int         cch;
    1727    FS_VAR();
     28
     29    /*
     30     * Rewrite the specified file path.
     31     */
     32    cch = __libc_PathRewrite(pszFile, NULL, 0);
     33    if (cch > 0)
     34    {
     35        char *pszRewritten = alloca(cch);
     36        if (!pszRewritten)
     37        {
     38            errno = ENOMEM;
     39            LIBCLOG_RETURN_INT(-1);
     40        }
     41        cch = __libc_PathRewrite(pszFile, pszRewritten, cch);
     42        if (cch > 0)
     43            pszFile = pszRewritten;
     44        /* else happens when someone changes the rules between the two calls. */
     45        else if (cch < 0)
     46        {
     47            errno = EAGAIN;             /* non-standard, I'm sure. */
     48            LIBCLOG_RETURN_INT(-1);
     49        }
     50    }
    1851
    1952    FS_SAVE_LOAD();
     
    3063    {
    3164        PSZ psz = NULL;
    32         if (DosScanEnv("DELDIR", &psz) || !psz)
     65        if (DosScanEnv((PCSZ)"DELDIR", &psz) || !psz)
    3366            fUseForce = 1;
    3467        else
     
    4073     */
    4174    if (fUseForce == 1)
    42         rc = DosForceDelete(name);
     75        rc = DosForceDelete((PCSZ)pszFile);
    4376    else
    44         rc = DosDelete(name);
     77        rc = DosDelete((PCSZ)pszFile);
    4578    FS_RESTORE();
    4679    if (rc)
    4780    {
    4881        _sys_set_errno(rc);
    49         return -1;
     82        LIBCLOG_RETURN_INT(-1);
    5083    }
    51     return 0;
     84    LIBCLOG_RETURN_INT(0);
    5285}
  • trunk/src/emx/src/lib/sys/rename.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1325 r1326  
    1 /* sys/rename.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* sys/rename.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
     2                          -- Copyright (c) 2003-2004 by knut st. osmundsen */
    23
     4/*******************************************************************************
     5*   Header Files                                                               *
     6*******************************************************************************/
    37#include "libc-alias.h"
    48#define INCL_FSMACROS
    59#include <os2emx.h>
    610#include <stdio.h>
     11#include <stdlib.h>
     12#include <errno.h>
    713#include <emx/syscalls.h>
    814#include "syscalls.h"
     15#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     16#include <InnoTekLIBC/logstrict.h>
     17#include <InnoTekLIBC/pathrewrite.h>
    918
    10 int _STD(rename) (const char *old_name, const char *new_name)
     19int _STD(rename)(const char *pszOldName, const char *pszNewName)
    1120{
    12   ULONG rc;
    13   FS_VAR();
     21    LIBCLOG_ENTER("pszOldName=%s pszNewName=%s\n", pszOldName, pszNewName);
     22    ULONG   rc;
     23    int     cch;
     24    FS_VAR();
    1425
    15   FS_SAVE_LOAD();
    16   rc = DosMove (old_name, new_name);
    17   FS_RESTORE();
    18   if (rc != 0)
     26    /*
     27     * Rewrite the specified paths.
     28     */
     29    cch = __libc_PathRewrite(pszOldName, NULL, 0);
     30    if (cch > 0)
    1931    {
    20       _sys_set_errno (rc);
    21       return -1;
     32        char *pszRewritten = alloca(cch);
     33        if (!pszRewritten)
     34        {
     35            errno = ENOMEM;
     36            LIBCLOG_RETURN_INT(-1);
     37        }
     38        cch = __libc_PathRewrite(pszOldName, pszRewritten, cch);
     39        if (cch > 0)
     40            pszOldName = pszRewritten;
     41        /* else happens when someone changes the rules between the two calls. */
     42        else if (cch < 0)
     43        {
     44            errno = EAGAIN;             /* non-standard, I'm sure. */
     45            LIBCLOG_RETURN_INT(-1);
     46        }
    2247    }
    23   return 0;
     48
     49    cch = __libc_PathRewrite(pszNewName, NULL, 0);
     50    if (cch > 0)
     51    {
     52        char *pszRewritten = alloca(cch);
     53        if (!pszRewritten)
     54        {
     55            errno = ENOMEM;
     56            LIBCLOG_RETURN_INT(-1);
     57        }
     58        cch = __libc_PathRewrite(pszNewName, pszRewritten, cch);
     59        if (cch > 0)
     60            pszNewName = pszRewritten;
     61        /* else happens when someone changes the rules between the two calls. */
     62        else if (cch < 0)
     63        {
     64            errno = EAGAIN;             /* non-standard, I'm sure. */
     65            LIBCLOG_RETURN_INT(-1);
     66        }
     67    }
     68
     69    /*
     70     * Rename it.
     71     */
     72    FS_SAVE_LOAD();
     73    rc = DosMove((PCSZ)pszOldName, (PCSZ)pszNewName);
     74    FS_RESTORE();
     75    if (rc)
     76    {
     77        _sys_set_errno(rc);
     78        LIBCLOG_RETURN_INT(-1);
     79    }
     80    LIBCLOG_RETURN_INT(0);
    2481}
Note: See TracChangeset for help on using the changeset viewer.