diff options
| author | Mitchell Wills <mwills@google.com> | 2015-08-26 01:01:12 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-26 01:01:12 +0000 |
| commit | 289d1289b5698bfbc81a54e11cea5f10f8a62693 (patch) | |
| tree | 12862fc75185d913a6f459b5fe7e4fcf7c8032ac /src | |
| parent | f8467ce3721b7154974a1f8a6e0dff54d4493f4d (diff) | |
| parent | 447c7ff83da0d89ffa70c378be2a4a58f9b14d3b (diff) | |
| download | android_external_wpa_supplicant_8-289d1289b5698bfbc81a54e11cea5f10f8a62693.tar.gz android_external_wpa_supplicant_8-289d1289b5698bfbc81a54e11cea5f10f8a62693.tar.bz2 android_external_wpa_supplicant_8-289d1289b5698bfbc81a54e11cea5f10f8a62693.zip | |
am 447c7ff8: Make sure configuration is saved to storage device
* commit '447c7ff83da0d89ffa70c378be2a4a58f9b14d3b':
Make sure configuration is saved to storage device
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/os.h | 7 | ||||
| -rw-r--r-- | src/utils/os_internal.c | 6 | ||||
| -rw-r--r-- | src/utils/os_none.c | 6 | ||||
| -rw-r--r-- | src/utils/os_unix.c | 8 | ||||
| -rw-r--r-- | src/utils/os_win32.c | 18 |
5 files changed, 45 insertions, 0 deletions
diff --git a/src/utils/os.h b/src/utils/os.h index 77250d63..8913854b 100644 --- a/src/utils/os.h +++ b/src/utils/os.h @@ -247,6 +247,13 @@ char * os_readfile(const char *name, size_t *len); int os_file_exists(const char *fname); /** + * os_fsync - Sync a file's (for a given stream) state with storage device + * @stream: the stream to be flushed + * Returns: 0 if the operation succeeded or -1 on failure + */ +int os_fsync(FILE *stream); + +/** * os_zalloc - Allocate and zero memory * @size: Number of bytes to allocate * Returns: Pointer to allocated and zeroed memory or %NULL on failure diff --git a/src/utils/os_internal.c b/src/utils/os_internal.c index 77733ad9..b8fb2dbd 100644 --- a/src/utils/os_internal.c +++ b/src/utils/os_internal.c @@ -243,6 +243,12 @@ char * os_readfile(const char *name, size_t *len) } +int os_fsync(FILE *stream) +{ + return 0; +} + + void * os_zalloc(size_t size) { void *n = os_malloc(size); diff --git a/src/utils/os_none.c b/src/utils/os_none.c index 83fe0251..96d243db 100644 --- a/src/utils/os_none.c +++ b/src/utils/os_none.c @@ -102,6 +102,12 @@ char * os_readfile(const char *name, size_t *len) } +int os_fsync(FILE *stream) +{ + return 0; +} + + void * os_zalloc(size_t size) { return NULL; diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index e0c1125d..ac73f7a6 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -415,6 +415,14 @@ int os_file_exists(const char *fname) } +int os_fsync(FILE *stream) +{ + if (!fflush(stream)) + return fsync(fileno(stream)); + return -1; +} + + #ifndef WPA_TRACE void * os_zalloc(size_t size) { diff --git a/src/utils/os_win32.c b/src/utils/os_win32.c index 296ea13f..890abf4f 100644 --- a/src/utils/os_win32.c +++ b/src/utils/os_win32.c @@ -216,6 +216,24 @@ char * os_readfile(const char *name, size_t *len) } +int os_fsync(FILE *stream) +{ + HANDLE hFile; + + if (stream == NULL) + return -1; + + hFile = _get_osfhandle(_fileno(stream)); + if (hFile == INVALID_HANDLE_VALUE) + return -1; + + if (!FlushFileBuffers(hFile)) + return -1; + + return 0; +} + + void * os_zalloc(size_t size) { return calloc(1, size); |
