The command zramctl lists the same stat info for all devices (DATA COMPR TOTAL).
Reported-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
#include "optutils.h"
#include "ismounted.h"
#include "strv.h"
+#include "path.h"
/*#define CONFIG_ZRAM_DEBUG*/
return -1;
}
+static void zram_reset_stat(struct zram *z)
+{
+ if (z) {
+ strv_free(z->mm_stat);
+ z->mm_stat = NULL;
+ z->mm_stat_probed = 0;
+ }
+}
+
static void zram_set_devname(struct zram *z, const char *devname, size_t n)
{
assert(z);
DBG(fprintf(stderr, "set devname: %s", z->devname));
sysfs_deinit(&z->sysfs);
+ zram_reset_stat(z);
}
static struct zram *new_zram(const char *devname)
return;
DBG(fprintf(stderr, "free: %p", z));
sysfs_deinit(&z->sysfs);
-
- strv_free(z->mm_stat);
+ zram_reset_stat(z);
free(z);
}
return z;
}
-#include "path.h"
static char *get_mm_stat(struct zram *z, size_t idx, int bytes)
{