You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
760 B
C
42 lines
760 B
C
/*
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
|
|
/* helper app to fsync a single file/directory */
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int fd,rc;
|
|
|
|
if (argc != 2) {
|
|
printf("usage: %s <path/to/file>\n", argv[0]);
|
|
return -1;
|
|
}
|
|
|
|
fd = open(argv[1], O_RDONLY);
|
|
if (fd == -1) {
|
|
printf("unable to open file %s: %m\n", argv[1]);
|
|
return -1;
|
|
}
|
|
|
|
rc = fsync(fd);
|
|
if (rc == -1) {
|
|
printf("error fsyncing file %s: %m\n", argv[1]);
|
|
}
|
|
|
|
if (close(fd) == -1) {
|
|
printf("error closing file %s: %m\n", argv[1]);
|
|
}
|
|
|
|
return rc;
|
|
}
|