readahead-common.c revision 5430f7f2bc7330f3088b894166bf3524a067e3d8
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <libudev.h>
#include "log.h"
#include "readahead-common.h"
#include "util.h"
return -errno;
}
return 0;
}
log_debug("Not preloading file %s with size out of bounds %llu", fn, (unsigned long long) st->st_size);
return 0;
}
return 1;
}
int fs_on_ssd(const char *p) {
bool b = false;
assert(p);
return -errno;
return false;
return -ENOMEM;
goto finish;
else
if (!look_at)
goto finish;
/* First, try high-level property */
goto finish;
}
/* Second, try kernel attribute */
goto finish;
/* Finally, fallback to heuristics */
goto finish;
if (udev_device)
if (udev)
return b;
}
int fs_on_read_only(const char *p) {
bool b = false;
const char *read_only;
assert(p);
return -errno;
return false;
return -ENOMEM;
goto finish;
goto finish;
if (udev_device)
if (udev)
return b;
}
bool enough_ram(void) {
/* Enable readahead only with at least 128MB memory */
}
int open_inotify(void) {
int fd;
log_error("Failed to create inotify handle: %m");
return -errno;
}
return -errno;
}
return fd;
}
ReadaheadShared *shared_get(void) {
int fd;
ReadaheadShared *m = NULL;
log_error("Failed to create shared memory segment: %m");
goto finish;
}
log_error("Failed to truncate shared memory segment: %m");
goto finish;
}
if ((m = mmap(NULL, sizeof(ReadaheadShared), PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
log_error("Failed to mmap shared memory segment: %m");
m = NULL;
goto finish;
}
if (fd >= 0)
return m;
}
int bump_request_nr(const char *p) {
uint64_t u;
int r;
dev_t d;
assert(p);
return -errno;
return 0;
block_get_whole_disk(d, &d);
r= -ENOMEM;
goto finish;
}
if (r < 0) {
if (r == -ENOENT)
r = 0;
goto finish;
}
r = safe_atou64(line, &u);
if (r >= 0 && u >= BUMP_REQUEST_NR) {
r = 0;
goto finish;
}
r = -ENOMEM;
goto finish;
}
if (r < 0)
goto finish;
log_info("Bumped block_nr parameter of %u:%u to %lu. This is a temporary hack and should be removed one day.", major(d), minor(d), (unsigned long) BUMP_REQUEST_NR);
r = 1;
return r;
}