From: Nickolai Zeldovich Date: Wed, 28 Aug 2002 04:53:33 +0000 (+0000) Subject: Make "fs newcell" work even when there are no pre-existing cells in X-Git-Tag: openafs-stable-1_2_7~25 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d3419a47695eb796f0731bf70b39182a6fee49e9;p=packages%2Fo%2Fopenafs.git Make "fs newcell" work even when there are no pre-existing cells in the kernel yet. Previously, newcell tried to issue a GetCell pioctl to figure out what version of the pioctl interface the kernel is using. Lacking such information (if the pioctl returns an error), we now assume the newer interface. (cherry picked from commit f840143cd6b672858e121a0fb3dea5e12cb60f84) --- diff --git a/src/venus/fs.c b/src/venus/fs.c index dbc27cd98..ac7156fae 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1909,6 +1909,8 @@ static NewCellCmd(as) * MAXCELLHOSTS (8) servers. To determine which we are talking to, * do a GETCELL pioctl and pass it a magic number. If an array of * 8 comes back, its a 3.5 client. If not, its a 3.4 client. + * If we get back EDOM, there are no cells in the kernel yet, + * and we'll assume a 3.5 client. */ tp = space; lp = (afs_int32 *)tp; @@ -1919,13 +1921,17 @@ static NewCellCmd(as) blob.in = space; blob.out = space; code = pioctl(0, VIOCGETCELL, &blob, 1); - if (code < 0) { + if (code < 0 && errno != EDOM) { Die(errno, 0); return 1; } - tp = space; - cellname = tp + MAXCELLHOSTS*sizeof(afs_int32); - scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS); + if (code < 1 && errno == EDOM) { + scount = MAXHOSTS; + } else { + tp = space; + cellname = tp + MAXCELLHOSTS*sizeof(afs_int32); + scount = ((cellname[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS); + } /* Now setup and do the NEWCELL pioctl call */ memset(space, 0, (scount+1) * sizeof(afs_int32));