+int libcfs_debug_clear_buffer(void)
+{
+ return 0;
+}
+
+int libcfs_debug_mark_buffer(char *text)
+{
+
+ fprintf(debug_file_fd, "*******************************************************************************\n");
+ fprintf(debug_file_fd, "DEBUG MARKER: %s\n", text);
+ fprintf(debug_file_fd, "*******************************************************************************\n");
+
+ return 0;
+}
+
+#ifdef HAVE_CATAMOUNT_DATA_H
+#define CATAMOUNT_MAXLINE (256-4)
+void catamount_printline(char *buf, size_t size)
+{
+ char *pos = buf;
+ int prsize = size;
+
+ while (prsize > 0){
+ lputs(pos);
+ pos += CATAMOUNT_MAXLINE;
+ prsize -= CATAMOUNT_MAXLINE;
+ }
+}
+#endif
+
+int
+libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
+ int subsys, int mask,
+ const char *file, const char *fn, const int line,
+ const char *format1, va_list args,
+ const char *format2, ...)
+{
+ struct timeval tv;
+ int nob;
+ int remain;
+ va_list ap;
+ char buf[CFS_PAGE_SIZE]; /* size 4096 used for compatimble
+ * with linux, where message can`t
+ * be exceed PAGE_SIZE */
+ int console = 0;
+ char *prefix = "Lustre";
+
+#ifdef HAVE_CATAMOUNT_DATA_H
+ /* toconsole == 0 - all messages to debug_file_fd
+ * toconsole == 1 - warnings to console, all to debug_file_fd
+ * toconsole > 1 - all debug to console */
+ if (((mask & libcfs_printk) && toconsole == 1) || toconsole > 1)
+ console = 1;
+#endif
+
+ if ((!console) && (!debug_file_fd)) {
+ return 0;
+ }
+
+ if (mask & (D_EMERG | D_ERROR))
+ prefix = "LustreError";
+
+ nob = snprintf(buf, sizeof(buf), "%s: %u-%s:(%s:%d:%s()): ", prefix,
+ source_pid, source_nid, file, line, fn);
+
+ remain = sizeof(buf) - nob;
+ if (format1) {
+ nob += vsnprintf(&buf[nob], remain, format1, args);
+ }
+
+ remain = sizeof(buf) - nob;
+ if ((format2) && (remain > 0)) {
+ va_start(ap, format2);
+ nob += vsnprintf(&buf[nob], remain, format2, ap);
+ va_end(ap);
+ }
+
+#ifdef HAVE_CATAMOUNT_DATA_H
+ if (console) {
+ /* check rate limit for console */
+ if (cdls != NULL) {
+ if (libcfs_console_ratelimit &&
+ cdls->cdls_next != 0 && /* not first time ever */
+ !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
+
+ /* skipping a console message */
+ cdls->cdls_count++;
+ goto out_file;
+ }
+
+ if (cfs_time_after(cfs_time_current(), cdls->cdls_next +
+ libcfs_console_max_delay +
+ cfs_time_seconds(10))) {
+ /* last timeout was a long time ago */
+ cdls->cdls_delay /= libcfs_console_backoff * 4;
+ } else {
+ cdls->cdls_delay *= libcfs_console_backoff;
+
+ if (cdls->cdls_delay <
+ libcfs_console_min_delay)
+ cdls->cdls_delay =
+ libcfs_console_min_delay;
+ else if (cdls->cdls_delay >
+ libcfs_console_max_delay)
+ cdls->cdls_delay =
+ libcfs_console_max_delay;
+ }
+
+ /* ensure cdls_next is never zero after it's been seen */
+ cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
+ }
+
+ if (cdls != NULL && cdls->cdls_count != 0) {
+ char buf2[100];
+
+ nob = snprintf(buf2, sizeof(buf2),
+ "Skipped %d previous similar message%s\n",
+ cdls->cdls_count, (cdls->cdls_count > 1) ? "s" : "");
+
+ catamount_printline(buf2, nob);
+ cdls->cdls_count = 0;
+ goto out_file;
+ }
+ catamount_printline(buf, nob);
+ }
+out_file:
+ /* return on toconsole > 1, as we don't want the user getting
+ * spammed by the debug data */
+ if (toconsole > 1)
+ return 0;
+#endif
+ if (debug_file_fd == NULL)
+ return 0;
+
+ gettimeofday(&tv, NULL);
+
+ fprintf(debug_file_fd, CFS_TIME_T".%06lu:%u:%s:(%s:%d:%s()): %s",
+ tv.tv_sec, tv.tv_usec, source_pid, source_nid,
+ file, line, fn, buf);
+
+ return 0;
+}
+
+void
+libcfs_assertion_failed(const char *expr, const char *file, const char *func,
+ const int line)
+{
+ libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line,
+ "ASSERTION(%s) failed\n", expr);
+ abort();