X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Freadahead-collect.c;h=ea07b3ff4978bfddff78a4033856e95a1355a101;hb=4dba533a137486719fb385c45fc2ff75593fdf53;hp=5c09f7a9e1df140b29f61585506476cacf7bbc19;hpb=d9c7a87b35289e9a5ba94c097e861640d1357e6d;p=elogind.git diff --git a/src/readahead-collect.c b/src/readahead-collect.c index 5c09f7a9e..ea07b3ff4 100644 --- a/src/readahead-collect.c +++ b/src/readahead-collect.c @@ -92,6 +92,13 @@ static int pack_file(FILE *pack, const char *fn, bool on_btrfs) { assert(fn); if ((fd = open(fn, O_RDONLY|O_CLOEXEC|O_NOATIME|O_NOCTTY|O_NOFOLLOW)) < 0) { + + if (errno == ENOENT) + return 0; + + if (errno == EPERM || errno == EACCES) + return 0; + log_warning("open(%s) failed: %m", fn); r = -errno; goto finish; @@ -398,8 +405,8 @@ static int collect(const char *root) { char_array_0(fn); if ((k = readlink_malloc(fn, &p)) >= 0) { - if (startswith(p, "/tmp") || + endswith(p, " (deleted)") || hashmap_get(files, p)) /* Not interesting, or * already read */ @@ -435,7 +442,7 @@ done: on_ssd = fs_on_ssd(root) > 0; log_debug("On SSD: %s", yes_no(on_ssd)); - on_btrfs = statfs(root, &sfs) >= 0 && sfs.f_type == BTRFS_SUPER_MAGIC; + on_btrfs = statfs(root, &sfs) >= 0 && (long) sfs.f_type == (long) BTRFS_SUPER_MAGIC; log_debug("On btrfs: %s", yes_no(on_btrfs)); asprintf(&pack_fn, "%s/.readahead", root); @@ -645,6 +652,11 @@ int main(int argc, char *argv[]) { return 0; } + if (running_in_vm()) { + log_info("Disabling readahead collector due to execution in virtual machine."); + return 0; + } + if (!(shared = shared_get())) return 1;