summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2018-11-07 12:58:19 +0100
committerKarol Lewandowski <k.lewandowsk@samsung.com>2018-11-16 13:22:59 +0100
commit6accf65c59124e5a70e6034922ad14f8853fc511 (patch)
treec5b9f30f6fa7076adba2673ddd23d01656edb395
parent8f8c0ba615a88de9c78d6b24f3ce0470c7015cbd (diff)
downloadcrash-worker-6accf65c59124e5a70e6034922ad14f8853fc511.tar.gz
crash-worker-6accf65c59124e5a70e6034922ad14f8853fc511.tar.bz2
crash-worker-6accf65c59124e5a70e6034922ad14f8853fc511.zip
util: Add fsync_path to selectively flush file buffer to disk
Change-Id: I3cd9169dafff33cdfbaf1c21955c37d38a524fae
-rw-r--r--src/shared/util.c16
-rw-r--r--src/shared/util.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index bdb8259..85879d6 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -502,6 +502,22 @@ int run_command_timeout(char *path, char *args[], char *env[], int timeout)
return res;
}
+int fsync_path(char *const path)
+{
+ int fd, ret;
+
+ ret = fd = open(path, O_RDONLY);
+ if (fd >= 0) {
+ ret = fsync(fd);
+ close(fd);
+ }
+
+ if (ret < 0)
+ _E("Unable to fsync %s: %m", path);
+
+ return ret;
+}
+
static int remove_dir_internal(int fd)
{
DIR *dir;
diff --git a/src/shared/util.h b/src/shared/util.h
index 53e0c7d..819a19c 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -51,6 +51,8 @@ int run_command_write_fd_timeout(char *path, char *args[], char *env[], int dfd,
int run_command_timeout(char *path, char *args[], char *env[], int timeout);
+int fsync_path(char *const path);
+
int remove_dir(const char *path, int del_dir);
int get_exec_pid(const char *execpath);