]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/fslog.h
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 #include <sys/syslog.h>
33 #include <sys/mount.h>
34 #include <machine/limits.h>
37 /* Log file system related error in key-value format identified by Apple
38 * system log (ASL) facility. The key-value pairs are string pointers
39 * (char *) and are provided as variable arguments list. A NULL value
40 * indicates end of the list.
42 * Keys can not contain '[', ']', space, and newline. Values can not
43 * contain '[', ']', and newline. If any key-value contains any of the
44 * reserved characters, the behavior is undefined. The caller of the
45 * function should escape any occurrences of '[' and ']' by prefixing
48 * The function takes a message ID which can be used to logically group
49 * different ASL messages. Messages in same logical group have same message
50 * ID and have information to describe order of the message --- first,
53 * The following message IDs have special meaning -
54 * FSLOG_MSG_FIRST - This message is the first message in its logical
55 * group. This generates a unique message ID, creates two key-value
56 * pairs with message ID and order of the message as "First".
57 * FSLOG_MSG_LAST - This is really a MASK which should be logically OR'ed
58 * with message ID to indicate the last message for a logical group.
59 * This also creates two key-value pairs with message ID and order of
61 * FSLOG_MSG_SINGLE - This signifies that the message is the only message
62 * in its logical group. Therefore no extra key-values are generated
64 * For all other values of message IDs, it regards them as intermediate
65 * message and generates two key-value pairs with message ID and order of
66 * message as "Middle".
69 * Message ID of the ASL message printed. The caller should use
70 * this value to print intermediate messages or end the logical message
72 * For FSLOG_MSG_SINGLE option, it returns FSLOG_MSG_SINGLE.
74 unsigned long fslog_err(unsigned long msg_id
, ... );
76 /* Reserved message IDs to determine message order */
77 #define FSLOG_MSG_SINGLE ULONG_MAX
78 #define FSLOG_MSG_FIRST 0x0
79 #define FSLOG_MSG_LAST (~(ULONG_MAX >> 1))
81 #ifdef BSD_KERNEL_PRIVATE
83 /* Log information about runtime file system corruption detected */
84 void fslog_fs_corrupt(struct mount
*mnt
);
86 /* Log information about IO error detected */
87 void fslog_io_error(const buf_t bp
);
89 #endif /* BSD_KERNEL_PRIVATE */
91 #ifdef XNU_KERNEL_PRIVATE
93 /* Log information about external modification of a target process */
94 void fslog_extmod_msgtracer(proc_t caller
, proc_t target
);
96 #endif /* XNU_KERNEL_PRIVATE */
100 /* Keys used by FSLog */
101 #define FSLOG_KEY_FACILITY "Facility" /* Facility generating messages */
102 #define FSLOG_KEY_LEVEL "Level" /* Priority level */
103 #define FSLOG_KEY_MSG_ID "FSLogMsgID" /* Message ID */
104 #define FSLOG_KEY_MSG_ORDER "FSLogMsgOrder" /* Message Order */
105 #define FSLOG_KEY_READ_UID "ReadUID" /* Allow read access to this UID only */
107 /* Values for message order (FSLOG_KEY_MSG_ORDER) */
108 #define FSLOG_VAL_ORDER_FIRST "First"
109 #define FSLOG_VAL_ORDER_MIDDLE "Middle"
110 #define FSLOG_VAL_ORDER_LAST "Last"
112 /* Values used by FSLog */
113 #define FSLOG_VAL_FACILITY "com.apple.system.fs" /* Facility generating messages */
114 #define FSLOG_VAL_LEVEL LOG_ERR /* Priority level */
115 #define FSLOG_VAL_READ_UID 0 /* Allow read access to root only */
117 /* Keys for IO/FS logging using FSLog */
118 #define FSLOG_KEY_ERR_TYPE "ErrType" /* Type of problem (IO, FS Corruption) */
119 #define FSLOG_KEY_ERRNO "ErrNo" /* Error number (Integer) */
120 #define FSLOG_KEY_IOTYPE "IOType" /* Type of IO (Read/Write) */
121 #define FSLOG_KEY_PHYS_BLKNUM "PBlkNum" /* Physical block number */
122 #define FSLOG_KEY_LOG_BLKNUM "LBlkNum" /* Logical block number */
123 #define FSLOG_KEY_DEVNODE "DevNode" /* Device node (f_mntfromname) */
124 #define FSLOG_KEY_PATH "Path" /* File system path */
125 #define FSLOG_KEY_MNTPT "MountPt" /* Mount point */
127 /* Values for type of error (FSLOG_KEY_ERR_TYPE) */
128 #define FSLOG_VAL_ERR_TYPE_IO "IO" /* IO error */
129 #define FSLOG_VAL_ERR_TYPE_FS "FS" /* FS error */
131 /* Values for type of operation (FSLOG_KEY_IOTYPE) */
132 #define FSLOG_VAL_IOTYPE_READ "Read"
133 #define FSLOG_VAL_IOTYPE_WRITE "Write"
135 #endif /* !_FSLOG_H_ */