[uclibc-ng-devel] about "implement fexecve from glibc"
ysionneau at kalray.eu
Wed Nov 6 11:27:09 CET 2019
I'm not sure why exactly sizeof(int)*3 in the following line:
char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3];
IIUC, this is supposed to give room for the ascii decimal representation
of the file descriptor number.
Maybe we could read the max file descriptor number configured in the
kernel from "/proc/sys/fs/file-max" (or "/proc/sys/file-max" for old
1/ fopen("/proc/sys/fs/file-max", "r");
2/ fscanf(fp, "%d", &fdmax);
3/ fdmax_length = log10(fdmax);
Then use fdmax_length
Or, much simpler: take for granted that fd is always an int, and thus
max 32 bits, and hard code that max "string length" of a file descriptor
is 10 chars.
But in any case maybe add a comment on top of the line to explain the
More information about the devel