+ struct lockfile *a, *dummy;
+ struct stat s;
+
+ /* Create a symlink "a" pointing to "dir/b". */
+ CHECK(mkdir("dir", 0700), 0);
+ CHECK(symlink("dir/b", "a"), 0);
+ CHECK(lstat("a", &s), 0);
+ CHECK(S_ISLNK(s.st_mode) != 0, 1);
+
+ /* Lock 'a'. */
+ CHECK(lockfile_lock("a", &a), 0);
+ CHECK(lstat("dir/.b.~lock~", &s), 0);
+ CHECK(S_ISREG(s.st_mode) != 0, 1);
+ CHECK(lstat(".a.~lock~", &s), -1);
+ CHECK(errno, ENOENT);
+ CHECK(lockfile_lock("dir/b", &dummy), EDEADLK);