chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tempfiles: add little utility for creating volatile files/dirs in tmpfs hierarchies
[elogind.git]
/
src
/
readahead-collect.c
diff --git
a/src/readahead-collect.c
b/src/readahead-collect.c
index aa136ce50ec82e3ba6a84aa360d74532bf876bf9..c8b2cdcc52eca4a38ff8216d3cfebe5d99b11e69 100644
(file)
--- a/
src/readahead-collect.c
+++ b/
src/readahead-collect.c
@@
-54,7
+54,6
@@
*
* - detect ssd on btrfs/lvm...
* - read ahead directories
*
* - detect ssd on btrfs/lvm...
* - read ahead directories
- * - sd_readahead_cancel
* - gzip?
* - remount rw?
* - handle files where nothing is in mincore
* - gzip?
* - remount rw?
* - handle files where nothing is in mincore
@@
-65,6
+64,10
@@
static unsigned arg_files_max = 16*1024;
static off_t arg_file_size_max = READAHEAD_FILE_SIZE_MAX;
static usec_t arg_timeout = 2*USEC_PER_MINUTE;
static off_t arg_file_size_max = READAHEAD_FILE_SIZE_MAX;
static usec_t arg_timeout = 2*USEC_PER_MINUTE;
+/* Avoid collisions with the NULL pointer */
+#define SECTOR_TO_PTR(s) ULONG_TO_PTR((s)+1)
+#define PTR_TO_SECTOR(p) (PTR_TO_ULONG(p)-1)
+
static int btrfs_defrag(int fd) {
struct btrfs_ioctl_vol_args data;
static int btrfs_defrag(int fd) {
struct btrfs_ioctl_vol_args data;
@@
-201,7
+204,7
@@
static int qsort_compare(const void *a, const void *b) {
static int collect(const char *root) {
enum {
static int collect(const char *root) {
enum {
- FD_FANOTIFY, /* Get the actual
y
fs events */
+ FD_FANOTIFY, /* Get the actual fs events */
FD_SIGNAL,
FD_INOTIFY, /* We get notifications to quit early via this fd */
_FD_MAX
FD_SIGNAL,
FD_INOTIFY, /* We get notifications to quit early via this fd */
_FD_MAX
@@
-396,7
+399,7
@@
static int collect(const char *root) {
ul = fd_first_block(m->fd);
ul = fd_first_block(m->fd);
- if ((k = hashmap_put(files, p,
ULONG
_TO_PTR(ul))) < 0) {
+ if ((k = hashmap_put(files, p,
SECTOR
_TO_PTR(ul))) < 0) {
log_warning("set_put() failed: %s", strerror(-k));
free(p);
}
log_warning("set_put() failed: %s", strerror(-k));
free(p);
}
@@
-419,7
+422,7
@@
done:
log_debug("Writing Pack File...");
log_debug("Writing Pack File...");
- on_ssd = fs_on_ssd(root);
+ 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;
log_debug("On SSD: %s", yes_no(on_ssd));
on_btrfs = statfs(root, &sfs) >= 0 && sfs.f_type == BTRFS_SUPER_MAGIC;
@@
-469,7
+472,7
@@
done:
j = ordered;
HASHMAP_FOREACH_KEY(q, p, files, i) {
j->path = p;
j = ordered;
HASHMAP_FOREACH_KEY(q, p, files, i) {
j->path = p;
- j->block = PTR_TO_
ULONG
(q);
+ j->block = PTR_TO_
SECTOR
(q);
j++;
}
j++;
}