- /* Try a 1-microsecond sleep first, for speed. If that doesn't
- work, try a 1 ms sleep; that should work with ext. If it doesn't
- work, try a 20 ms sleep. xfs has a quantization of about 10
- milliseconds, even though it has a granularity of 1 nanosecond,
- and NTFS has a default quantization of 15.25 milliseconds, even
- though it has a granularity of 100 nanoseconds, so 20 ms is a
- good quantization to try. If that doesn't work, try 1 second.
- The worst case is 2 seconds, needed for FAT. */
- static int const delaytab[] = {1, 1000, 20000, 1000000 };
- int fd = creat (BASE "tmp", 0600);
- int i;
- int delay = 2000000;
- struct stat st;
- ASSERT (0 <= fd);
- get_mtime (fd, &st, 0);
- for (i = 0; i < sizeof delaytab / sizeof delaytab[0]; i++)
- if (nap_works (fd, delaytab[i], &st))
- {
- delay = delaytab[i];
- break;
- }
- ASSERT (close (fd) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- return delay;