mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
util: Add fopen_fmt helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
@@ -162,6 +162,7 @@ extern void hex_dump(void *addr, unsigned long len);
|
||||
|
||||
extern DIR *opendir_proc(char *fmt, ...);
|
||||
extern FILE *fopen_proc(char *fmt, char *mode, ...);
|
||||
extern FILE *fopen_fmt(char *fmt, char *mode, ...);
|
||||
extern int open_fmt(char *fmt, int mode, ...);
|
||||
|
||||
#define __xalloc(op, size, ...) \
|
||||
|
16
util.c
16
util.c
@@ -352,6 +352,22 @@ FILE *fopen_proc(char *fmt, char *mode, ...)
|
||||
return file;
|
||||
}
|
||||
|
||||
FILE *fopen_fmt(char *fmt, char *mode, ...)
|
||||
{
|
||||
FILE *file;
|
||||
char fname[128];
|
||||
va_list args;
|
||||
|
||||
va_start(args, mode);
|
||||
vsnprintf(fname, sizeof(fname), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
file = fopen(fname, mode);
|
||||
if (!file)
|
||||
pr_perror("Can't open %s\n", fname);
|
||||
return file;
|
||||
}
|
||||
|
||||
int open_fmt(char *fmt, int mode, ...)
|
||||
{
|
||||
int fd;
|
||||
|
Reference in New Issue
Block a user