Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
handle toplevel directories
Browse files Browse the repository at this point in the history
  • Loading branch information
dividuum committed Sep 29, 2012
1 parent 5dcb046 commit 0904cff
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main.c
Expand Up @@ -1348,13 +1348,19 @@ int main(int argc, char *argv[]) {
die("cannot canonicalize path: %s", strerror(errno));

char *split = rindex(root_name, '/');
if (split) {
*split = '\0';
fprintf(stderr, INFO("chdir %s\n"), root_name);
if (chdir(root_name) == -1)
die("cannot chdir(%s): %s", root_name, strerror(errno));
root_name = split+1;
}
if (!split)
die("no slashes in target path. cannot continue");

*split = '\0';
if (*root_name == '\0')
root_name = "/";

fprintf(stderr, INFO("chdir %s\n"), root_name);
if (chdir(root_name) == -1)
die("cannot chdir(%s): %s", root_name, strerror(errno));

root_name = split+1;
fprintf(stderr, INFO("root node is %s\n"), root_name);

inotify_fd = inotify_init1(IN_NONBLOCK);
if (inotify_fd == -1)
Expand Down

0 comments on commit 0904cff

Please sign in to comment.