1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | #include <mach.h> |
23 | #include <stdio.h> |
24 | #include <hurd/hurd_types.h> |
25 | #include <hurd/fs.h> |
26 | #include <hurd/io.h> |
27 | #include <hurd.h> |
28 | #include <fcntl.h> |
29 | #include <errno(*__errno_location ()).h> |
30 | #include <error.h> |
31 | #include <unistd.h> |
32 | |
33 | int check_refs (mach_port_t port) |
34 | { |
35 | int err; |
36 | mach_port_urefs_t refs; |
37 | err = mach_port_get_refs (mach_task_self ()((__mach_task_self_ + 0)), |
38 | port, MACH_PORT_RIGHT_SEND((mach_port_right_t) 0), &refs); |
39 | return err ? -err : refs; |
40 | } |
41 | |
42 | int |
43 | main () |
44 | { |
45 | mach_port_t root; |
46 | #if HURDISH_TESTS |
47 | extern file_t *_hurd_init_dtable; |
48 | char string[] = "Did this get into the file?\n"; |
49 | file_t filetowrite; |
50 | retry_type retry; |
51 | char pathbuf[1024]; |
52 | int written; |
53 | error_t err; |
54 | #endif |
55 | |
56 | root = getcrdir (); |
57 | |
58 | printf ("fstests running...\n"); |
59 | |
60 | #if HURDISH_TESTS |
61 | if ((err = dir_unlink (root, "CREATED")) && err != ENOENT((0x10 << 26) | ((2) & 0x3fff))) |
62 | error (0, err, "Error on unlink"); |
63 | else if (err = dir_lookup (root, "CREATED", O_WRITE0x0002 | O_CREAT0x0010, 0666, |
64 | &retry, pathbuf, &filetowrite)) |
65 | error (0, err, "Error on lookup"); |
66 | else if (err = io_write (filetowrite, string, strlen (string), -1, &written)) |
67 | error (0, err, "Error on write"); |
68 | else if (written != strlen (string)) |
69 | error (0, 0, "Short write: %d\n", written); |
70 | else if (err = file_syncfs (filetowrite, 1, 0)) |
71 | error (0, err, "Error on sync"); |
72 | #else |
73 | |
74 | if (unlink ("/newdir")) |
| |
75 | error (0, errno(*__errno_location ()), "unlink"); |
76 | if (rmdir ("/newdir")) |
| |
77 | error (0, errno(*__errno_location ()), "1st rmdir"); |
78 | if (mkdir ("/newdir", 0777)) |
| |
79 | error (0, errno(*__errno_location ()), "1st mkdir"); |
80 | if (rename ("/newdir", "/newdir2")) |
| |
81 | error (0, errno(*__errno_location ()), "1st rename"); |
82 | if (rmdir ("/foo")) |
| |
83 | error (0, errno(*__errno_location ()), "2nd rmdir"); |
84 | if (mkdir ("/foo", 0777)) |
| |
85 | error (0, errno(*__errno_location ()), "2nd mkdir"); |
86 | if (rename ("/newdir2", "/foo")) |
| |
87 | error (0, errno(*__errno_location ()), "2nd rename"); |
88 | sync (); |
89 | #endif |
90 | |
91 | printf ("All done.\n"); |
92 | malloc (0); |
| 8 | | Call to 'malloc' has an allocation size of 0 bytes |
|
93 | |
94 | return 0; |
95 | } |