Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

48 UNIX Standardization and Implementations Chapter 2


err_sys("sysconf error");
}else {
fputs(" (no limit)\n", stdout);
}
}else {
printf(" %ld\n", val);
}
}
static void
pr_pathconf(char *mesg, char *path, int name)
{
long val;
fputs(mesg, stdout);
errno = 0;
if ((val = pathconf(path, name)) < 0) {
if (errno != 0) {
if (errno == EINVAL)
fputs(" (not supported)\n", stdout);
else
err_sys("pathconf error, path = %s", path);
}else {
fputs(" (no limit)\n", stdout);
}
}else {
printf(" %ld\n", val);
}
}

Figure 2.14 Print all possiblesysconfandpathconfvalues

Figure2.15 summarizes the results from Figure2.14 for the four systems we discuss in
this book. The entry ‘‘no symbol’’means that the system doesn’t provide a
corresponding_SCor_PCsymbol to query the value of the constant. Thus the limit is
undefined in this case. In contrast, the entry ‘‘unsupported’’means that the symbol is
defined by the system but unrecognized by thesysconforpathconffunctions. The
entry ‘‘no limit’’means that the system defines no limit for the constant, but this doesn’t
mean that the limit is infinite; it just means that the limit is indeterminite.

Bewarethat some limits arereported incorrectly.For example, on Linux,SYMLOOP_MAXis
reportedly unlimited, but an examination of the source code reveals that there is actually a
hard-coded limit of 40 for the number of consecutive symbolic links traversed in the absence of
aloop (see thefollow_linkfunction infs/namei.c).
Another potential source of inaccuracy in Linux is that thepathconfandfpathconf
functions areimplemented in the C library.The configuration limits returned by these
functions depend on the underlying file system type, so if your file system is unknown to the
Clibrary,the functions return an educated guess.

We’ll see in Section 4.14 thatUFSis the SVR4 implementation of the Berkeley fast
file system. PCFS is the MS-DOS FAT file system implementation for Solaris.
Free download pdf