Add ntfs_debug() and ntfs_error() to make kernel<->userspace porting easier.

(Logical change 1.538)
edge.strict_endians
cantab.net!aia21 2004-09-09 07:54:06 +00:00
parent 38cc93f5e7
commit d6fc63d0b1
2 changed files with 47 additions and 0 deletions

View File

@ -43,6 +43,15 @@ extern void __Sprintf(const int silent, const char *fmt, ...)
/* Debug output to stderr. To get it run ./configure --enable-debug. */
extern void __ntfs_debug (const char *file, int line, const char *function,
const char *format, ...) __attribute__((format(printf, 4, 5)));
#define ntfs_debug(f, a...) \
__ntfs_debug(__FILE__, __LINE__, __FUNCTION__, f, ##a)
extern void __ntfs_error(const char *function,
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
#define ntfs_error(sb, f, a...) __ntfs_error(__FUNCTION__, f, ##a)
extern void __Dprintf(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
#define Dprintf(f, a...) __Dprintf(f, ##a)
@ -57,6 +66,9 @@ extern void ntfs_debug_runlist_dump(const struct _runlist_element *rl);
#else /* if !DEBUG */
#define ntfs_debug(f, a...) do {} while (0)
#define ntfs_error(f, a...) do {} while (0)
#define Dprintf(f, a...) do {} while (0)
#define Dputs(s) do {} while (0)
#define Dperror(s) do {} while (0)

View File

@ -61,6 +61,41 @@ void __Sprintf(const int silent, const char *fmt, ...)
/* Debug output to stderr. To get it run ./configure --enable-debug. */
void __ntfs_error(const char *function, const char *fmt, ...)
{
int eo = errno;
int flen = 0;
va_list args;
char err_buf[1024];
if (function)
flen = strlen(function);
va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args);
va_end(args);
fprintf(stderr, "NTFS error: %s(): %s\n", flen ? function : "",
err_buf);
errno = eo;
}
void __ntfs_debug (const char *file, int line, const char *function,
const char *fmt, ...)
{
int eo = errno;
int flen = 0;
va_list args;
char err_buf[1024];
if (function)
flen = strlen(function);
va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args);
va_end(args);
fprintf(stderr, "NTFS DEBUG (%s, %d): %s(): %s\n", file, line,
flen ? function : "", err_buf);
errno = eo;
}
void __Dprintf(const char *fmt, ...)
{
int eo = errno;