61,11 → 61,11 |
int fd; |
|
fd = open(f, O_RDONLY); |
if (fd > 0) { |
if (fd > -1) { |
close(fd); |
return 1; |
return 0; |
} else |
return 0; |
return -1; |
} |
|
/* Returns the full path of "cmd" if cmd is found, else just hand back |
74,15 → 74,20 |
{ |
char *path_orig, *path_tok; |
char *path[PATH_MAX]; |
int rc, n = 0, i = 0; |
int n = 0, i = 0; |
size_t x = strlen(cmd) + 2; |
|
found = (char *)malloc(PATH_MAX); |
|
/* The user has specified the full path, just give it back. Don't test it, |
* they seem to know what they're doing. */ |
if (cmd[0] == '/' || cmd [0] == '.') |
return (char *)cmd; |
/* The user has specified a full or relative path, just give it back. */ |
#ifdef HELENOS |
if (-1 != try_access(cmd)) |
#else |
if (-1 != access(cmd, F_OK)) |
#endif |
{ |
return (char *) cmd; |
} |
|
#ifdef HELENOS |
path_orig = PATH; |
111,12 → 116,11 |
memset(found, 0, sizeof(found)); |
snprintf(found, PATH_MAX, "%s/%s", path[i], cmd); |
#ifdef HELENOS |
rc = try_access(found); |
if (-1 != try_access(found)) |
#else |
rc = access(found, F_OK); |
if (-1 != access(found, F_OK)) |
#endif |
if (rc >= 0) { |
/* We found it */ |
{ |
free(path_tok); |
return (char *) found; |
} |
185,11 → 189,6 |
|
free(tmp); |
|
/* No need to go any further if status == 0 */ |
/* |
if (status == 0) |
return status; |
*/ |
/* Decode any errors from execv() (these explain themselves) */ |
switch (status) { |
case ENOTDIR: |