Whamcloud - gitweb
a617f31b53a1b638ce5e6de68ce809c74404d69a
[fs/lustre-release.git] / lnet / include / libcfs / libcfs.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #ifndef __LIBCFS_LIBCFS_H__
5 #define __LIBCFS_LIBCFS_H__
6
7 #if !__GNUC__
8 #define __attribute__(x)
9 #endif
10
11 #if defined(__linux__)
12 #include <libcfs/linux/libcfs.h>
13 #elif defined(__APPLE__)
14 #include <libcfs/darwin/libcfs.h>
15 #elif defined(__WINNT__)
16 #include <libcfs/winnt/libcfs.h>
17 #else
18 #error Unsupported operating system.
19 #endif
20
21 #include "curproc.h"
22
23 #ifndef __KERNEL__
24 #include <stdio.h>
25 #endif
26
27 /* Controlled via configure key */
28 /* #define LIBCFS_DEBUG */
29
30 #ifndef offsetof
31 # define offsetof(typ,memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
32 #endif
33
34 /* cardinality of array */
35 #define sizeof_array(a) ((sizeof (a)) / (sizeof ((a)[0])))
36
37 #if !defined(container_of)
38 /* given a pointer @ptr to the field @member embedded into type (usually
39  * struct) @type, return pointer to the embedding instance of @type. */
40 #define container_of(ptr, type, member) \
41         ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
42 #endif
43
44 #define container_of0(ptr, type, member)                        \
45 ({                                                              \
46         typeof(ptr) __ptr = (ptr);                              \
47         type       *__res;                                      \
48                                                                 \
49         if (unlikely(IS_ERR(__ptr) || __ptr == NULL))           \
50                 __res = (type *)__ptr;                          \
51         else                                                    \
52                 __res = container_of(__ptr, type, member);      \
53         __res;                                                  \
54 })
55
56 /*
57  * true iff @i is power-of-2
58  */
59 #define IS_PO2(i)                               \
60 ({                                              \
61         typeof(i) __i;                          \
62                                                 \
63         __i = (i);                              \
64         !(__i & (__i - 1));                     \
65 })
66
67 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
68
69 /*
70  *  Debugging
71  */
72 extern unsigned int libcfs_subsystem_debug;
73 extern unsigned int libcfs_stack;
74 extern unsigned int libcfs_debug;
75 extern unsigned int libcfs_printk;
76 extern unsigned int libcfs_console_ratelimit;
77 extern unsigned int libcfs_debug_binary;
78 extern char debug_file_path[1024];
79
80 int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys);
81 int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
82
83 /* Has there been an LBUG? */
84 extern unsigned int libcfs_catastrophe;
85 extern unsigned int libcfs_panic_on_lbug;
86
87 /*
88  * struct ptldebug_header is defined in libcfs/<os>/libcfs.h
89  */
90
91 #define PH_FLAG_FIRST_RECORD 1
92
93 /* Debugging subsystems (32 bits, non-overlapping) */
94 /* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */
95 #define S_UNDEFINED   0x00000001
96 #define S_MDC         0x00000002
97 #define S_MDS         0x00000004
98 #define S_OSC         0x00000008
99 #define S_OST         0x00000010
100 #define S_CLASS       0x00000020
101 #define S_LOG         0x00000040
102 #define S_LLITE       0x00000080
103 #define S_RPC         0x00000100
104 #define S_MGMT        0x00000200
105 #define S_LNET        0x00000400
106 #define S_LND         0x00000800 /* ALL LNDs */
107 #define S_PINGER      0x00001000
108 #define S_FILTER      0x00002000
109 /* unused */
110 #define S_ECHO        0x00008000
111 #define S_LDLM        0x00010000
112 #define S_LOV         0x00020000
113 /* unused */
114 /* unused */
115 /* unused */
116 /* unused */
117 /* unused */
118 #define S_LMV         0x00800000 /* b_new_cmd */
119 /* unused */
120 #define S_SEC         0x02000000 /* upcall cache */
121 #define S_GSS         0x04000000 /* b_new_cmd */
122 /* unused */
123 #define S_MGC         0x10000000
124 #define S_MGS         0x20000000
125 #define S_FID         0x40000000 /* b_new_cmd */
126 #define S_FLD         0x80000000 /* b_new_cmd */
127 /* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */
128
129 /* Debugging masks (32 bits, non-overlapping) */
130 /* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */
131 #define D_TRACE       0x00000001 /* ENTRY/EXIT markers */
132 #define D_INODE       0x00000002
133 #define D_SUPER       0x00000004
134 #define D_EXT2        0x00000008 /* anything from ext2_debug */
135 #define D_MALLOC      0x00000010 /* print malloc, free information */
136 #define D_CACHE       0x00000020 /* cache-related items */
137 #define D_INFO        0x00000040 /* general information */
138 #define D_IOCTL       0x00000080 /* ioctl related information */
139 #define D_NETERROR    0x00000100 /* network errors */
140 #define D_NET         0x00000200 /* network communications */
141 #define D_WARNING     0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
142 #define D_BUFFS       0x00000800
143 #define D_OTHER       0x00001000
144 #define D_DENTRY      0x00002000
145 #define D_NETTRACE    0x00004000
146 #define D_PAGE        0x00008000 /* bulk page handling */
147 #define D_DLMTRACE    0x00010000
148 #define D_ERROR       0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
149 #define D_EMERG       0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
150 #define D_HA          0x00080000 /* recovery and failover */
151 #define D_RPCTRACE    0x00100000 /* for distributed debugging */
152 #define D_VFSTRACE    0x00200000
153 #define D_READA       0x00400000 /* read-ahead */
154 #define D_MMAP        0x00800000
155 #define D_CONFIG      0x01000000
156 #define D_CONSOLE     0x02000000
157 #define D_QUOTA       0x04000000
158 #define D_SEC         0x08000000
159 /* keep these in sync with lnet/{utils,libcfs}/debug.c */
160
161 #define D_CANTMASK   (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
162
163 #ifndef DEBUG_SUBSYSTEM
164 # define DEBUG_SUBSYSTEM S_UNDEFINED
165 #endif
166
167 #define CDEBUG_MAX_LIMIT 600
168 typedef struct {
169         cfs_time_t      cdls_next;
170         int             cdls_count;
171         cfs_duration_t  cdls_delay;
172 } cfs_debug_limit_state_t;
173
174 /* Controlled via configure key */
175 /* #define CDEBUG_ENABLED */
176
177 #if defined(__KERNEL__) || (defined(__arch_lib__) && !defined(LUSTRE_UTILS))
178
179 #ifdef CDEBUG_ENABLED
180 #define __CDEBUG(cdls, mask, format, a...)                              \
181 do {                                                                    \
182         CHECK_STACK();                                                  \
183                                                                         \
184         if (((mask) & D_CANTMASK) != 0 ||                               \
185             ((libcfs_debug & (mask)) != 0 &&                            \
186              (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))          \
187                 libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, mask,           \
188                                  __FILE__, __FUNCTION__, __LINE__,      \
189                                  format, ## a);                         \
190 } while (0)
191
192 #define CDEBUG(mask, format, a...) __CDEBUG(NULL, mask, format, ## a)
193
194 #define CDEBUG_LIMIT(mask, format, a...)        \
195 do {                                            \
196         static cfs_debug_limit_state_t cdls;    \
197                                                 \
198         __CDEBUG(&cdls, mask, format, ## a);    \
199 } while (0)
200
201 #else /* CDEBUG_ENABLED */
202 #define CDEBUG(mask, format, a...) (void)(0)
203 #define CDEBUG_LIMIT(mask, format, a...) (void)(0)
204 #warning "CDEBUG IS DISABLED. THIS SHOULD NEVER BE DONE FOR PRODUCTION!"
205 #endif
206
207 #else
208
209 #define CDEBUG(mask, format, a...)                                      \
210 do {                                                                    \
211         if (((mask) & D_CANTMASK) != 0)                                 \
212                 fprintf(stderr, "(%s:%d:%s()) " format,                 \
213                         __FILE__, __LINE__, __FUNCTION__, ## a);        \
214 } while (0)
215
216 #define CDEBUG_LIMIT CDEBUG
217
218 #endif /* !__KERNEL__ */
219
220 /*
221  * Lustre Error Checksum: calculates checksum
222  * of Hex number by XORing each bit.
223  */
224 #define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
225                            ((hexnum) >> 8 & 0xf))
226
227 #define CWARN(format, a...)          CDEBUG_LIMIT(D_WARNING, format, ## a)
228 #define CERROR(format, a...)         CDEBUG_LIMIT(D_ERROR, format, ## a)
229 #define CEMERG(format, a...)         CDEBUG_LIMIT(D_EMERG, format, ## a)
230
231 #define LCONSOLE(mask, format, a...) CDEBUG(D_CONSOLE | (mask), format, ## a)
232 #define LCONSOLE_INFO(format, a...)  CDEBUG_LIMIT(D_CONSOLE, format, ## a)
233 #define LCONSOLE_WARN(format, a...)  CDEBUG_LIMIT(D_CONSOLE | D_WARNING, format, ## a)
234 #define LCONSOLE_ERROR_MSG(errnum, format, a...) CDEBUG_LIMIT(D_CONSOLE | D_ERROR, \
235                            "%x-%x: " format, errnum, LERRCHKSUM(errnum),  ## a)
236 #define LCONSOLE_ERROR(format, a...) LCONSOLE_ERROR_MSG(0x00, format, ## a)
237
238 #define LCONSOLE_EMERG(format, a...) CDEBUG(D_CONSOLE | D_EMERG, format, ## a)
239
240 #ifdef CDEBUG_ENABLED
241
242 #define GOTO(label, rc)                                                 \
243 do {                                                                    \
244         long GOTO__ret = (long)(rc);                                    \
245         CDEBUG(D_TRACE,"Process leaving via %s (rc=%lu : %ld : %lx)\n", \
246                #label, (unsigned long)GOTO__ret, (signed long)GOTO__ret,\
247                (signed long)GOTO__ret);                                 \
248         goto label;                                                     \
249 } while (0)
250 #else
251 #define GOTO(label, rc) do { ((void)(rc)); goto label; } while (0)
252 #endif
253
254 /* Controlled via configure key */
255 /* #define CDEBUG_ENTRY_EXIT */
256
257 #ifdef CDEBUG_ENTRY_EXIT
258
259 /*
260  * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise
261  * there will be a warning in osx.
262  */
263 #define RETURN(rc)                                                      \
264 do {                                                                    \
265         typeof(rc) RETURN__ret = (rc);                                  \
266         CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n",       \
267                (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\
268         EXIT_NESTING;                                                   \
269         return RETURN__ret;                                             \
270 } while (0)
271
272 #define ENTRY                                                           \
273 ENTRY_NESTING;                                                          \
274 do {                                                                    \
275         CDEBUG(D_TRACE, "Process entered\n");                           \
276 } while (0)
277
278 #define EXIT                                                            \
279 do {                                                                    \
280         CDEBUG(D_TRACE, "Process leaving\n");                           \
281         EXIT_NESTING;                                                   \
282 } while(0)
283 #else /* !CDEBUG_ENTRY_EXIT */
284
285 #define RETURN(rc) return (rc)
286 #define ENTRY                           do { } while (0)
287 #define EXIT                            do { } while (0)
288
289 #endif /* !CDEBUG_ENTRY_EXIT */
290
291 /*
292  * Some (nomina odiosa sunt) platforms define NULL as naked 0. This confuses
293  * Lustre RETURN(NULL) macro.
294  */
295 #if defined(NULL)
296 #undef NULL
297 #endif
298
299 #define NULL ((void *)0)
300
301 #define LUSTRE_SRV_LNET_PID      LUSTRE_LNET_PID
302
303 #ifdef __KERNEL__
304
305 #include <libcfs/list.h>
306
307 struct libcfs_ioctl_data;                       /* forward ref */
308
309 struct libcfs_ioctl_handler {
310         struct list_head item;
311         int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_data *data);
312 };
313
314 #define DECLARE_IOCTL_HANDLER(ident, func)                      \
315         struct libcfs_ioctl_handler ident = {                   \
316                 /* .item = */ CFS_LIST_HEAD_INIT(ident.item),   \
317                 /* .handle_ioctl = */ func                      \
318         }
319
320 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
321 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
322
323 /* libcfs tcpip */
324 #define LNET_ACCEPTOR_MIN_RESERVED_PORT    512
325 #define LNET_ACCEPTOR_MAX_RESERVED_PORT    1023
326
327 int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
328 int libcfs_ipif_enumerate(char ***names);
329 void libcfs_ipif_free_enumeration(char **names, int n);
330 int libcfs_sock_listen(cfs_socket_t **sockp, __u32 ip, int port, int backlog);
331 int libcfs_sock_accept(cfs_socket_t **newsockp, cfs_socket_t *sock);
332 void libcfs_sock_abort_accept(cfs_socket_t *sock);
333 int libcfs_sock_connect(cfs_socket_t **sockp, int *fatal,
334                         __u32 local_ip, int local_port,
335                         __u32 peer_ip, int peer_port);
336 int libcfs_sock_setbuf(cfs_socket_t *socket, int txbufsize, int rxbufsize);
337 int libcfs_sock_getbuf(cfs_socket_t *socket, int *txbufsize, int *rxbufsize);
338 int libcfs_sock_getaddr(cfs_socket_t *socket, int remote, __u32 *ip, int *port);
339 int libcfs_sock_write(cfs_socket_t *sock, void *buffer, int nob, int timeout);
340 int libcfs_sock_read(cfs_socket_t *sock, void *buffer, int nob, int timeout);
341 void libcfs_sock_release(cfs_socket_t *sock);
342
343 /* libcfs watchdogs */
344 struct lc_watchdog;
345
346 /* Add a watchdog which fires after "time" milliseconds of delay.  You have to
347  * touch it once to enable it. */
348 struct lc_watchdog *lc_watchdog_add(int time,
349                                     void (*cb)(pid_t pid, void *),
350                                     void *data);
351
352 /* Enables a watchdog and resets its timer. */
353 void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms);
354 void lc_watchdog_touch(struct lc_watchdog *lcw);
355
356 /* Disable a watchdog; touch it to restart it. */
357 void lc_watchdog_disable(struct lc_watchdog *lcw);
358
359 /* Clean up the watchdog */
360 void lc_watchdog_delete(struct lc_watchdog *lcw);
361
362 /* Dump a debug log */
363 void lc_watchdog_dumplog(pid_t pid, void *data);
364
365 /* __KERNEL__ */
366 #endif
367
368 /*
369  * libcfs pseudo device operations
370  *
371  * struct cfs_psdev_t and
372  * cfs_psdev_register() and
373  * cfs_psdev_deregister() are declared in
374  * libcfs/<os>/cfs_prim.h
375  *
376  * It's just draft now.
377  */
378
379 struct cfs_psdev_file {
380         unsigned long   off;
381         void            *private_data;
382         unsigned long   reserved1;
383         unsigned long   reserved2;
384 };
385
386 struct cfs_psdev_ops {
387         int (*p_open)(unsigned long, void *);
388         int (*p_close)(unsigned long, void *);
389         int (*p_read)(struct cfs_psdev_file *, char *, unsigned long);
390         int (*p_write)(struct cfs_psdev_file *, char *, unsigned long);
391         int (*p_ioctl)(struct cfs_psdev_file *, unsigned long, void *);
392 };
393
394 /*
395  * generic time manipulation functions.
396  */
397
398 static inline int cfs_time_after(cfs_time_t t1, cfs_time_t t2)
399 {
400         return cfs_time_before(t2, t1);
401 }
402
403 static inline int cfs_time_aftereq(cfs_time_t t1, cfs_time_t t2)
404 {
405         return cfs_time_beforeq(t2, t1);
406 }
407
408 /*
409  * return seconds since UNIX epoch
410  */
411 static inline time_t cfs_unix_seconds(void)
412 {
413         cfs_fs_time_t t;
414
415         cfs_fs_time_current(&t);
416         return (time_t)cfs_fs_time_sec(&t);
417 }
418
419 static inline cfs_time_t cfs_time_shift(int seconds)
420 {
421         return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds));
422 }
423
424 static inline long cfs_timeval_sub(struct timeval *large, struct timeval *small,
425                                    struct timeval *result)
426 {
427         long r = (long) (
428                 (large->tv_sec - small->tv_sec) * ONE_MILLION +
429                 (large->tv_usec - small->tv_usec));
430         if (result != NULL) {
431                 result->tv_usec = r % ONE_MILLION;
432                 result->tv_sec = r / ONE_MILLION;
433         }
434         return r;
435 }
436
437 #define CFS_RATELIMIT(seconds)                                  \
438 ({                                                              \
439         /*                                                      \
440          * XXX nikita: non-portable initializer                 \
441          */                                                     \
442         static time_t __next_message = 0;                       \
443         int result;                                             \
444                                                                 \
445         if (cfs_time_after(cfs_time_current(), __next_message)) \
446                 result = 1;                                     \
447         else {                                                  \
448                 __next_message = cfs_time_shift(seconds);       \
449                 result = 0;                                     \
450         }                                                       \
451         result;                                                 \
452 })
453
454 struct libcfs_debug_msg_data {
455         cfs_debug_limit_state_t *msg_cdls;
456         int                      msg_subsys;
457         const char              *msg_file;
458         const char              *msg_fn;
459         int                      msg_line;
460 };
461
462 #define DEBUG_MSG_DATA_INIT(cdls, subsystem, file, func, ln ) { \
463         .msg_cdls           = (cdls),       \
464         .msg_subsys         = (subsystem),  \
465         .msg_file           = (file),       \
466         .msg_fn             = (func),       \
467         .msg_line           = (ln)          \
468     }
469
470
471 extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
472                               int subsys, int mask,
473                               const char *file, const char *fn, const int line,
474                               const char *format1, va_list args,
475                               const char *format2, ...)
476         __attribute__ ((format (printf, 9, 10)));
477
478 #define libcfs_debug_vmsg(cdls, subsys, mask, file, fn, line, format, args)   \
479     libcfs_debug_vmsg2(cdls, subsys, mask, file, fn,line,format,args,NULL,NULL)
480
481 #define libcfs_debug_msg(cdls, subsys, mask, file, fn, line, format, a...)    \
482     libcfs_debug_vmsg2(cdls, subsys, mask, file, fn,line,NULL,NULL,format, ##a)
483
484 #define cdebug_va(cdls, mask, file, func, line, fmt, args)      do {          \
485         CHECK_STACK();                                                        \
486                                                                               \
487         if (((mask) & D_CANTMASK) != 0 ||                                     \
488             ((libcfs_debug & (mask)) != 0 &&                                  \
489              (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))                \
490                 libcfs_debug_vmsg(cdls, DEBUG_SUBSYSTEM, (mask),              \
491                                   (file), (func), (line), fmt, args);         \
492 } while(0);
493
494 #define cdebug(cdls, mask, file, func, line, fmt, a...) do {                  \
495         CHECK_STACK();                                                        \
496                                                                               \
497         if (((mask) & D_CANTMASK) != 0 ||                                     \
498             ((libcfs_debug & (mask)) != 0 &&                                  \
499              (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))                \
500                 libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, (mask),               \
501                                  (file), (func), (line), fmt, ## a);          \
502 } while(0);
503
504 extern void libcfs_assertion_failed(const char *expr, const char *file,
505                                     const char *fn, const int line);
506
507 static inline void cfs_slow_warning(cfs_time_t now, int seconds, char *msg)
508 {
509         if (cfs_time_after(cfs_time_current(),
510                            cfs_time_add(now, cfs_time_seconds(15))))
511                 CERROR("slow %s %lu sec\n", msg,
512                        cfs_duration_sec(cfs_time_sub(cfs_time_current(),now)));
513 }
514
515 /*
516  * helper function similar to do_gettimeofday() of Linux kernel
517  */
518 static inline void cfs_fs_timeval(struct timeval *tv)
519 {
520         cfs_fs_time_t time;
521
522         cfs_fs_time_current(&time);
523         cfs_fs_time_usec(&time, tv);
524 }
525
526 /*
527  * return valid time-out based on user supplied one. Currently we only check
528  * that time-out is not shorted than allowed.
529  */
530 static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout)
531 {
532         if (timeout < CFS_TICK)
533                 timeout = CFS_TICK;
534         return timeout;
535 }
536
537 /*
538  * Universal memory allocator API
539  */
540 enum cfs_alloc_flags {
541         /* allocation is not allowed to block */
542         CFS_ALLOC_ATOMIC = 0x1,
543         /* allocation is allowed to block */
544         CFS_ALLOC_WAIT   = 0x2,
545         /* allocation should return zeroed memory */
546         CFS_ALLOC_ZERO   = 0x4,
547         /* allocation is allowed to call file-system code to free/clean
548          * memory */
549         CFS_ALLOC_FS     = 0x8,
550         /* allocation is allowed to do io to free/clean memory */
551         CFS_ALLOC_IO     = 0x10,
552         /* don't report allocation failure to the console */
553         CFS_ALLOC_NOWARN = 0x20,
554         /* standard allocator flag combination */
555         CFS_ALLOC_STD    = CFS_ALLOC_FS | CFS_ALLOC_IO,
556         CFS_ALLOC_USER   = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO,
557 };
558
559 /* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */
560 enum cfs_alloc_page_flags {
561         /* allow to return page beyond KVM. It has to be mapped into KVM by
562          * cfs_page_map(); */
563         CFS_ALLOC_HIGH   = 0x40,
564         CFS_ALLOC_HIGHUSER = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO | CFS_ALLOC_HIGH,
565 };
566
567 /*
568  * Drop into debugger, if possible. Implementation is provided by platform.
569  */
570
571 void cfs_enter_debugger(void);
572
573 /*
574  * Defined by platform
575  */
576 void cfs_daemonize(char *str);
577 int cfs_daemonize_ctxt(char *str);
578 cfs_sigset_t cfs_get_blocked_sigs(void);
579 cfs_sigset_t cfs_block_allsigs(void);
580 cfs_sigset_t cfs_block_sigs(cfs_sigset_t bits);
581 void cfs_restore_sigs(cfs_sigset_t);
582 int cfs_signal_pending(void);
583 void cfs_clear_sigpending(void);
584 /*
585  * XXX Liang:
586  * these macros should be removed in the future,
587  * we keep them just for keeping libcfs compatible
588  * with other branches.
589  */
590 #define libcfs_daemonize(s)     cfs_daemonize(s)
591 #define cfs_sigmask_lock(f)     do { f= 0; } while (0)
592 #define cfs_sigmask_unlock(f)   do { f= 0; } while (0)
593
594 int convert_server_error(__u64 ecode);
595 int convert_client_oflag(int cflag, int *result);
596
597 /*
598  * Stack-tracing filling.
599  */
600
601 /*
602  * Platform-dependent data-type to hold stack frames.
603  */
604 struct cfs_stack_trace;
605
606 /*
607  * Fill @trace with current back-trace.
608  */
609 void cfs_stack_trace_fill(struct cfs_stack_trace *trace);
610
611 /*
612  * Return instruction pointer for frame @frame_no. NULL if @frame_no is
613  * invalid.
614  */
615 void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no);
616
617 /*
618  * Universal open flags.
619  */
620 #define CFS_O_ACCMODE           0003
621 #define CFS_O_CREAT             0100
622 #define CFS_O_EXCL              0200
623 #define CFS_O_NOCTTY            0400
624 #define CFS_O_TRUNC             01000
625 #define CFS_O_APPEND            02000
626 #define CFS_O_NONBLOCK          04000
627 #define CFS_O_NDELAY            CFS_O_NONBLOCK
628 #define CFS_O_SYNC              010000
629 #define CFS_O_ASYNC             020000
630 #define CFS_O_DIRECT            040000
631 #define CFS_O_LARGEFILE         0100000
632 #define CFS_O_DIRECTORY         0200000
633 #define CFS_O_NOFOLLOW          0400000
634 #define CFS_O_NOATIME           01000000
635
636 /* convert local open flags to universal open flags */
637 int cfs_oflags2univ(int flags);
638 /* convert universal open flags to local open flags */
639 int cfs_univ2oflags(int flags);
640
641 #define _LIBCFS_H
642
643 #endif /* _LIBCFS_H */