mirror of
https://git.openafs.org/openafs.git
synced 2025-02-01 05:57:43 +00:00
STABLE14-getcellunix-use-stdio-again-20060925
i have no idea why this is so ugly. put it back to something like how it was. (cherry picked from commit 2201fd6d9ff41506c1bc60d677ae268a1de42fbc)
This commit is contained in:
parent
1c0f071de6
commit
f566dca39c
@ -478,28 +478,22 @@ GetCellUnix(struct afsconf_dir *adir)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
char tbuffer[256];
|
char tbuffer[256];
|
||||||
int fd;
|
char *p;
|
||||||
|
afsconf_FILE *fp;
|
||||||
|
|
||||||
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
|
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
|
||||||
fd = open(tbuffer, O_RDONLY, 0);
|
fp = fopen(tbuffer, "r");
|
||||||
if (fd < 0) {
|
if (fp == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
int sz;
|
|
||||||
|
|
||||||
memset(tbuffer, 0, 256);
|
|
||||||
sz = read(fd, tbuffer, 255);
|
|
||||||
close(fd);
|
|
||||||
if (sz > 0) {
|
|
||||||
char *p = strchr(tbuffer, '\n');
|
|
||||||
if (p)
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
adir->cellName = (char *)malloc(sz + 1);
|
|
||||||
memset(adir->cellName, 0, sz+1);
|
|
||||||
strncpy(adir->cellName, tbuffer, sz);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
rc = fgets(tbuffer, 256, fp);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
p = strchr(tbuffer, '\n');
|
||||||
|
if (p)
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
adir->cellName = strdup(tbuffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user