Changeset 1534
- Timestamp:
- Oct 1, 2004, 6:55:39 AM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/emx/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1533 r1534 61 61 /** File attributes. */ 62 62 unsigned char attr; 63 #if 0 /// @todo DT_LNK & d_ino 64 /** Directory entry type. */ 65 unsigned char dt_type; 66 #endif 63 67 /** File name */ 64 68 char szName[257]; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/lstat.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 1 /* lstat.c (libc) -- Copyright (c) 2003 knut st. osmundsen */ 1 /* $Id$ *//* lstat.c (libc) -- Copyright (c) 2003 knut st. osmundsen */ 2 /** @file 3 * 4 * lstat(). 5 * 6 * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de> 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 28 /******************************************************************************* 29 * Header Files * 30 *******************************************************************************/ 3 31 #include "libc-alias.h" 32 #include <errno.h> 4 33 #include <sys/types.h> 5 34 #include <sys/stat.h> 6 #include <emx/syscalls.h> 35 #include <emx/time.h> 36 #include <InnoTekLIBC/backend.h> 37 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC 38 #include <InnoTekLIBC/logstrict.h> 7 39 8 int _STD(lstat) (const char *name, struct stat *buffer) 40 41 int _STD(lstat)(const char *name, struct stat *buffer) 9 42 { 10 return stat(name, buffer); 43 LIBCLOG_ENTER("name=%p:{%s} buffer=%p\n", (void *)name, name, (void *)buffer); 44 int rc = __libc_Back_fsSymlinkStat(name, buffer); 45 if (!rc) 46 { 47 if (!_tzset_flag) 48 tzset(); 49 _loc2gmt(&buffer->st_atime, -1); 50 _loc2gmt(&buffer->st_mtime, -1); 51 _loc2gmt(&buffer->st_ctime, -1); 52 } 53 else 54 { 55 errno = -rc; 56 rc = -1; 57 } 58 LIBCLOG_RETURN_INT(rc); 11 59 } 12 60 61 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/stat.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1533 r1534 2 2 3 3 #include "libc-alias.h" 4 #include <stdlib.h>5 #include <string.h>6 #include <time.h>7 #include <io.h>8 4 #include <errno.h> 9 5 #include <sys/types.h> 10 6 #include <sys/stat.h> 11 #include <emx/io.h>12 7 #include <emx/time.h> 13 #include <emx/syscalls.h>14 8 #include <InnoTekLIBC/backend.h> 9 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC 10 #include <InnoTekLIBC/logstrict.h> 15 11 16 12 int _STD(stat) (const char *name, struct stat *buffer) 17 13 { 18 int rc = __libc_Back_fsFileStat (name, buffer); 19 if (rc == 0) 14 LIBCLOG_ENTER("name=%p:{%s} buffer=%p\n", (void *)name, name, (void *)buffer); 15 int rc = __libc_Back_fsFileStat (name, buffer); 16 if (!rc) 20 17 { 21 if (!_tzset_flag) 22 tzset (); 23 _loc2gmt (&buffer->st_atime, -1); 24 _loc2gmt (&buffer->st_mtime, -1); 25 _loc2gmt (&buffer->st_ctime, -1); 26 if ((buffer->st_mode & (S_IFMT | ((S_IEXEC >> 6) * 0111))) == S_IFREG) 27 { 28 const char *tmp = _getext (name); 29 if (tmp != NULL && 30 (stricmp (tmp, ".exe") == 0 || 31 stricmp (tmp, ".com") == 0 || 32 stricmp (tmp, ".cmd") == 0 || 33 stricmp (tmp, ".bat") == 0)) 34 buffer->st_mode |= (S_IEXEC >> 6) * 0111; 35 } 18 if (!_tzset_flag) 19 tzset (); 20 _loc2gmt (&buffer->st_atime, -1); 21 _loc2gmt (&buffer->st_mtime, -1); 22 _loc2gmt (&buffer->st_ctime, -1); 36 23 } 37 else24 else 38 25 { 39 errno = -rc;40 rc = -1;26 errno = -rc; 27 rc = -1; 41 28 } 42 return rc;29 LIBCLOG_RETURN_INT(rc); 43 30 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/symlink.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 52 52 int rc = __libc_Back_fsSymlinkCreate(target, symlink); 53 53 if (!rc) 54 LIBCLOG_RETURN_INT( !rc);54 LIBCLOG_RETURN_INT(0); 55 55 errno = -rc; 56 56 LIBCLOG_RETURN_INT(-1); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsDirCreate.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 71 71 if (!rc) 72 72 { 73 __libc_back_fs SetUnixAttribs(-1, &szNativePath[0], Mode);73 __libc_back_fsUnixAttribsSet(-1, &szNativePath[0], Mode); 74 74 LIBCLOG_RETURN_INT(0); 75 75 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsFileStatFH.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 42 42 #include <limits.h> 43 43 #include "syscalls.h" 44 #include <InnoTekLIBC/libc.h> 44 45 #include <InnoTekLIBC/backend.h> 45 46 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO … … 89 90 } 90 91 91 FS_VAR(); 92 FS_SAVE_LOAD(); 93 if (pStat->st_mode == S_IFREG) 94 { 95 union 96 { 97 FILESTATUS3 fsts3; 98 FILESTATUS3L fsts3L; 99 } info; 100 #if OFF_MAX > LONG_MAX 101 int fLarge = 0; 102 #endif 103 104 /* 105 * Get file info. 106 */ 107 #if OFF_MAX > LONG_MAX 108 if (__libc_gpfnDosOpenL) 109 { 110 rc = DosQueryFileInfo(fh, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 111 fLarge = 1; 112 } 113 else 114 #endif 115 rc = DosQueryFileInfo(fh, FIL_STANDARD, &info, sizeof(info.fsts3)); 116 if (rc) 117 { 118 FS_RESTORE(); 119 rc = -__libc_native2errno(rc); 120 LIBCLOG_RETURN_INT(rc); 121 } 122 123 /* 124 * Format stats struct. 125 * We know the info struct layouts! 126 * Only cbFile, cbFileAlloc and attrFile need be accessed 127 * using the specific structure. 128 */ 129 /* Times: FAT might not return create and access time. */ 130 pStat->st_mtime = _sys_p2t(info.fsts3.ftimeLastWrite, info.fsts3.fdateLastWrite); 131 if ( FTIMEZEROP(info.fsts3.ftimeCreation) 132 && FDATEZEROP(info.fsts3.fdateCreation)) 133 pStat->st_ctime = pStat->st_mtime; 134 else 135 pStat->st_ctime = _sys_p2t(info.fsts3.ftimeCreation, info.fsts3.fdateCreation); 136 if ( FTIMEZEROP(info.fsts3.ftimeLastAccess) 137 && FDATEZEROP(info.fsts3.fdateLastAccess)) 138 pStat->st_atime = pStat->st_mtime; 139 else 140 pStat->st_atime = _sys_p2t(info.fsts3.ftimeLastAccess, info.fsts3.fdateLastAccess); 141 142 #if OFF_MAX > LONG_MAX 143 if (fLarge) 144 { 145 pStat->st_size = info.fsts3L.cbFile; 146 pStat->st_blocks = info.fsts3L.cbFileAlloc / S_BLKSIZE; 147 rc = info.fsts3L.attrFile; 148 } 149 else 150 #endif 151 { 152 pStat->st_size = info.fsts3.cbFile; 153 pStat->st_blocks = info.fsts3.cbFileAlloc / S_BLKSIZE; 154 rc = info.fsts3.attrFile; 155 } 156 pStat->st_attr = rc; 157 if (rc & FILE_READONLY) 158 pStat->st_mode |= (S_IREAD >> 6) * 0111; 159 else 160 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 161 } 162 else 163 { 164 if ((pFH->fFlags & O_ACCMODE) == O_RDONLY) 165 pStat->st_mode |= (S_IREAD >> 6) * 0111; 166 else 167 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 168 } 169 170 /* default fake stuff */ 171 /** @todo read EAs containing this info! */ 92 /* fake unix stuff */ 172 93 pStat->st_uid = 0; 173 94 pStat->st_gid = 0; … … 179 100 pStat->st_nlink = 1; 180 101 pStat->st_blksize = 4096*12; /* 48KB */ 102 103 FS_VAR(); 104 FS_SAVE_LOAD(); 105 if (pStat->st_mode == S_IFREG) 106 { 107 union 108 { 109 FILESTATUS4 fsts4; 110 FILESTATUS4L fsts4L; 111 } info; 112 #if OFF_MAX > LONG_MAX 113 int fLarge = 0; 114 #endif 115 116 /* 117 * Get file info. 118 */ 119 #if OFF_MAX > LONG_MAX 120 if (__libc_gpfnDosOpenL) 121 { 122 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 123 fLarge = 1; 124 } 125 else 126 #endif 127 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 128 if (rc) 129 { 130 FS_RESTORE(); 131 rc = -__libc_native2errno(rc); 132 LIBCLOG_RETURN_INT(rc); 133 } 134 135 /* 136 * Format stats struct. 137 * We know the info struct layouts! 138 * Only cbFile, cbFileAlloc and attrFile need be accessed 139 * using the specific structure. 140 */ 141 /* Times: FAT might not return create and access time. */ 142 pStat->st_mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite); 143 if ( FTIMEZEROP(info.fsts4.ftimeCreation) 144 && FDATEZEROP(info.fsts4.fdateCreation)) 145 pStat->st_ctime = pStat->st_mtime; 146 else 147 pStat->st_ctime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation); 148 if ( FTIMEZEROP(info.fsts4.ftimeLastAccess) 149 && FDATEZEROP(info.fsts4.fdateLastAccess)) 150 pStat->st_atime = pStat->st_mtime; 151 else 152 pStat->st_atime = _sys_p2t(info.fsts4.ftimeLastAccess, info.fsts4.fdateLastAccess); 153 154 #if OFF_MAX > LONG_MAX 155 if (fLarge) 156 { 157 pStat->st_size = info.fsts4L.cbFile; 158 pStat->st_blocks = info.fsts4L.cbFileAlloc / S_BLKSIZE; 159 rc = info.fsts4L.attrFile; 160 } 161 else 162 #endif 163 { 164 pStat->st_size = info.fsts4.cbFile; 165 pStat->st_blocks = info.fsts4.cbFileAlloc / S_BLKSIZE; 166 rc = info.fsts4.attrFile; 167 } 168 pStat->st_attr = rc; 169 if (rc & FILE_READONLY) 170 pStat->st_mode |= (S_IREAD >> 6) * 0111; 171 else 172 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 173 174 /* If in unix mode we'll check the EAs (if any). */ 175 if ( !__libc_gfNoUnix 176 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 177 __libc_back_fsUnixAttribsGet(fh, 0, pStat); 178 } 179 else 180 { 181 if ((pFH->fFlags & O_ACCMODE) == O_RDONLY) 182 pStat->st_mode |= (S_IREAD >> 6) * 0111; 183 else 184 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 185 } 186 181 187 FS_RESTORE(); 182 188 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsNativeFileStat.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 38 38 #include <sys/types.h> 39 39 #include <sys/stat.h> 40 #include <stdlib.h> 40 41 #include <limits.h> 41 42 #include "syscalls.h" 43 #include <InnoTekLIBC/libc.h> 42 44 #include <InnoTekLIBC/pathrewrite.h> 43 45 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS … … 59 61 union 60 62 { 61 FILESTATUS 3 fsts3;62 FILESTATUS 3L fsts3L;63 FILESTATUS4 fsts4; 64 FILESTATUS4L fsts4L; 63 65 } info; 64 66 #if OFF_MAX > LONG_MAX … … 88 90 if (__libc_gpfnDosOpenL) 89 91 { 90 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_ STANDARDL, &info, sizeof(info.fsts3L));92 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 91 93 fLarge = 1; 92 94 } 93 95 else 94 96 #endif 95 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_ STANDARD, &info, sizeof(info.fsts3));97 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 96 98 FS_RESTORE(); 97 99 if (rc) … … 108 110 */ 109 111 /* Times: FAT might not return create and access time. */ 110 pStat->st_mtime = _sys_p2t(info.fsts 3.ftimeLastWrite, info.fsts3.fdateLastWrite);111 if ( FTIMEZEROP(info.fsts 3.ftimeCreation)112 && FDATEZEROP(info.fsts 3.fdateCreation))112 pStat->st_mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite); 113 if ( FTIMEZEROP(info.fsts4.ftimeCreation) 114 && FDATEZEROP(info.fsts4.fdateCreation)) 113 115 pStat->st_ctime = pStat->st_mtime; 114 116 else 115 pStat->st_ctime = _sys_p2t(info.fsts 3.ftimeCreation, info.fsts3.fdateCreation);116 if ( FTIMEZEROP(info.fsts 3.ftimeLastAccess)117 && FDATEZEROP(info.fsts 3.fdateLastAccess))117 pStat->st_ctime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation); 118 if ( FTIMEZEROP(info.fsts4.ftimeLastAccess) 119 && FDATEZEROP(info.fsts4.fdateLastAccess)) 118 120 pStat->st_atime = pStat->st_mtime; 119 121 else 120 pStat->st_atime = _sys_p2t(info.fsts 3.ftimeLastAccess, info.fsts3.fdateLastAccess);122 pStat->st_atime = _sys_p2t(info.fsts4.ftimeLastAccess, info.fsts4.fdateLastAccess); 121 123 122 124 #if OFF_MAX > LONG_MAX 123 ULONG fAttributtes = fLarge ? info.fsts 3L.attrFile : info.fsts3.attrFile;125 ULONG fAttributtes = fLarge ? info.fsts4L.attrFile : info.fsts4.attrFile; 124 126 #else 125 ULONG fAttributtes = info.fsts 3.attrFile;127 ULONG fAttributtes = info.fsts4.attrFile; 126 128 #endif 127 129 pStat->st_attr = fAttributtes; … … 138 140 if (fLarge) 139 141 { 140 pStat->st_size = info.fsts 3L.cbFile;141 pStat->st_blocks = info.fsts 3L.cbFileAlloc / S_BLKSIZE;142 pStat->st_size = info.fsts4L.cbFile; 143 pStat->st_blocks = info.fsts4L.cbFileAlloc / S_BLKSIZE; 142 144 } 143 145 else 144 146 #endif 145 147 { 146 pStat->st_size = info.fsts 3.cbFile;147 pStat->st_blocks = info.fsts 3.cbFileAlloc / S_BLKSIZE;148 pStat->st_size = info.fsts4.cbFile; 149 pStat->st_blocks = info.fsts4.cbFileAlloc / S_BLKSIZE; 148 150 } 149 151 pStat->st_mode = S_IFREG; … … 152 154 else 153 155 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 156 157 /* Mark .exe, .com, .cmd and .bat as executables. */ 158 if ((pStat->st_mode & (S_IFMT | ((S_IEXEC >> 6) * 0111))) == S_IFREG) 159 { 160 const char *pszExt = _getext(pszNativePath); 161 if ( pszExt++ 162 && strstr("exeExeEXeEXEExEeXeeXEexEcomComCOmCOMCoMcOmcOMcoMbatBatBAtBATBaTbAtbATbaTcmdCmdCMdCMDCmDcMdcMDcmD", 163 pszExt)) 164 pStat->st_mode |= (S_IEXEC >> 6) * 0111; 165 } 154 166 } 155 /** @todo rewrite this to check for the LIBC.MODE, LIBC.GID, 156 * LIBC.UID, LIBC.RDEV, LIBC.DEV and LIBC.INO EAs. 157 */ 158 /* default fake stuff */ 167 168 /* fake unix stuff */ 159 169 pStat->st_uid = 0; 160 170 pStat->st_gid = 0; … … 166 176 pStat->st_nlink = 1; 167 177 pStat->st_blksize = 4096 * 12; /* 48kb */ 178 /* If in unix mode we'll check the EAs (if any). */ 179 if ( !__libc_gfNoUnix 180 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 181 __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat); 168 182 169 183 LIBCLOG_MSG("st_dev: %#x\n", pStat->st_dev); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_ioFileOpen.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1533 r1534 180 180 if ( (ulAction == FILE_CREATED) 181 181 && !__libc_gfNoUnix) 182 __libc_back_fs SetUnixAttribs(hFile, NULL, Mode);182 __libc_back_fsUnixAttribsSet(hFile, NULL, Mode); 183 183 184 184 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filefind.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r1533 r1534 40 40 } 41 41 42 /* Build a `struct _find' structure from a FILEFINDBUF 3structure and42 /* Build a `struct _find' structure from a FILEFINDBUF4 structure and 43 43 move to the next one. */ 44 44 … … 54 54 { 55 55 const char *pch; 56 const FILEFINDBUF 3 *pFindbuf3;57 const FILEFINDBUF 3L *pFindbuf3L;56 const FILEFINDBUF4 *pFindbuf4; 57 const FILEFINDBUF4L *pFindbuf4L; 58 58 } u; 59 59 u.pch = pFD->pchNext; … … 76 76 * cbFile, cbFileAlloc, attrFile, cchName, achName. 77 77 */ 78 fp->time = XUSHORT(u.pFindbuf 3->ftimeLastWrite);79 fp->date = XUSHORT(u.pFindbuf 3->fdateLastWrite);78 fp->time = XUSHORT(u.pFindbuf4->ftimeLastWrite); 79 fp->date = XUSHORT(u.pFindbuf4->fdateLastWrite); 80 80 #if OFF_MAX > LONG_MAX 81 if (pFD->fType == FIL_STANDARDL) 82 { 83 fp->cbFile = u.pFindbuf3L->cbFile; 84 fp->attr = (unsigned char)u.pFindbuf3L->attrFile; 85 strcpy(fp->szName, &u.pFindbuf3L->achName[0]); 81 if (pFD->fType == FIL_QUERYEASIZEL) 82 { 83 fp->cbFile = u.pFindbuf4L->cbFile; 84 fp->attr = (unsigned char)u.pFindbuf4L->attrFile; 85 strcpy(fp->szName, &u.pFindbuf4L->achName[0]); 86 #if 0 //@todo DT_LNK 87 if (u.pFindbuf4L->cbList >= LIBC_UNIX_EA_MIN 88 && find_is_symlink(u.pFindbuf4L->achName)) 89 fp->attr |= 0xf0; 90 #endif 86 91 } 87 92 else 88 93 #endif 89 94 { 90 fp->cbFile = u.pFindbuf3->cbFile; 91 fp->attr = (unsigned char)u.pFindbuf3->attrFile; 92 strcpy(fp->szName, &u.pFindbuf3->achName[0]); 95 fp->cbFile = u.pFindbuf4->cbFile; 96 fp->attr = (unsigned char)u.pFindbuf4->attrFile; 97 strcpy(fp->szName, &u.pFindbuf4->achName[0]); 98 if (u.pFindbuf4L->cbList >= LIBC_UNIX_EA_MIN) 99 { 100 101 } 93 102 } 94 103 … … 96 105 * Next entry. 97 106 */ 98 if (pFD->cFiles && u.pFindbuf 3->oNextEntryOffset)99 { 100 pFD->pchNext = u.pch + u.pFindbuf 3->oNextEntryOffset;107 if (pFD->cFiles && u.pFindbuf4->oNextEntryOffset) 108 { 109 pFD->pchNext = u.pch + u.pFindbuf4->oNextEntryOffset; 101 110 pFD->cFiles--; 102 111 } … … 124 133 LIBCLOG_ENTER("pszName=%s attr=%#x fp=%p\n", pszName, attr, (void *)fp); 125 134 int rc; 126 int cch;135 char szNativePath[PATH_MAX]; 127 136 struct find_data *pFD = &__libc_threadCurrent()->b.sys.fd; 128 137 FS_VAR(); … … 131 140 * Rewrite the specified file path. 132 141 */ 133 cch = __libc_PathRewrite(pszName, NULL, 0); 134 if (cch > 0) 135 { 136 char *pszRewritten = alloca(cch); 137 if (!pszRewritten) 138 { 139 errno = ENOMEM; 140 LIBCLOG_RETURN_INT(-1); 141 } 142 cch = __libc_PathRewrite(pszName, pszRewritten, cch); 143 if (cch > 0) 144 pszName = pszRewritten; 145 /* else happens when someone changes the rules between the two calls. */ 146 else if (cch < 0) 147 { 148 errno = EAGAIN; /* non-standard, I'm sure. */ 149 LIBCLOG_RETURN_INT(-1); 150 } 142 rc = __libc_back_fsResolve(pszName, BACKFS_FLAGS_RESOLVE_FULL, &szNativePath[0], NULL); 143 if (rc) 144 { 145 errno = -rc; 146 return -1; 151 147 } 152 148 … … 171 167 pFD->cFiles = sizeof(pFD->achBuffer) / 40; 172 168 #if OFF_MAX > LONG_MAX 173 pFD->fType = __libc_gpfnDosOpenL ? FIL_ STANDARDL : FIL_STANDARD;174 if (pFD->fType == FIL_ STANDARDL) /* the L version is buggy!! Make sure there is enough space. */175 pFD->cFiles = sizeof(pFD->achBuffer) / sizeof(FILEFINDBUF 3L);169 pFD->fType = __libc_gpfnDosOpenL ? FIL_QUERYEASIZEL : FIL_QUERYEASIZE; 170 if (pFD->fType == FIL_QUERYEASIZEL) /* the L version is buggy!! Make sure there is enough space. */ 171 pFD->cFiles = sizeof(pFD->achBuffer) / sizeof(FILEFINDBUF4L); 176 172 #else 177 pFD->fType = FIL_ STANDARD;173 pFD->fType = FIL_QUERYEASIZE; 178 174 #endif 179 175 FS_SAVE_LOAD(); … … 234 230 { 235 231 pFD->cFiles = sizeof(pFD->achBuffer) / 40; 236 if (pFD->fType == FIL_ STANDARDL) /* the L version is buggy!! Make sure there is enough space. */237 pFD->cFiles = sizeof(pFD->achBuffer) / sizeof(FILEFINDBUF 3L);232 if (pFD->fType == FIL_QUERYEASIZEL) /* the L version is buggy!! Make sure there is enough space. */ 233 pFD->cFiles = sizeof(pFD->achBuffer) / sizeof(FILEFINDBUF4L); 238 234 FS_SAVE_LOAD(); 239 235 rc = DosFindNext(pFD->hdir, &pFD->achBuffer[0], sizeof(pFD->achBuffer), &pFD->cFiles); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1533 r1534 40 40 #include <errno.h> 41 41 #include <386/builtin.h> 42 #include <sys/stat.h> 42 43 #include <sys/fmutex.h> 43 44 #include <emx/startup.h> … … 84 85 85 86 /** Symlink EA name. */ 86 #define EA_SYMLINK "LIBC.SYMLINK" 87 88 /** Symlink ea name. */ 89 const char __libc_gszSymlinkEA[] = EA_SYMLINK; 87 #define EA_SYMLINK "LIBC.SYMLINK" 88 /** Symlink EA owner. */ 89 #define EA_UID "LIBC.UID" 90 /** Symlink EA group. */ 91 #define EA_GID "LIBC.GID" 92 /** Symlink EA mode. */ 93 #define EA_MODE "LIBC.MODE" 94 /** Symlink EA i-node number. */ 95 #define EA_INO "LIBC.INO" 96 /** Symlink EA rdev number. */ 97 #define EA_RDEV "LIBC.RDEV" 98 /** Symlink EA gen number. */ 99 #define EA_GEN "LIBC.GEN" 100 101 /** Symlink EA name. */ 102 static const char __libc_gszSymlinkEA[] = EA_SYMLINK; 103 /** UID EA name. */ 104 static const char __libc_gszUidEA[] = EA_UID; 105 /** GID EA name. */ 106 static const char __libc_gszGidEA[] = EA_GID; 107 /** Mode EA name. */ 108 static const char __libc_gszModeEA[] = EA_MODE; 109 /** Ino EA name. */ 110 static const char __libc_gszInoEA[] = EA_INO; 111 /** RDev EA name. */ 112 static const char __libc_gszRDevEA[] = EA_RDEV; 113 /** Gen(eration) EA name. */ 114 static const char __libc_gszGenEA[] = EA_GEN; 115 90 116 /* GEA2LIST Structure, just a bit more conveniently laid out.. */ 91 117 static const struct … … 95 121 BYTE cbName; 96 122 CHAR szName[sizeof(EA_SYMLINK)]; 97 } g SymlinkGEA2List=98 { 99 sizeof(g SymlinkGEA2List),123 } gGEA2ListSymlink = 124 { 125 sizeof(gGEA2ListSymlink), 100 126 0, 101 127 sizeof(EA_SYMLINK) - 1, 102 128 EA_SYMLINK 129 }; 130 131 /* GEA2LIST Structures, just a bit more conveniently laid out.. */ 132 static const struct GEA2LISTUNIXATTRIBS 133 { 134 ULONG cbList; 135 136 ULONG offSymlink; 137 BYTE cbSymlinkName; 138 CHAR szSymlinkName[sizeof(EA_SYMLINK)]; 139 140 ULONG offUID; 141 BYTE cbUIDName; 142 CHAR szUIDName[sizeof(EA_UID)]; 143 144 ULONG offGID; 145 BYTE cbGIDName; 146 CHAR szGIDName[sizeof(EA_GID)]; 147 148 ULONG offMode; 149 BYTE cbModeName; 150 CHAR szModeName[sizeof(EA_MODE)]; 151 152 ULONG offINO; 153 BYTE cbINOName; 154 CHAR szINOName[sizeof(EA_INO)]; 155 156 ULONG offRDev; 157 BYTE cbRDevName; 158 CHAR szRDevName[sizeof(EA_RDEV)]; 159 160 ULONG offGen; 161 BYTE cbGenName; 162 CHAR szGenName[sizeof(EA_GEN)]; 163 } gGEA2ListUnixAttribs = 164 { 165 sizeof(gGEA2ListUnixAttribs), 166 offsetof(struct GEA2LISTUNIXATTRIBS, offUID) - offsetof(struct GEA2LISTUNIXATTRIBS, offSymlink), sizeof(EA_SYMLINK) - 1, EA_SYMLINK, 167 offsetof(struct GEA2LISTUNIXATTRIBS, offGID) - offsetof(struct GEA2LISTUNIXATTRIBS, offUID), sizeof(EA_UID) - 1, EA_UID, 168 offsetof(struct GEA2LISTUNIXATTRIBS, offMode) - offsetof(struct GEA2LISTUNIXATTRIBS, offGID), sizeof(EA_GID) - 1, EA_GID, 169 offsetof(struct GEA2LISTUNIXATTRIBS, offINO) - offsetof(struct GEA2LISTUNIXATTRIBS, offMode), sizeof(EA_MODE) - 1, EA_MODE, 170 offsetof(struct GEA2LISTUNIXATTRIBS, offRDev) - offsetof(struct GEA2LISTUNIXATTRIBS, offINO), sizeof(EA_INO) - 1, EA_INO, 171 offsetof(struct GEA2LISTUNIXATTRIBS, offGen) - offsetof(struct GEA2LISTUNIXATTRIBS, offRDev), sizeof(EA_RDEV) - 1, EA_RDEV, 172 0, sizeof(EA_GEN) - 1, EA_GEN 103 173 }; 104 174 … … 316 386 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); 317 387 EAOP2 EaOp; 318 EaOp.fpGEA2List = (PGEA2LIST)&g SymlinkGEA2List;388 EaOp.fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink; 319 389 EaOp.fpFEA2List = (PFEA2LIST)pachBuffer; 320 390 EaOp.oError = 0; … … 749 819 */ 750 820 int cchTmp = __libc_PathRewrite(pszUserPath, szTmp, sizeof(szTmp)); 751 if (cchTmp )821 if (cchTmp > 0) 752 822 { 753 823 /* … … 968 1038 { 969 1039 EAOP2 EaOp; 970 EaOp.fpGEA2List = (PGEA2LIST)&g SymlinkGEA2List;1040 EaOp.fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink; 971 1041 EaOp.fpFEA2List = (PFEA2LIST)pachBuffer; 972 1042 EaOp.oError = 0; … … 1140 1210 * @param hFile File handle to the newly created fs object. If no 1141 1211 * handle handy, set to -1. 1142 * @param pszNativePath Native path ofthe newly created fs object. If1212 * @param pszNativePath Native path to the newly created fs object. If 1143 1213 * handle is give this will be ignored. 1144 1214 * @param mode The specified file permission mode mask. 1145 1215 */ 1146 int __libc_back_fs SetUnixAttribs(int hFile, const char *pszNativePath, mode_t mode)1216 int __libc_back_fsUnixAttribsSet(int hFile, const char *pszNativePath, mode_t mode) 1147 1217 { 1148 1218 /* later */ … … 1150 1220 } 1151 1221 1222 /** 1223 * Reads the unix EAs for a file which is being stat'ed. 1224 * 1225 * @returns 0 on success. 1226 * @returns Negative errno on failure. 1227 * @param hFile File handle to the fs object. If no handle handy, set to -1. 1228 * @param pszNativePath Native path to the fs object. If handle is give this will be ignored. 1229 * @param pStat Pointer to the stat buffer. 1230 * The buffer is only updated if and with the EAs we find, 1231 * so the caller must fill the fields with defaults before 1232 * calling this function. 1233 */ 1234 int __libc_back_fsUnixAttribsGet(int hFile, const char *pszNativePath, struct stat *pStat) 1235 { 1236 LIBCLOG_ENTER("hFile=%d pszNativePath=%p:{%s} pStat=%p\n", hFile, (void *)pszNativePath, pszNativePath, (void *)pStat); 1237 1238 /* Try come up with an accurate max estimate of a maximum result. */ 1239 char achBuffer[sizeof(gGEA2ListUnixAttribs) + 7 * (sizeof(USHORT) * 2 + sizeof(BYTE)) + CCHMAXPATH + 6 * sizeof(uint32_t) + 0x30]; 1240 char *pachBuffer = (char *)((uintptr_t)&achBuffer[3] & ~3); 1241 EAOP2 EaOp2; 1242 int rc; 1243 1244 /* 1245 * Issue the query. 1246 */ 1247 EaOp2.fpGEA2List = (PGEA2LIST)&gGEA2ListUnixAttribs; 1248 EaOp2.fpFEA2List = (PFEA2LIST)pachBuffer; 1249 EaOp2.oError = 0; 1250 EaOp2.fpFEA2List->cbList = sizeof(achBuffer) - 4; 1251 if (hFile >= 0) 1252 rc = DosQueryFileInfo(hFile, FIL_QUERYEASFROMLIST, &EaOp2, sizeof(EaOp2)); 1253 else 1254 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp2, sizeof(EaOp2)); 1255 if (rc) 1256 { 1257 LIBC_ASSERTM_FAILED("Bogus EAs? rc=%d oError=%ld\n", rc, EaOp2.oError); 1258 rc = -__libc_native2errno(rc); 1259 LIBCLOG_RETURN_INT(rc); 1260 } 1261 if (EaOp2.fpFEA2List->cbList < LIBC_UNIX_EA_MIN) 1262 LIBCLOG_RETURN_INT(rc); 1263 1264 /* 1265 * Parse the result. 1266 */ 1267 PFEA2 pFea2 = &EaOp2.fpFEA2List->list[0]; 1268 for (;;) 1269 { 1270 if (pFea2->cbValue > 0) 1271 { 1272 #define COMPARE_EANAME(name) (pFea2->cbName == sizeof(name) - 1 && !memcmp(name, pFea2->szName, sizeof(name) - 1)) 1273 if (COMPARE_EANAME(__libc_gszSymlinkEA)) 1274 pStat->st_mode = (pStat->st_mode & ~S_IFMT) | S_IFLNK; 1275 else 1276 { 1277 PUSHORT pusType = (PUSHORT)((char *)pFea2 + pFea2->cbName); 1278 if (pusType[0] == EAT_BINARY && pusType[1] == sizeof(uint32_t)) 1279 { 1280 uint32_t u32 = *(uint32_t *)&pusType[2]; 1281 if (COMPARE_EANAME(__libc_gszUidEA)) 1282 pStat->st_uid = u32; 1283 else if (COMPARE_EANAME(__libc_gszGidEA)) 1284 pStat->st_gid = u32; 1285 else if (COMPARE_EANAME(__libc_gszModeEA)) 1286 pStat->st_mode = u32; 1287 else if (COMPARE_EANAME(__libc_gszInoEA)) 1288 pStat->st_ino = u32; 1289 else if (COMPARE_EANAME(__libc_gszRDevEA)) 1290 pStat->st_rdev = u32; 1291 else if (COMPARE_EANAME(__libc_gszGenEA)) 1292 /* pStat->st_gen = u32 - not implemented */; 1293 else 1294 LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d!\n", pFea2->szName, pFea2->cbName); 1295 } 1296 else 1297 LIBC_ASSERTM_FAILED("Invalid LIBC EA! %s type=%#x len=%#x, expected type=%#x and len=%#x.\n", 1298 pFea2->szName, pusType[0], pusType[1], EAT_BINARY, sizeof(uint32_t)); 1299 } 1300 #undef COMPARE_EANAME 1301 } 1302 1303 /* next */ 1304 if (pFea2->oNextEntryOffset <= sizeof(FEA2)) 1305 break; 1306 pFea2 = (PFEA2)((uintptr_t)pFea2 + pFea2->oNextEntryOffset); 1307 } 1308 1309 LIBCLOG_RETURN_INT(0); 1310 } 1311 1312 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1533 r1534 46 46 /** The current umask of the process. */ 47 47 extern mode_t __libc_gfsUMask; 48 49 /** The minimum EA size of a file for it to possibly contain any LIBC Unix EAs. */ 50 #define LIBC_UNIX_EA_MIN (1 + 1 + 2 + sizeof("LIBC.???") + 2 + 2 + sizeof(uint32_t)) 51 48 52 49 53 #ifdef _OS2EMX_H … … 132 136 * @param mode The specified file permission mode mask. 133 137 */ 134 int __libc_back_fsSetUnixAttribs(int hFile, const char *pszNativePath, mode_t mode); 138 int __libc_back_fsUnixAttribsSet(int hFile, const char *pszNativePath, mode_t mode); 139 140 /** 141 * Reads the unix EAs for a file which is being stat'ed. 142 * 143 * @returns 0 on success. 144 * @returns Negative errno on failure. 145 * @param hFile File handle to the fs object. If no handle handy, set to -1. 146 * @param pszNativePath Native path to the fs object. If handle is give this will be ignored. 147 * @param pStat Pointer to the stat buffer. 148 * The buffer is only updated if and with the EAs we find, 149 * so the caller must fill the fields with defaults before 150 * calling this function. 151 */ 152 int __libc_back_fsUnixAttribsGet(int hFile, const char *pszNativePath, struct stat *pStat); 135 153 136 154 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.