Changeset 1326
- Timestamp:
- Mar 22, 2004, 1:07:03 AM (21 years ago)
- 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
to1.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 */ 2 3 3 4 #include "libc-alias.h" 4 5 #define INCL_FSMACROS 5 6 #include <os2emx.h> 7 #include <stdlib.h> 8 #include <errno.h> 6 9 #include <emx/syscalls.h> 7 10 #include "syscalls.h" 11 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 12 #include <InnoTekLIBC/logstrict.h> 13 #include <InnoTekLIBC/pathrewrite.h> 8 14 9 15 10 int __chdir (const char * name)16 int __chdir (const char *pszPath) 11 17 { 12 ULONG rc; 13 FS_VAR(); 18 LIBCLOG_ENTER("pszPath=%s\n", pszPath); 19 ULONG rc; 20 int cch; 21 FS_VAR(); 14 22 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) 19 28 { 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 } 22 44 } 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); 24 59 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__chmod.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.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 */ 2 3 4 /******************************************************************************* 5 * Header Files * 6 *******************************************************************************/ 3 7 #include "libc-alias.h" 4 8 #include <string.h> 5 9 #include <errno.h> 10 #include <stdlib.h> 6 11 #define INCL_FSMACROS 7 12 #include <os2emx.h> 8 13 #include <emx/syscalls.h> 9 14 #include "syscalls.h" 15 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 16 #include <InnoTekLIBC/logstrict.h> 17 #include <InnoTekLIBC/pathrewrite.h> 10 18 11 int __chmod (const char *name, int flag, int attr) 19 20 int __chmod(const char *pszPath, int flag, int attr) 12 21 { 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(); 16 27 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) 18 33 { 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 } 21 49 } 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) 24 55 { 25 errno = ENOENT;26 return -1;56 errno = EINVAL; 57 LIBCLOG_RETURN_INT(-1); 27 58 } 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] == '\\')) 31 65 { 32 FS_RESTORE(); 33 _sys_set_errno (rc); 34 return -1; 66 errno = ENOENT; 67 LIBCLOG_RETURN_INT(-1); 35 68 } 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) 37 76 { 38 FS_RESTORE(); 39 return info.attrFile; 77 FS_RESTORE(); 78 _sys_set_errno(rc); 79 LIBCLOG_RETURN_INT(-1); 40 80 } 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) 45 82 { 46 _sys_set_errno (rc);47 return -1;83 FS_RESTORE(); 84 LIBCLOG_RETURN_INT((int)info.attrFile); 48 85 } 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); 50 99 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__fstat.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1325 r1326 1 1 /* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/__fstat.c (libc) -- Copyright (c) 2003by knut st. osmundsen2 * sys/__fstat.c (libc) -- Copyright (c) 2003-2004 by knut st. osmundsen 3 3 */ 4 4 5 /******************************************************************************* 6 * Header Files * 7 *******************************************************************************/ 5 8 #include "libc-alias.h" 6 9 #define INCL_FSMACROS … … 14 17 #include <limits.h> 15 18 #include "syscalls.h" 19 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 20 #include <InnoTekLIBC/logstrict.h> 16 21 17 22 int __fstat(int hFile, struct stat *pStat) 18 23 { 24 LIBCLOG_ENTER("hFile=%d pStat=%p\n", hFile, (void *)pStat); 19 25 ULONG rc; 20 26 ULONG ulType; … … 30 36 { 31 37 errno = EBADF; 32 return -1;38 LIBCLOG_RETURN_INT(-1); 33 39 } 34 40 … … 44 50 FS_RESTORE(); 45 51 _sys_set_errno(rc); 46 return -1;52 LIBCLOG_RETURN_INT(-1); 47 53 } 48 54 switch (pFH->fFlags & F_TYPEMASK) … … 83 89 FS_RESTORE(); 84 90 _sys_set_errno (rc); 85 return -1;91 LIBCLOG_RETURN_INT(-1); 86 92 } 87 93 … … 133 139 FS_RESTORE(); 134 140 _sys_set_errno (rc); 135 return -1;141 LIBCLOG_RETURN_INT(-1); 136 142 } 137 143 if ((flFlags & 7) == OPEN_ACCESS_READONLY) … … 159 165 */ 160 166 errno = EPERM; 161 return -1;167 LIBCLOG_RETURN_INT(-1); 162 168 } 163 169 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); 165 185 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__mkdir.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.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 */ 2 3 3 4 #include "libc-alias.h" 4 5 #define INCL_FSMACROS 5 6 #include <os2emx.h> 7 #include <stdlib.h> 8 #include <errno.h> 6 9 #include <emx/syscalls.h> 7 10 #include "syscalls.h" 11 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 12 #include <InnoTekLIBC/logstrict.h> 13 #include <InnoTekLIBC/pathrewrite.h> 8 14 9 int __mkdir (const char *name) 15 16 int __mkdir(const char *pszPath) 10 17 { 11 ULONG rc; 12 FS_VAR(); 18 LIBCLOG_ENTER("pszPath=%s\n", pszPath); 19 ULONG rc; 20 int cch; 21 FS_VAR(); 13 22 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) 18 28 { 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 } 21 44 } 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); 23 58 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__open.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1325 r1326 1 1 /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 2 Copyright (c) 2003 Dimitry Froloff 3 Copyright (c) 2003 knut st. osmundsen3 Copyright (c) 2003-2004 knut st. osmundsen 4 4 */ 5 5 6 /******************************************************************************* 7 * Header Files * 8 *******************************************************************************/ 6 9 #include "libc-alias.h" 7 10 #define INCL_DOSERRORS … … 18 21 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 19 22 #include <InnoTekLIBC/logstrict.h> 23 20 24 21 25 int __open(const char *pszFile, int flags, off_t cbInitial, unsigned fLibc, PLIBCFH *ppFH) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__rmdir.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1325 r1326 4 4 #define INCL_FSMACROS 5 5 #include <os2emx.h> 6 #include <stdlib.h> 7 #include <errno.h> 6 8 #include <emx/syscalls.h> 7 9 #include "syscalls.h" 10 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 11 #include <InnoTekLIBC/logstrict.h> 12 #include <InnoTekLIBC/pathrewrite.h> 8 13 9 int __rmdir (const char *name)14 int __rmdir(const char *pszPath) 10 15 { 11 ULONG rc; 12 FS_VAR(); 16 LIBCLOG_ENTER("pszPath=%s\n", pszPath); 17 ULONG rc; 18 int cch; 19 FS_VAR(); 13 20 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) 18 26 { 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 } 21 42 } 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); 23 56 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__stat.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1325 r1326 1 1 /* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/__stat.c (libc) -- Copyright (c) 2003by knut st. osmundsen2 * sys/__stat.c (libc) -- Copyright (c) 2003-2004 by knut st. osmundsen 3 3 */ 4 4 5 /******************************************************************************* 6 * Header Files * 7 *******************************************************************************/ 5 8 #include "libc-alias.h" 6 9 #define INCL_FSMACROS … … 8 11 #include <string.h> 9 12 #include <errno.h> 13 #include <stdlib.h> 10 14 #include <sys/types.h> 11 15 #include <sys/stat.h> … … 13 17 #include <limits.h> 14 18 #include "syscalls.h" 19 #include <InnoTekLIBC/pathrewrite.h> 20 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 21 #include <InnoTekLIBC/logstrict.h> 15 22 16 23 int __stat(const char *pszPath, struct stat *pStat) 17 24 { 25 LIBCLOG_ENTER("pszPath=%s pStat=%p\n", pszPath, (void *)pStat); 18 26 ULONG rc; 27 int cch; 19 28 union 20 29 { … … 27 36 FS_VAR(); 28 37 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 29 63 /* 30 64 * Validate input, refusing named pipes. 31 65 */ 32 memset(pStat, 0, sizeof(*pStat));33 66 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') 35 71 && (pszPath[5] == '/' || pszPath[5] == '\\')) 36 72 { 37 73 errno = ENOENT; 38 return -1;74 LIBCLOG_RETURN_INT(-1); 39 75 } 40 76 … … 46 82 if (__pfnDosOpenL) 47 83 { 48 rc = DosQueryPathInfo( pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));84 rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 49 85 fLarge = 1; 50 86 } 51 87 else 52 88 #endif 53 rc = DosQueryPathInfo( pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));89 rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info.fsts3)); 54 90 FS_RESTORE(); 55 91 if (rc) 56 92 { 57 93 _sys_set_errno(rc); 58 return -1;94 LIBCLOG_RETURN_INT(-1); 59 95 } 60 96 … … 121 157 pStat->st_nlink = 1; 122 158 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); 124 175 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__utimes.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1325 r1326 5 5 #include <os2emx.h> 6 6 #include <string.h> 7 #include <stdlib.h> 7 8 #include <errno.h> 8 9 #include <time.h> … … 10 11 #include <emx/syscalls.h> 11 12 #include "syscalls.h" 13 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 14 #include <InnoTekLIBC/logstrict.h> 15 #include <InnoTekLIBC/pathrewrite.h> 12 16 13 static void _sys_t2p (long sec, PFTIME time, PFDATE date) 17 18 static void _sys_t2p(long sec, PFTIME time, PFDATE date) 14 19 { 15 struct tm *p;16 USHORT tmp;20 struct tm *p; 21 USHORT tmp; 17 22 18 p = gmtime(&sec);23 p = gmtime(&sec); 19 24 #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; 26 31 #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; 31 36 #endif 32 37 } 33 38 34 39 35 int __utimes (const char *name, const struct timeval *tvp)40 int __utimes(const char *pszPath, const struct timeval *tvp) 36 41 { 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(); 40 49 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) 43 55 { 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 } 46 71 } 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] == '\\')) 50 82 { 51 FS_RESTORE(); 52 _sys_set_errno (rc); 53 return -1; 83 errno = ENOENT; 84 return -1; 54 85 } 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) 60 93 { 61 _sys_set_errno (rc); 62 return -1; 94 FS_RESTORE(); 95 _sys_set_errno(rc); 96 LIBCLOG_RETURN_INT(-1); 63 97 } 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); 65 112 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filefind.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1325 r1326 1 1 /* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes 2 sys/filefind.c (libc) -- Copyright (c) 2003 by knut st. osmundsen2 sys/filefind.c (libc) -- Copyright (c) 2003-2004 by knut st. osmundsen 3 3 */ 4 4 5 /******************************************************************************* 6 * Header Files * 7 *******************************************************************************/ 5 8 #include "libc-alias.h" 9 #include <stdlib.h> 6 10 #include <string.h> 7 11 #include <errno.h> … … 13 17 #include "syscalls.h" 14 18 #include <InnoTekLIBC/thread.h> 19 #include <InnoTekLIBC/pathrewrite.h> 20 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 21 #include <InnoTekLIBC/logstrict.h> 15 22 16 23 /** … … 114 121 int __findfirst(const char *pszName, int attr, struct _find *fp) 115 122 { 116 ULONG rc; 123 LIBCLOG_ENTER("pszName=%s attr=%#x fp=%p\n", pszName, attr, (void *)fp); 124 int rc; 125 int cch; 117 126 struct find_data *pFD = &__libc_threadCurrent()->b.sys.fd; 118 127 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 } 119 151 120 152 /* … … 160 192 pFD->pchNext = NULL; 161 193 _sys_set_errno(rc); 162 return -1;194 LIBCLOG_RETURN_INT(-1); 163 195 } 164 196 pFD->pchNext = &pFD->achBuffer[0]; 165 return find_conv(pFD, fp); 197 rc = find_conv(pFD, fp); 198 LIBCLOG_RETURN_INT(rc); 166 199 } 167 200 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/remove.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1325 r1326 1 1 /* 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 */ 3 3 4 /******************************************************************************* 5 * Header Files * 6 *******************************************************************************/ 4 7 #include "libc-alias.h" 5 8 #define INCL_FSMACROS … … 7 10 #include <os2safe.h> 8 11 #include <os2emx.h> 12 #include <stdlib.h> 9 13 #include <stdio.h> 14 #include <errno.h> 10 15 #include <emx/syscalls.h> 11 16 #include "syscalls.h" 17 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 18 #include <InnoTekLIBC/logstrict.h> 19 #include <InnoTekLIBC/pathrewrite.h> 12 20 13 int _STD(remove)(const char * name)21 int _STD(remove)(const char *pszFile) 14 22 { 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; 17 27 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 } 18 51 19 52 FS_SAVE_LOAD(); … … 30 63 { 31 64 PSZ psz = NULL; 32 if (DosScanEnv( "DELDIR", &psz) || !psz)65 if (DosScanEnv((PCSZ)"DELDIR", &psz) || !psz) 33 66 fUseForce = 1; 34 67 else … … 40 73 */ 41 74 if (fUseForce == 1) 42 rc = DosForceDelete( name);75 rc = DosForceDelete((PCSZ)pszFile); 43 76 else 44 rc = DosDelete( name);77 rc = DosDelete((PCSZ)pszFile); 45 78 FS_RESTORE(); 46 79 if (rc) 47 80 { 48 81 _sys_set_errno(rc); 49 return -1;82 LIBCLOG_RETURN_INT(-1); 50 83 } 51 return 0;84 LIBCLOG_RETURN_INT(0); 52 85 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/rename.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.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 */ 2 3 4 /******************************************************************************* 5 * Header Files * 6 *******************************************************************************/ 3 7 #include "libc-alias.h" 4 8 #define INCL_FSMACROS 5 9 #include <os2emx.h> 6 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <errno.h> 7 13 #include <emx/syscalls.h> 8 14 #include "syscalls.h" 15 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 16 #include <InnoTekLIBC/logstrict.h> 17 #include <InnoTekLIBC/pathrewrite.h> 9 18 10 int _STD(rename) (const char *old_name, const char *new_name)19 int _STD(rename)(const char *pszOldName, const char *pszNewName) 11 20 { 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(); 14 25 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) 19 31 { 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 } 22 47 } 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); 24 81 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.