- Timestamp:
- Oct 24, 2014, 12:49:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/src/kNIX/os2/fs-os2.c
r3861 r3911 217 217 { 218 218 LIBCLOG_ENTER("\n"); 219 APIRET rc; 219 220 /** @todo getenv doesn't work at this point. :( */ 220 221 … … 262 263 if (pInherit) 263 264 __libc_spmInheritRelease(); 265 264 266 /* 265 267 * Setup unofficial unixroot. 266 268 */ 267 269 const char *psz = getenv("UNIXROOT"); 268 if (psz) 270 if ( psz 271 && ((psz[0] >= 'A' && psz[0] <= 'Z') || (psz[0] >= 'a' && psz[0] <= 'z')) 272 && psz[1] == ':' 273 && (psz[2] == '\\' || psz[2] == '/') 274 ) 269 275 { 270 276 LIBCLOG_MSG("Unofficial unixroot=%s\n", psz); … … 276 282 } 277 283 memcpy(&__libc_gszUnixRoot[0], psz, cch + 1); 284 285 /* Clean it up a tiny little bit. */ 286 if (__libc_gszUnixRoot[0] >= 'a') 287 __libc_gszUnixRoot[0] -= 'a' - 'A'; 288 289 size_t off = cch; 290 while (off-- > 0) 291 if (__libc_gszUnixRoot[off] == '\\') 292 __libc_gszUnixRoot[off] = '/'; 278 293 279 294 /* Register the rewrite rule. */ … … 281 296 if (__libc_PathRewriteAdd(&gUnixRootRewriteRule, 1)) 282 297 LIBCLOG_RETURN_INT(-1); 283 } 298 299 /* Should we pretend chroot($UNIXROOT) + chdir()? */ 300 psz = getenv("UNIXROOT_CHROOTED"); 301 if (psz && *psz != '\0') 302 { 303 __libc_gcchUnixRoot = cch; 304 305 ULONG ulDisk, ulIgnored; 306 rc = DosQueryCurrentDisk(&ulDisk, &ulIgnored); 307 if ( rc == NO_ERROR 308 && ulDisk + 'A' - 1 == __libc_gszUnixRoot[0]) 309 { 310 if (cch == 3) 311 __libc_gfInUnixTree = 1; 312 else 313 { 314 char szCurDir[PATH_MAX]; 315 ULONG cbCurDir = sizeof(szCurDir); 316 rc = DosQueryCurrentDir(0, (PSZ)&szCurDir[0], &cbCurDir); 317 __libc_gfInUnixTree = rc == NO_ERROR 318 && cch <= cbCurDir + 3 319 && memicmp(&__libc_gszUnixRoot[3], szCurDir, cch - 3) == 0 320 && ( cch == cbCurDir + 3 321 || szCurDir[cch - 3] == '\\'); 322 } 323 324 } 325 LIBCLOG_MSG(__libc_gfInUnixTree ? "Inside unixroot chroot.\n" : "Outside unixroot chroot.\n"); 326 } 327 } 328 else if (psz) 329 LIBCLOG_MSG("Invalid UNIXROOT=\"%s\" - must start with drive letter and root slash.\n", psz); 284 330 } 285 331 … … 291 337 PPIB pPib; 292 338 DosGetInfoBlocks(&pTib, &pPib); 293 APIRETrc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]);339 rc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]); 294 340 if (!rc) 295 341 {
Note:
See TracChangeset
for help on using the changeset viewer.