1/*
2 * ntfs_debug.h - Defines for NTFS kernel debug support.
3 *
4 * Copyright (c) 2006-2008 Anton Altaparmakov.  All Rights Reserved.
5 * Portions Copyright (c) 2006-2008 Apple Inc.  All Rights Reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 *    this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 *    this list of conditions and the following disclaimer in the documentation
14 *    and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
16 *    contributors may be used to endorse or promote products derived from this
17 *    software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * ALTERNATIVELY, provided that this notice and licensing terms are retained in
31 * full, this file may be redistributed and/or modified under the terms of the
32 * GNU General Public License (GPL) Version 2, in which case the provisions of
33 * that version of the GPL will apply to you instead of the license terms
34 * above.  You can obtain a copy of the GPL Version 2 at
35 * http://developer.apple.com/opensource/licenses/gpl-2.txt.
36 */
37
38#ifndef _OSX_NTFS_DEBUG_H
39#define _OSX_NTFS_DEBUG_H
40
41#include <sys/cdefs.h>
42
43#include "ntfs_runlist.h"
44
45/* Forward declaration so we do not have to include <sys/mount.h> here. */
46struct mount;
47
48__private_extern__ void ntfs_debug_init(void);
49__private_extern__ void ntfs_debug_deinit(void);
50
51__private_extern__ void __ntfs_warning(const char *function,
52		struct mount *mp, const char *fmt, ...) __printflike(3, 4);
53#define ntfs_warning(mp, fmt, a...)	\
54		__ntfs_warning(__FUNCTION__, mp, fmt, ##a)
55
56__private_extern__ void __ntfs_error(const char *function,
57		struct mount *mp, const char *fmt, ...) __printflike(3, 4);
58#define ntfs_error(mp, fmt, a...)	\
59		__ntfs_error(__FUNCTION__, mp, fmt, ##a)
60
61#ifdef DEBUG
62
63/**
64 * ntfs_debug - write a debug message to the console
65 * @fmt:	a printf format string containing the message
66 * @...:	the variables to substitute into @fmt
67 *
68 * ntfs_debug() writes a message to the console but only if the driver was
69 * compiled with -DDEBUG.  Otherwise, the call turns into a NOP.
70 */
71__private_extern__ void __ntfs_debug(const char *file, int line,
72		const char *function, const char *fmt, ...)
73		__printflike(4, 5);
74#define ntfs_debug(fmt, a...)		\
75		__ntfs_debug(__FILE__, __LINE__, __FUNCTION__, fmt, ##a)
76
77__private_extern__ void ntfs_debug_runlist_dump(const ntfs_runlist *rl);
78__private_extern__ void ntfs_debug_attr_list_dump(const u8 *al,
79		const unsigned size);
80
81#else /* !DEBUG */
82
83#define ntfs_debug(fmt, a...)			do {} while (0)
84#define ntfs_debug_runlist_dump(rl)		do {} while (0)
85#define ntfs_debug_attr_list_dump(al, size)	do {} while (0)
86
87#endif /* !DEBUG */
88
89#endif /* !_OSX_NTFS_DEBUG_H */
90