[Devel] [PATCH] fused: save logrotate option to fstab
Dmitry Monakhov
dmonakhov at openvz.org
Thu Aug 17 20:47:11 MSK 2017
currently one may run 'vstorage-mount -s' with -L option, but
it will affect only current mount w/o reflection to fstab opts.
In fact mount.fuse.vstorage already has parser for logrotate option, so
this patch makes this feature fully supported.
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
pcs/clients/fused/fused.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/pcs/clients/fused/fused.c b/pcs/clients/fused/fused.c
index b73da80..5c4a84e 100644
--- a/pcs/clients/fused/fused.c
+++ b/pcs/clients/fused/fused.c
@@ -176,6 +176,8 @@ static char *make_fstab_options(
int timeout,
char *logfile,
int loglevel,
+ unsigned long rotate_num,
+ unsigned long long rotate_size,
unsigned long mntflags,
char *username,
char *groupname,
@@ -197,6 +199,9 @@ static char *make_fstab_options(
res += fstab_add_option(&out, "logfile=%s", logfile);
if (loglevel != LOG_LEVEL_SRV_DEFAULT)
res += fstab_add_option(&out, "loglevel=%u", (unsigned)loglevel);
+ if (rotate_num || rotate_size)
+ res += fstab_add_option(&out, "logrotate=%lux%llu", rotate_num, rotate_size);
+
if (g_read_cache.params.pathname)
res += fstab_add_option(&out, "cache=%s", g_read_cache.params.pathname);
if (g_read_cache.params.total_sz_mb > 0)
@@ -501,6 +506,7 @@ int main(int argc, char** argv)
unsigned long mntflags = 0;
int ch, res = -1;
int pipefd[2];
+ int rotate_opt = 0;
unsigned long rotate_num = 10;
unsigned long long rotate_size = 100LL * 1024LL * 1024LL;
int after_exec = 0;
@@ -595,6 +601,7 @@ int main(int argc, char** argv)
case 'L':
if (parse_logrotate_diskspace(optarg, &rotate_num, &rotate_size) < 0)
usage(NULL);
+ rotate_opt = 1;
break;
case 'd':
pcs_log_level = strtoul(optarg, &p, 10);
@@ -678,8 +685,11 @@ int main(int argc, char** argv)
usage("Invalid read cache parameters");
if (fstab_modify) {
- fstab_options = make_fstab_options(timeout, logfile, pcs_log_level, mntflags,
- username, groupname, mode, nodef, mntparams);
+ fstab_options = make_fstab_options(timeout, logfile, pcs_log_level,
+ rotate_opt ? rotate_num : 0,
+ rotate_opt ? rotate_size : 0,
+ mntflags, username,
+ groupname, mode, nodef, mntparams);
if (!fstab_options) {
pcs_log(LOG_ERR, PCS_FUSED_MSG_PREFIX"failed to make fstab options");
exit(252);
--
1.8.3.1
More information about the Devel
mailing list