mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dm_fclose: new function
* lib/libdevmapper.h: Declare it. * lib/libdm-file.c (dm_fclose): Define it. * lib/.exported_symbols: Add dm_fclose.
This commit is contained in:
parent
b07dabbe80
commit
0c3cd7e292
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.22 -
|
Version 1.02.22 -
|
||||||
================================
|
================================
|
||||||
|
dm_fclose: new function
|
||||||
|
|
||||||
Version 1.02.21 - 13th July 2007
|
Version 1.02.21 - 13th July 2007
|
||||||
================================
|
================================
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
dm_lib_release
|
dm_lib_release
|
||||||
dm_lib_exit
|
dm_lib_exit
|
||||||
dm_driver_version
|
dm_driver_version
|
||||||
|
dm_fclose
|
||||||
dm_get_library_version
|
dm_get_library_version
|
||||||
dm_log
|
dm_log
|
||||||
dm_log_init
|
dm_log_init
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
* The first section of this file provides direct access to the
|
* The first section of this file provides direct access to the
|
||||||
@ -623,6 +624,21 @@ int dm_snprintf(char *buf, size_t bufsize, const char *format, ...);
|
|||||||
*/
|
*/
|
||||||
char *dm_basename(const char *path);
|
char *dm_basename(const char *path);
|
||||||
|
|
||||||
|
/**************************
|
||||||
|
* file/stream manipulation
|
||||||
|
**************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close a stream, with nicer error checking than fclose's.
|
||||||
|
* Derived from gnulib's close-stream.c.
|
||||||
|
*
|
||||||
|
* Close "stream". Return 0 if successful, and EOF (setting errno)
|
||||||
|
* otherwise. Upon failure, set errno to 0 if the error number
|
||||||
|
* cannot be determined. Useful mainly for writable streams.
|
||||||
|
*/
|
||||||
|
int dm_fclose(FILE *stream);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns size of a buffer which is allocated with dm_malloc.
|
* Returns size of a buffer which is allocated with dm_malloc.
|
||||||
* Pointer to the buffer is stored in *buf.
|
* Pointer to the buffer is stored in *buf.
|
||||||
|
@ -72,3 +72,16 @@ int create_dir(const char *dir)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dm_fclose(FILE *stream)
|
||||||
|
{
|
||||||
|
int prev_fail = ferror(stream);
|
||||||
|
int fclose_fail = fclose(stream);
|
||||||
|
|
||||||
|
/* If there was a previous failure, but fclose succeeded,
|
||||||
|
clear errno, since ferror does not set it, and its value
|
||||||
|
may be unrelated to the ferror-reported failure. */
|
||||||
|
if (prev_fail && !fclose_fail)
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
|
return prev_fail || fclose_fail ? EOF : 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user