mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
getcellunix-use-stdio-again-20060925
i have no idea why this is so ugly. put it back to something like how it was.
This commit is contained in:
parent
c1d3a69976
commit
2201fd6d9f
@ -478,28 +478,22 @@ GetCellUnix(struct afsconf_dir *adir)
|
||||
{
|
||||
int rc;
|
||||
char tbuffer[256];
|
||||
int fd;
|
||||
char *p;
|
||||
afsconf_FILE *fp;
|
||||
|
||||
strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL);
|
||||
fd = open(tbuffer, O_RDONLY, 0);
|
||||
if (fd < 0) {
|
||||
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);
|
||||
}
|
||||
fp = fopen(tbuffer, "r");
|
||||
if (fp == 0) {
|
||||
return -1;
|
||||
}
|
||||
rc = fgets(tbuffer, 256, fp);
|
||||
fclose(fp);
|
||||
|
||||
p = strchr(tbuffer, '\n');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
|
||||
adir->cellName = strdup(tbuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user