Revision 5047,
1.6 KB
checked in by jik, 34 years ago
(diff) |
Need to use a bigger number when writing the test file, to accomodate machines
that have a large maximum block size but that still represent st_blocvks
properly.
|
Line | |
---|
1 | cd ${TMPDIR-/tmp} |
---|
2 | |
---|
3 | cat >test$$.c <<PROGRAM_IS_DONE |
---|
4 | #include <sys/types.h> |
---|
5 | #include <sys/stat.h> |
---|
6 | #include <sys/file.h> |
---|
7 | #include <stdio.h> |
---|
8 | |
---|
9 | main() |
---|
10 | { |
---|
11 | struct stat statbuf; |
---|
12 | char buf[4096]; |
---|
13 | int testfile; |
---|
14 | char filename[20]; |
---|
15 | |
---|
16 | sprintf(filename, "test%d.out", getppid()); |
---|
17 | |
---|
18 | testfile = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644); |
---|
19 | if (testfile < 0) { |
---|
20 | fprintf(stderr, "Could not open temporary file \"%s\".\n", filename); |
---|
21 | exit(1); |
---|
22 | } |
---|
23 | |
---|
24 | if (write(testfile, buf, sizeof(buf)) != sizeof(buf)) { |
---|
25 | fprintf(stderr, "Could not write all data to file \"%s\".\n", |
---|
26 | filename); |
---|
27 | exit(1); |
---|
28 | } |
---|
29 | |
---|
30 | if (close(testfile) < 0) { |
---|
31 | fprintf(stderr, "Error closing \"%s\".\n", filename); |
---|
32 | exit(1); |
---|
33 | } |
---|
34 | |
---|
35 | if (stat(filename, &statbuf) < 0) { |
---|
36 | fprintf(stderr, "Could not stat file \"%s\".\n", filename); |
---|
37 | exit(1); |
---|
38 | } |
---|
39 | |
---|
40 | if (statbuf.st_blocks == sizeof(buf) / 512) { |
---|
41 | printf("You SHOULD define USE_BLOCKS.\n"); |
---|
42 | } |
---|
43 | else { |
---|
44 | printf("You SHOULD NOT define USE_BLOCKS.\n"); |
---|
45 | printf("However, you have an interesting machine that delete might be made to work\nbetter with. Please contact the author (see the README file for an address)\nand tell him what kind of machine you have and what operating system it is\nrunning.\n"); |
---|
46 | } |
---|
47 | exit(0); |
---|
48 | } |
---|
49 | PROGRAM_IS_DONE |
---|
50 | |
---|
51 | |
---|
52 | if ${CC-cc} -o test$$ test$$.c 2>&1 >/dev/null; then |
---|
53 | if ./test$$; then : ; |
---|
54 | else |
---|
55 | echo "Test program did not succeed." |
---|
56 | echo "This means you probably shouldn't define USE_BLOCKS." |
---|
57 | fi |
---|
58 | else |
---|
59 | echo "Could not compile test program." |
---|
60 | echo "This means you probably shouldn't define USE_BLOCKS." |
---|
61 | fi |
---|
62 | |
---|
63 | |
---|
64 | rm test$$* |
---|
65 | exit 0 |
---|
Note: See
TracBrowser
for help on using the repository browser.