#include <unistd.h>
#include <sys/types.h>
#include <libsyscommon/list.h>
+#include <libsyscommon/file.h>
#include "core.h"
#include "display-misc.h"
int ret;
cleanup_pmlock_statistics();
- ret = do_copy_force(PMLOCK_HISTORY_RUN_PATH, PMLOCK_HISTORY_FILE);
+ ret = syscommon_file_copy(PMLOCK_HISTORY_RUN_PATH, PMLOCK_HISTORY_FILE, true);
if (ret < 0)
_W("Can not move(%d)", ret);
int ret;
cleanup_pmlock_statistics();
- ret = do_copy_force(PMLOCK_HISTORY_RUN_PATH, PMLOCK_HISTORY_GHOST_PATH);
+ ret = syscommon_file_copy(PMLOCK_HISTORY_RUN_PATH, PMLOCK_HISTORY_GHOST_PATH, true);
if (ret < 0)
_W("Can not move(%d)", ret);
return 0;
}
-static int do_copy_internal(const char *src, const char *dst, mode_t mode, bool force)
-{
- _cleanup_close_ int rfd = -1, wfd = -1;
- char buf[1024];
- ssize_t red;
- int r;
-
- assert(src);
- assert(dst);
-
- if (!force) {
- r = access(dst, F_OK);
- if (r == 0)
- return -EALREADY;
- else if (errno != ENOENT)
- return -errno;
- }
-
- wfd = open(dst, O_CREAT | O_WRONLY | O_TRUNC, mode);
- if (wfd < 0)
- return -errno;
-
- rfd = open(src, O_RDONLY);
- if (rfd < 0)
- return -errno;
-
- while ((red = read(rfd, buf, 1024)) > 0)
- if (write(wfd, buf, red) != red)
- return -errno;
-
- if (red < 0)
- return -errno;
-
- return 0;
-}
-
-int do_copy_force(const char *src, const char *dst)
-{
- assert(src);
- assert(dst);
-
- return do_copy_internal(src, dst, 0644, true);
-}
-
int get_command(pid_t pid, char *comm, size_t len)
{
FILE *fp;
int get_systemd_reboot_param(char *buf, unsigned bufsize);
int do_mkdir(const char *path, mode_t mode);
-int do_copy_force(const char *src, const char *dst);
void watchdog_notify(void);
#ifdef __cplusplus