version 1.4, 1996/09/02 16:04:21 |
version 1.5, 1996/11/30 21:09:06 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: util.c,v 1.5 1995/11/22 17:40:17 christos Exp $ */ |
/* $NetBSD: util.c,v 1.9 1996/11/11 15:16:10 christos Exp $ */ |
|
|
/* |
/* |
* Missing stuff from OS's |
* Missing stuff from OS's |
* |
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
|
|
extern char *sys_errlist[]; |
extern char *sys_errlist[]; |
|
|
char * |
char * |
strerror(e) |
strerror(e) |
int e; |
int e; |
{ |
{ |
static char buf[100]; |
static char buf[100]; |
if (e < 0 || e >= sys_nerr) { |
if (e < 0 || e >= sys_nerr) { |
|
|
const char *str; |
const char *str; |
{ |
{ |
size_t len; |
size_t len; |
|
char *p; |
|
|
if (str == NULL) |
if (str == NULL) |
return NULL; |
return NULL; |
|
|
|
|
int |
int |
setenv(name, value, dum) |
setenv(name, value, dum) |
const char *name; |
const char *name; |
const char *value; |
const char *value; |
int dum; |
int dum; |
{ |
{ |
|
|
|
|
if (ptr == NULL) |
if (ptr == NULL) |
return -1; |
return -1; |
|
|
p = ptr; |
p = ptr; |
|
|
while (*name) |
while (*name) |
*p++ = *name++; |
*p++ = *name++; |
|
|
*p++ = '='; |
*p++ = '='; |
|
|
while (*value) |
while (*value) |
*p++ = *value++; |
*p++ = *value++; |
|
|
*p = '\0'; |
*p = '\0'; |
|
|
/* look in the parent for the entry with the same inode */ |
/* look in the parent for the entry with the same inode */ |
if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) { |
if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) { |
/* Parent has same device. No need to stat every member */ |
/* Parent has same device. No need to stat every member */ |
for (d = readdir(dp); d != NULL; d = readdir(dp)) |
for (d = readdir(dp); d != NULL; d = readdir(dp)) |
if (d->d_fileno == st_cur.st_ino) |
if (d->d_fileno == st_cur.st_ino) |
break; |
break; |
} |
} |
else { |
else { |
/* |
/* |
* Parent has a different device. This is a mount point so we |
* Parent has a different device. This is a mount point so we |
* need to stat every member |
* need to stat every member |
*/ |
*/ |
for (d = readdir(dp); d != NULL; d = readdir(dp)) { |
for (d = readdir(dp); d != NULL; d = readdir(dp)) { |
if (ISDOT(d->d_name) || ISDOTDOT(d->d_name)) |
if (ISDOT(d->d_name) || ISDOTDOT(d->d_name)) |
|
|
} |
} |
/* check if we found it yet */ |
/* check if we found it yet */ |
if (st_next.st_ino == st_cur.st_ino && |
if (st_next.st_ino == st_cur.st_ino && |
DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev)) |
DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev)) |
break; |
break; |
} |
} |
} |
} |