Bug#1008507:
/* reproduce glibc bug */
/*
* I don't typically care what the return of pathconf(..., _PC_LINK_MAX)
* is; I just care whether or not it's greater than 1 because I'm checking
* whether the filesystem supports hard links or not.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
int main()
{
char file[40];
char dir[40];
char commandbuf[120];
sprintf(file, "/tmp/%u.img", getpid());
sprintf(dir, "/tmp/%u.mnt", getpid());
FILE *fimage = fopen(file, "wb");
fseek(fimage, 1440 * 1024 - 1, SEEK_SET);
fputc(0, fimage);
fclose(fimage);
mkdir(dir, 0);
sprintf(commandbuf, "mkfs.fat /tmp/%u.img", getpid());
if (system(commandbuf) != 0) {
rmdir(dir);
unlink(file);
return 1;
}
sprintf(commandbuf, "mount -o loop -t msdos %s %s", file, dir);
if (system(commandbuf) != 0) {
rmdir(dir);
unlink(file);
return 1;
}
int r;
printf("Testing pathconf(%s, _PC_LINK_MAX)...");
r = pathconf(dir, _PC_LINK_MAX) != 1;
printf(r ? "Failed\n" : "OK\n");
sprintf(commandbuf, "umount %s", dir);
system(commandbuf);
rmdir(dir);
unlink(file);
return r;
}
Reply to: