#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
#endif
-
/*
* libcfs proc device object
*/
-#define LUSTRE_PROC_DEVICE L"\\Device\\lproc" /* proc fs emulator device object */
-#define LUSTRE_PROC_SYMLNK L"\\DosDevices\\lproc" /* proc fs user-visible device */
+#define LUSTRE_PROC_DEVICE L"\\Device\\LNetProcFS" /* proc fs emulator device object */
+#define LUSTRE_PROC_SYMLNK L"\\DosDevices\\LNetProcFS" /* proc fs user-visible device */
/*
#define FILE_DEVICE_LIBCFS ('LC')
-#define FILE_DEVICE_LIBCFS ('LC')
-
#define FUNC_LIBCFS_VERSION 0x101 // get version of current libcfs
#define FUNC_LIBCFS_IOCTL 0x102 // Device i/o control to proc fs
CTL_CODE(FILE_DEVICE_LIBCFS, FUNC_LIBCFS_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS)
#pragma pack(4)
-
typedef struct _CFS_PROC_IOCTL {
ULONG cmd; // ioctl command identifier
ULONG len; // length of data
+ int rc; // return code
+ ULONG usused; // unused
// UCHAR data[]; // content of the real ioctl
} CFS_PROC_IOCTL, *PCFS_PROC_IOCTL;
-
#pragma pack()
#ifdef __KERNEL__
-#include <libcfs/list.h>
+void cfs_enter_debugger(void);
+#define __builtin_return_address(x) (0)
/*
* Symbol functions for libcfs
extern void cfs_symbol_put(const char *);
extern void cfs_symbol_clean();
-
-
typedef struct file_operations cfs_file_operations_t;
typedef struct file cfs_file_t;
*/
typedef int cfs_read_proc_t(char *page, char **start, off_t off,
- int count, int *eof, void *data);
+ int count, int *eof, void *data);
typedef int cfs_write_proc_t(struct file *file, const char *buffer,
- ulong_ptr count, void *data);
+ unsigned long count, void *data);
#define CFS_PROC_ENTRY_MAGIC 'CPEM'
PRTL_SPLAY_LINKS root;
};
+ struct cfs_proc_entry *parent;
+
struct _file_entry { // proc file / leaf entry
cfs_read_proc_t * read_proc;
cfs_write_proc_t * write_proc;
mode_t mode;
unsigned short nlink;
+ BOOLEAN deleted;
- struct file_operations * proc_fops;
- void * data;
+ struct file_operations *proc_fops;
+ void *data;
// proc_dir_entry ended.
} cfs_proc_entry_t, cfs_proc_dir_entry_t;
typedef cfs_proc_entry_t cfs_proc_dir_entry_t;
+#define proc_dir_entry cfs_proc_entry
#define PROC_BLOCK_SIZE PAGE_SIZE
+struct proc_dir_entry *PDE(const struct inode *inode);
+
+
/*
* Sysctl register
*/
-typedef struct ctl_table cfs_sysctl_table_t;
-typedef struct ctl_table_header cfs_sysctl_table_header_t;
+typedef struct ctl_table cfs_sysctl_table_t;
+typedef struct ctl_table_header cfs_sysctl_table_header_t;
typedef int ctl_handler (
cfs_sysctl_table_t *table,
- int *name, int nlen,
- void *oldval, size_t *oldlenp,
- void *newval, size_t newlen,
- void **context );
+ int *name, int nlen,
+ void *oldval, size_t *oldlenp,
+ void *newval, size_t newlen,
+ void **context );
typedef int proc_handler (
cfs_sysctl_table_t *ctl,
int write, struct file * filp,
- void *buffer, size_t *lenp );
+ void *buffer, size_t *lenp );
int proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *filp,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context);
-
/*
* System io control definitions
*/
struct list_head ctl_entry;
};
+/* proc root entries, support routines */
+extern cfs_proc_entry_t * cfs_proc_root; /* / */
+extern cfs_proc_entry_t * cfs_proc_proc; /* /proc */
+extern cfs_proc_entry_t * cfs_proc_fs; /* /proc/fs */
+extern cfs_proc_entry_t * cfs_proc_sys; /* /proc/sys */
+extern cfs_proc_entry_t * cfs_proc_dev; /* /dev */
-cfs_proc_entry_t * create_proc_entry(char *name, mode_t mod,
+cfs_proc_entry_t * create_proc_entry(const char *name, mode_t mod,
cfs_proc_entry_t *parent);
void proc_free_entry(cfs_proc_entry_t *de);
-void remove_proc_entry(char *name, cfs_proc_entry_t *entry);
-cfs_proc_entry_t * search_proc_entry(char * name,
+void remove_proc_entry(const char *name, cfs_proc_entry_t *entry);
+cfs_proc_entry_t * search_proc_entry(const char * name,
cfs_proc_entry_t * root );
+cfs_proc_entry_t *proc_symlink(const char *name,
+ cfs_proc_entry_t *parent,
+ const char *dest);
+cfs_proc_entry_t *proc_mkdir(const char *name,
+ cfs_proc_entry_t *parent);
#define cfs_create_proc_entry create_proc_entry
#define cfs_free_proc_entry proc_free_entry
#define cfs_remove_proc_entry remove_proc_entry
-#define register_cfs_sysctl_table(t, a) register_sysctl_table(t, a)
-#define unregister_cfs_sysctl_table(t) unregister_sysctl_table(t, a)
+struct ctl_table_header *register_sysctl_table(cfs_sysctl_table_t * table,
+ int insert_at_head);
+void unregister_sysctl_table(struct ctl_table_header * header);
+
+#define cfs_register_sysctl_table(t, a) register_sysctl_table(t, a)
+#define cfs_unregister_sysctl_table(t) unregister_sysctl_table(t)
+
+/*
+ * seq device (linux/seq_file.h)
+ */
+
+
+/*
+ * seq file definitions
+ */
+
+struct dentry;
+struct vfsmount;
+
+struct path {
+ struct vfsmount *mnt;
+ struct dentry *dentry;
+};
+
+struct seq_operations;
+struct file;
+struct inode;
+
+struct seq_file {
+ char *buf;
+ size_t size;
+ size_t from;
+ size_t count;
+ loff_t index;
+ u32 version;
+ mutex_t lock;
+ const struct seq_operations *op;
+ void *private;
+};
+
+struct seq_operations {
+ void * (*start) (struct seq_file *m, loff_t *pos);
+ void (*stop) (struct seq_file *m, void *v);
+ void * (*next) (struct seq_file *m, void *v, loff_t *pos);
+ int (*show) (struct seq_file *m, void *v);
+};
+
+int seq_open(struct file *, const struct seq_operations *);
+ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
+loff_t seq_lseek(struct file *, loff_t, int);
+int seq_release(struct inode *, struct file *);
+int seq_escape(struct seq_file *, const char *, const char *);
+int seq_putc(struct seq_file *m, char c);
+int seq_puts(struct seq_file *m, const char *s);
+
+int seq_printf(struct seq_file *, const char *, ...)
+ __attribute__ ((format (printf,2,3)));
+int seq_path(struct seq_file *, struct path *, char *);
+
+int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
+int single_release(struct inode *, struct file *);
+void *__seq_open_private(struct file *, const struct seq_operations *, int);
+int seq_open_private(struct file *, const struct seq_operations *, int);
+int seq_release_private(struct inode *, struct file *);
+
+#define SEQ_START_TOKEN ((void *)1)
+
+/*
+ * Helpers for iteration over list_head-s in seq_files
+ */
+
+extern struct list_head *seq_list_start(struct list_head *head,
+ loff_t pos);
+extern struct list_head *seq_list_start_head(struct list_head *head,
+ loff_t pos);
+extern struct list_head *seq_list_next(void *v, struct list_head *head,
+ loff_t *ppos);
/*
* declaration of proc kernel process routines
int
lustre_do_ioctl( cfs_file_t * fh,
unsigned long cmd,
- ulong_ptr arg );
+ ulong_ptr_t arg );
int
lustre_ioctl_file( cfs_file_t * fh,
size_t
lustre_read_file( cfs_file_t * fh,
- loff_t off,
+ loff_t offl,
size_t size,
char * buf
);
#define CFS_TASK_INTERRUPTIBLE 0x00000001
#define CFS_TASK_UNINT 0x00000002
#define CFS_TASK_RUNNING 0x00000003
-
+#define CFS_TASK_UNINTERRUPTIBLE CFS_TASK_UNINT
#define CFS_WAITQ_MAGIC 'CWQM'
#define CFS_WAITLINK_MAGIC 'CWLM'
#define CFS_DECL_WAITQ(name) cfs_waitq_t name
-
-void cfs_waitq_init(struct cfs_waitq *waitq);
-void cfs_waitlink_init(struct cfs_waitlink *link);
-
-void cfs_waitq_add(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void cfs_waitq_add_exclusive(struct cfs_waitq *waitq,
- struct cfs_waitlink *link);
-void cfs_waitq_del(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-int cfs_waitq_active(struct cfs_waitq *waitq);
-
-void cfs_waitq_signal(struct cfs_waitq *waitq);
-void cfs_waitq_signal_nr(struct cfs_waitq *waitq, int nr);
-void cfs_waitq_broadcast(struct cfs_waitq *waitq);
-
-void cfs_waitq_wait(struct cfs_waitlink *link, cfs_task_state_t state);
-cfs_duration_t cfs_waitq_timedwait(struct cfs_waitlink *link,
- cfs_task_state_t state, cfs_duration_t timeout);
-
-
-
/* Kernel thread */
typedef int (*cfs_thread_t) (void *arg);
} cfs_thread_context_t;
int cfs_kernel_thread(int (*func)(void *), void *arg, int flag);
+#define kernel_thread cfs_kernel_thread
/*
* thread creation flags from Linux, not used in winnt
/*
- * sigset ...
+ * group_info: linux/sched.h
*/
+#define NGROUPS_SMALL 32
+#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))
+struct group_info {
+ int ngroups;
+ atomic_t usage;
+ gid_t small_block[NGROUPS_SMALL];
+ int nblocks;
+ gid_t *blocks[0];
+};
-typedef sigset_t cfs_sigset_t;
+#define get_group_info(group_info) do { \
+ atomic_inc(&(group_info)->usage); \
+} while (0)
+
+#define put_group_info(group_info) do { \
+ if (atomic_dec_and_test(&(group_info)->usage)) \
+ groups_free(group_info); \
+} while (0)
+
+static __inline struct group_info *groups_alloc(int gidsetsize)
+{
+ struct group_info * groupinfo;
+ KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+ groupinfo = (struct group_info *)cfs_alloc(sizeof(struct group_info), 0);
+ if (groupinfo) {
+ memset(groupinfo, 0, sizeof(struct group_info));
+ }
+ return groupinfo;
+}
+static __inline void groups_free(struct group_info *group_info)
+{
+ KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+ cfs_free(group_info);
+}
+static __inline int set_current_groups(struct group_info *group_info) {
+ KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+ return 0;
+}
+static __inline int groups_search(struct group_info *group_info, gid_t grp) {
+ KdPrint(("%s(%d): %s NOT implemented.\n", __FILE__, __LINE__, __FUNCTION__));
+ return 0;
+}
/*
- * Task struct
+ * capability issue (linux/capability.h)
*/
-#define MAX_SCHEDULE_TIMEOUT ((long_ptr)(~0UL>>12))
+/* Override resource limits. Set resource limits. */
+/* Override quota limits. */
+/* Override reserved space on ext2 filesystem */
+/* Modify data journaling mode on ext3 filesystem (uses journaling
+ resources) */
+/* NOTE: ext2 honors fsuid when checking for resource overrides, so
+ you can override using fsuid too */
+/* Override size restrictions on IPC message queues */
+/* Allow more than 64hz interrupts from the real-time clock */
+/* Override max number of consoles on console allocation */
+/* Override max number of keymaps */
+#define CAP_SYS_RESOURCE 24
-#define NGROUPS 1
-#define CFS_CURPROC_COMM_MAX (16)
-typedef struct task_sruct{
- mode_t umask;
+/*
+ * capabilities support
+ */
+
+typedef __u32 cfs_kernel_cap_t;
+
+#define cap_raise(c, flag) do {} while(0)
+#define cap_lower(c, flag) do {} while(0)
+#define cap_raised(c, flag) do {} while(0)
- pid_t pid;
- pid_t pgrp;
- uid_t uid,euid,suid,fsuid;
- gid_t gid,egid,sgid,fsgid;
+/*
+ * Task struct
+ */
+
+#define MAX_SCHEDULE_TIMEOUT ((long_ptr_t)(~0UL>>12))
+#define schedule_timeout(t) cfs_schedule_timeout(0, t)
- int ngroups;
- gid_t groups[NGROUPS];
- cfs_kernel_cap_t cap_effective,
- cap_inheritable,
- cap_permitted;
+struct vfsmount;
- char comm[CFS_CURPROC_COMM_MAX];
- void * journal_info;
+#define NGROUPS 1
+#define CFS_CURPROC_COMM_MAX (16)
+typedef struct task_sruct{
+ mode_t umask;
+ sigset_t blocked;
+
+ pid_t pid;
+ pid_t pgrp;
+
+ uid_t uid,euid,suid,fsuid;
+ gid_t gid,egid,sgid,fsgid;
+
+ int ngroups;
+ int cgroups;
+ gid_t groups[NGROUPS];
+ struct group_info *group_info;
+ cfs_kernel_cap_t cap_effective,
+ cap_inheritable,
+ cap_permitted;
+
+ char comm[CFS_CURPROC_COMM_MAX];
+ void *journal_info;
+ struct vfsmount *fs;
} cfs_task_t;
+static inline void task_lock(cfs_task_t *t)
+{
+}
+
+static inline void task_unlock(cfs_task_t *t)
+{
+}
/*
* linux task struct emulator ...
} TASK_SLOT, *PTASK_SLOT;
-#define current cfs_current()
-#define set_current_state(s) do {;} while (0)
-
-#define wait_event(wq, condition) \
-do { \
- cfs_waitlink_t __wait; \
- \
- cfs_waitlink_init(&__wait); \
- while (TRUE) { \
- cfs_waitq_add(&wq, &__wait); \
- if (condition) { \
- break; \
- } \
- cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE); \
- cfs_waitq_del(&wq, &__wait); \
- } \
- cfs_waitq_del(&wq, &__wait); \
+#define current cfs_current()
+#define set_current_state(s) do {;} while (0)
+#define cfs_set_current_state(state) set_current_state(state)
+
+#define wait_event(wq, condition) \
+do { \
+ cfs_waitlink_t __wait; \
+ \
+ cfs_waitlink_init(&__wait); \
+ while (TRUE) { \
+ cfs_waitq_add(&wq, &__wait); \
+ if (condition) { \
+ break; \
+ } \
+ cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE); \
+ cfs_waitq_del(&wq, &__wait); \
+ } \
+ cfs_waitq_del(&wq, &__wait); \
} while(0)
-#define wait_event_interruptible(wq, condition, __ret) \
-do { \
- cfs_waitlink_t __wait; \
- \
- __ret = 0; \
- cfs_waitlink_init(&__wait); \
- while (TRUE) { \
- cfs_waitq_add(&wq, &__wait); \
- if (condition) { \
- break; \
- } \
- cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE); \
- cfs_waitq_del(&wq, &__wait); \
- } \
- cfs_waitq_del(&wq, &__wait); \
+#define cfs_wait_event_interruptible(wq, condition, __ret) \
+do { \
+ cfs_waitlink_t __wait; \
+ \
+ __ret = 0; \
+ cfs_waitlink_init(&__wait); \
+ while (TRUE) { \
+ cfs_waitq_add(&wq, &__wait); \
+ if (condition) { \
+ break; \
+ } \
+ cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE); \
+ cfs_waitq_del(&wq, &__wait); \
+ } \
+ cfs_waitq_del(&wq, &__wait); \
} while(0)
+# define cfs_wait_event_interruptible_exclusive(wq, condition, rc) \
+ cfs_wait_event_interruptible(wq, condition, rc)
+
+/*
+ retval == 0; condition met; we're good.
+ retval < 0; interrupted by signal.
+ retval > 0; timed out.
+*/
+
+#define cfs_waitq_wait_event_interruptible_timeout( \
+ wq, condition, timeout, rc) \
+do { \
+ cfs_waitlink_t __wait; \
+ \
+ rc = 0; \
+ cfs_waitlink_init(&__wait); \
+ while (TRUE) { \
+ cfs_waitq_add(&wq, &__wait); \
+ if (condition) { \
+ break; \
+ } \
+ if (cfs_waitq_timedwait(&__wait, \
+ CFS_TASK_INTERRUPTIBLE, timeout) == 0) { \
+ rc = TRUE; \
+ break; \
+ } \
+ cfs_waitq_del(&wq, &__wait); \
+ } \
+ cfs_waitq_del(&wq, &__wait); \
+} while(0)
+
+
+#define cfs_waitq_wait_event_timeout \
+ cfs_waitq_wait_event_interruptible_timeout
int init_task_manager();
void cleanup_task_manager();
cfs_task_t * cfs_current();
-int schedule_timeout(int64_t time);
-int schedule();
int wake_up_process(cfs_task_t * task);
-#define cfs_schedule_timeout(state, time) schedule_timeout(time)
void sleep_on(cfs_waitq_t *waitq);
-
+#define might_sleep() do {} while(0)
#define CFS_DECL_JOURNAL_DATA
#define CFS_PUSH_JOURNAL do {;} while(0)
#define CFS_POP_JOURNAL do {;} while(0)
#define __init
#endif
-#define request_module(x) (0)
+struct module {
+ const char *name;
+};
+
+extern struct module libcfs_global_module;
+#define THIS_MODULE &libcfs_global_module
+#define request_module(x) (0)
#define EXPORT_SYMBOL(s)
#define MODULE_AUTHOR(s)
#define MODULE_DESCRIPTION(s)
#define cfs_module(name, version, init, fini) \
module_init(init); \
module_exit(fini)
+#define module_refcount(x) (1)
+/*
+ * typecheck
+ */
+
+#define typecheck(a, b) do {} while(0)
/*
- * Linux kernel version definition
+ * linux/crypto.h
*/
-#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-#define LINUX_VERSION_CODE (2*100+6*10+7)
+#define CRYPTO_MAX_ALG_NAME 64
+#define CRYPTO_TFM_MODE_ECB 0x00000001
+#define CRYPTO_TFM_MODE_CBC 0x00000002
+#define CRYPTO_TFM_MODE_CFB 0x00000004
+#define CRYPTO_TFM_MODE_CTR 0x00000008
+#define CRYPTO_TFM_MODE_EME 0x00000010
/*
- * Signal
+ * hash
*/
-#define SIGNAL_MASK_ASSERT()
+/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
+#define GOLDEN_RATIO_PRIME_32 0x9e370001UL
+
+#if 0 /* defined in libcfs/libcfs_hash.h */
+static inline u32 hash_long(u32 val, unsigned int bits)
+{
+ /* On some cpus multiply is faster, on others gcc will do shifts */
+ u32 hash = val * GOLDEN_RATIO_PRIME_32;
+
+ /* High bits are more random, so use them. */
+ return hash >> (32 - bits);
+}
+#endif
/*
* Timer
cfs_time_t deadline;
- void (*proc)(ulong_ptr);
+ void (*proc)(ulong_ptr_t);
void * arg;
} cfs_timer_t;
-
-typedef void (*timer_func_t)(ulong_ptr);
-
-#define cfs_init_timer(t)
-
-void cfs_timer_init(cfs_timer_t *timer, void (*func)(ulong_ptr), void *arg);
-void cfs_timer_done(cfs_timer_t *t);
-void cfs_timer_arm(cfs_timer_t *t, cfs_time_t deadline);
-void cfs_timer_disarm(cfs_timer_t *t);
-int cfs_timer_is_armed(cfs_timer_t *t);
-cfs_time_t cfs_timer_deadline(cfs_timer_t *t);
-
-
-/* deschedule for a bit... */
-static inline void cfs_pause(cfs_duration_t ticks)
-{
- cfs_schedule_timeout(TASK_UNINTERRUPTIBLE, ticks);
-}
-
-
-static inline void cfs_enter_debugger(void)
-{
-#if _X86_
- __asm int 3;
-#else
- KdBreakPoint();
-#endif
-}
-
/*
* libcfs globals initialization/cleanup
*/
libcfs_arch_cleanup(void);
/*
+ * cache alignment size
+ */
+
+#define L1_CACHE_ALIGN(x) (x)
+
+#define __cacheline_aligned
+
+/*
* SMP ...
*/
+
#define SMP_CACHE_BYTES 128
-#define __cacheline_aligned
-#define NR_CPUS (2)
-#define smp_processor_id() KeGetCurrentProcessorNumber()
-#define smp_num_cpus NR_CPUS
-#define num_online_cpus() smp_num_cpus
+#define NR_CPUS (32)
+#define smp_num_cpus ((CCHAR)KeNumberProcessors)
+#define num_possible_cpus() smp_num_cpus
+#define num_online_cpus() smp_num_cpus
+#define smp_processor_id() ((USHORT)KeGetCurrentProcessorNumber())
#define smp_call_function(f, a, n, w) do {} while(0)
+#define smp_rmb() do {} while(0)
/*
* Irp related
*/
-#define NR_IRQS 512
-#define in_interrupt() (0)
+#define NR_IRQS 512
+#define in_interrupt() (0)
+#define cfs_in_interrupt() in_interrupt()
/*
* printk flags
* Misc
*/
-
#define inter_module_get(n) cfs_symbol_get(n)
#define inter_module_put(n) cfs_symbol_put(n)
#define lock_kernel() do {} while(0)
#define unlock_kernel() do {} while(0)
-#define USERMODEHELPER(path, argv, envp) (0)
-
-
#define local_irq_save(x)
#define local_irq_restore(x)
-#define cfs_assert ASSERT
-
#define THREAD_NAME
-#else /* !__KERNEL__ */
+#define va_copy(_d, _s) (_d = _s)
-#define PAGE_CACHE_SIZE PAGE_SIZE
-#define PAGE_CACHE_MASK PAGE_MASK
+char *strnchr(const char *s, size_t count, int c);
-#define getpagesize() (PAGE_SIZE)
+#define adler32(a,b,l) zlib_adler32(a,b,l)
+ULONG zlib_adler32(ULONG adler, const BYTE *buf, UINT len);
+typedef ssize_t (*read_actor_t)();
-typedef struct {
- int foo;
-} pthread_mutex_t;
+#if DBG
+/*
+ * winnt debug routines
+ */
-typedef struct {
- int foo;
-} pthread_cond_t;
+VOID
+KsPrintf(
+ LONG DebugPrintLevel,
+ PCHAR DebugMessage,
+ ...
+ );
-#define pthread_mutex_init(x, y) do {} while(0)
-#define pthread_cond_init(x, y) do {} while(0)
+PUCHAR
+KsNtStatusToString (IN NTSTATUS Status);
+#endif
-#define pthread_mutex_lock(x) do {} while(0)
-#define pthread_mutex_unlock(x) do {} while(0)
+#else /* !__KERNEL__ */
-#define pthread_cond_wait(x,y) do {} while(0)
-#define pthread_cond_broadcast(x) do {} while(0)
+void cfs_enter_debugger();
-typedef struct file {
- int foo;
-} cfs_file_t;
+/*
+ * PAGE_SIZE ...
+ */
-typedef struct cfs_proc_dir_entry{
- void *data;
-}cfs_proc_dir_entry_t;
+#ifndef PAGE_SIZE
+#define PAGE_SIZE (4096)
+#endif
+#define getpagesize() (4096)
+#define PAGE_CACHE_SIZE PAGE_SIZE
+#define PAGE_CACHE_MASK PAGE_MASK
-#include "../user-prim.h"
+#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t) -2)
+#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t) -3)
+typedef struct file {
+ int foo;
+} cfs_file_t;
+
+#include "../user-prim.h"
+#include "../user-lock.h"
#include <sys/stat.h>
#include <sys/types.h>
#define strcasecmp strcmp
#define strncasecmp strncmp
-#define snprintf _snprintf
#define getpid() (0)
-
-#define getpwuid(x) (NULL)
+#define getuid() (0)
#define getgrgid(x) (NULL)
+struct passwd {
+ uid_t pw_uid;
+ char pw_name[64];
+};
+struct passwd * getpwuid(uid_t uid);
+
int cfs_proc_mknod(const char *path, mode_t mode, dev_t dev);
int gethostname(char * name, int namelen);
#define setlinebuf(x) do {} while(0)
-NTSYSAPI VOID NTAPI DebugBreak();
+/* Maximum EA Information Length */
+#define EA_MAX_LENGTH (sizeof(FILE_FULL_EA_INFORMATION) + 15)
+/*
+ * proc user mode routines
+ */
-static inline void cfs_enter_debugger(void)
-{
-#if _X86_
- __asm int 3;
+int cfs_proc_open (char * filename, int oflag);
+int cfs_proc_close(int fd);
+int cfs_proc_read(int fd, void *buffer, unsigned int count);
+int cfs_proc_write(int fd, void *buffer, unsigned int count);
+int cfs_proc_ioctl(int fd, int cmd, void *buffer);
+FILE *cfs_proc_fopen(char *path, char * mode);
+char *cfs_proc_fgets(char * buf, int len, FILE *fp);
+int cfs_proc_fclose(FILE *fp);
+
+/* Bits set in the FLAGS argument to `glob'. */
+#define GLOB_ERR (1 << 0)/* Return on read errors. */
+#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
+#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */
+#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */
+#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */
+#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */
+#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */
+#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */
+
+#if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
+# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
+# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
+# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
+# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */
+# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */
+# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */
+# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
+ if the user name is not available. */
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
+ GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
#else
- DebugBreak();
+# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+ GLOB_PERIOD)
#endif
-}
-/* Maximum EA Information Length */
-#define EA_MAX_LENGTH (sizeof(FILE_FULL_EA_INFORMATION) + 15)
+/* Error returns from `glob'. */
+#define GLOB_NOSPACE 1 /* Ran out of memory. */
+#define GLOB_ABORTED 2 /* Read error. */
+#define GLOB_NOMATCH 3 /* No matches found. */
+#define GLOB_NOSYS 4 /* Not implemented. */
+#ifdef __USE_GNU
+/* Previous versions of this file defined GLOB_ABEND instead of
+ GLOB_ABORTED. Provide a compatibility definition here. */
+# define GLOB_ABEND GLOB_ABORTED
+#endif
+
+/* Structure describing a globbing run. */
+#ifdef __USE_GNU
+struct stat;
+#endif
+typedef struct
+ {
+ size_t gl_pathc; /* Count of paths matched by the pattern. */
+ char **gl_pathv; /* List of matched pathnames. */
+ size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
+ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) (void *);
+#ifdef __USE_GNU
+ struct dirent *(*gl_readdir) (void *);
+#else
+ void *(*gl_readdir) (void *);
+#endif
+ void *(*gl_opendir) (const char *);
+#ifdef __USE_GNU
+ int (*gl_lstat) (const char *__restrict, struct stat *__restrict);
+ int (*gl_stat) (const char *__restrict, struct stat *__restrict);
+#else
+ int (*gl_lstat) (const char *__restrict, void *__restrict);
+ int (*gl_stat) (const char *__restrict, void *__restrict);
+#endif
+ } glob_t;
+
+#ifdef __USE_LARGEFILE64
+# ifdef __USE_GNU
+struct stat64;
+# endif
+typedef struct
+ {
+ __size_t gl_pathc;
+ char **gl_pathv;
+ __size_t gl_offs;
+ int gl_flags;
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) (void *);
+# ifdef __USE_GNU
+ struct dirent64 *(*gl_readdir) (void *);
+# else
+ void *(*gl_readdir) (void *);
+# endif
+ void *(*gl_opendir) (__const char *);
+# ifdef __USE_GNU
+ int (*gl_lstat) (__const char *__restrict, struct stat64 *__restrict);
+ int (*gl_stat) (__const char *__restrict, struct stat64 *__restrict);
+# else
+ int (*gl_lstat) (__const char *__restrict, void *__restrict);
+ int (*gl_stat) (__const char *__restrict, void *__restrict);
+# endif
+ } glob64_t;
+#endif
+
+int glob (const char * __pattern, int __flags,
+ int (*__errfunc) (const char *, int),
+ glob_t * __pglob);
+void globfree(glob_t *__pglog);
+#endif /* !__KERNEL__ */
/*
- * proc user mode routines
+ * module routines
*/
-HANDLE cfs_proc_open (char * filename, int oflag);
-int cfs_proc_close(HANDLE handle);
-int cfs_proc_read(HANDLE handle, void *buffer, unsigned int count);
-int cfs_proc_write(HANDLE handle, void *buffer, unsigned int count);
-int cfs_proc_ioctl(HANDLE handle, int cmd, void *buffer);
+static inline void __module_get(struct module *module)
+{
+}
+static inline int try_module_get(struct module *module)
+{
+ return 1;
+}
+
+static inline void module_put(struct module *module)
+{
+}
/*
- * Native API definitions
+ * sigset_t routines
*/
-//
-// Disk I/O Routines
-//
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtReadFile(HANDLE FileHandle,
- HANDLE Event OPTIONAL,
- PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- PVOID ApcContext OPTIONAL,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset OPTIONAL,
- PULONG Key OPTIONAL);
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtWriteFile(HANDLE FileHandle,
- HANDLE Event OPTIONAL,
- PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- PVOID ApcContext OPTIONAL,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID Buffer,
- ULONG Length,
- PLARGE_INTEGER ByteOffset OPTIONAL,
- PULONG Key OPTIONAL);
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtClose(HANDLE Handle);
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtCreateFile(PHANDLE FileHandle,
- ACCESS_MASK DesiredAccess,
- POBJECT_ATTRIBUTES ObjectAttributes,
- PIO_STATUS_BLOCK IoStatusBlock,
- PLARGE_INTEGER AllocationSize OPTIONAL,
- ULONG FileAttributes,
- ULONG ShareAccess,
- ULONG CreateDisposition,
- ULONG CreateOptions,
- PVOID EaBuffer OPTIONAL,
- ULONG EaLength);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtDeviceIoControlFile(
- IN HANDLE FileHandle,
- IN HANDLE Event,
- IN PIO_APC_ROUTINE ApcRoutine,
- IN PVOID ApcContext,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG IoControlCode,
- IN PVOID InputBuffer,
- IN ULONG InputBufferLength,
- OUT PVOID OutputBuffer,
- OUT ULONG OutputBufferLength
- );
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtFsControlFile(
- IN HANDLE FileHandle,
- IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
- IN PVOID ApcContext OPTIONAL,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN ULONG FsControlCode,
- IN PVOID InputBuffer OPTIONAL,
- IN ULONG InputBufferLength,
- OUT PVOID OutputBuffer OPTIONAL,
- IN ULONG OutputBufferLength
-);
-
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtQueryInformationFile(
- IN HANDLE FileHandle,
- OUT PIO_STATUS_BLOCK IoStatusBlock,
- OUT PVOID FileInformation,
- IN ULONG Length,
- IN FILE_INFORMATION_CLASS FileInformationClass
- );
+typedef sigset_t cfs_sigset_t;
+#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
+#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
+#define sigemptyset(what) (*(what) = 0, 0)
+#define sigfillset(what) (*(what) = ~(0), 0)
+#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
+
+static __inline int
+sigprocmask(int sig, cfs_sigset_t *w1, cfs_sigset_t *w2) {
+ return 0;
+}
+static __inline int
+sigpending(cfs_sigset_t *what) {
+ return 0;
+}
+
+/*
+ * common inode flags (user & kernel)
+ */
-//
-// Random routines ...
-//
-
-NTSYSAPI
-ULONG
-NTAPI
-RtlRandom(
- IN OUT PULONG Seed
- );
-
-#endif /* __KERNEL__ */
-
-
-//
-// Inode flags (Linux uses octad number, but why ? strange!!!)
-//
-
-#undef S_IFMT
-#undef S_IFDIR
-#undef S_IFCHR
-#undef S_IFREG
-#undef S_IREAD
-#undef S_IWRITE
-#undef S_IEXEC
-
-#define S_IFMT 0x0F000 /* 017 0000 */
-#define S_IFSOCK 0x0C000 /* 014 0000 */
-#define S_IFLNK 0x0A000 /* 012 0000 */
-#define S_IFREG 0x08000 /* 010 0000 */
-#define S_IFBLK 0x06000 /* 006 0000 */
-#define S_IFDIR 0x04000 /* 004 0000 */
-#define S_IFCHR 0x02000 /* 002 0000 */
-#define S_IFIFO 0x01000 /* 001 0000 */
-#define S_ISUID 0x00800 /* 000 4000 */
-#define S_ISGID 0x00400 /* 000 2000 */
-#define S_ISVTX 0x00200 /* 000 1000 */
-
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#define S_ISFIL(m) (((m) & S_IFMT) == S_IFFIL)
-#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-
-#define S_IPERMISSION_MASK 0x1FF /* */
-
-#define S_IRWXU 0x1C0 /* 0 0700 */
-#define S_IRUSR 0x100 /* 0 0400 */
-#define S_IWUSR 0x080 /* 0 0200 */
-#define S_IXUSR 0x040 /* 0 0100 */
-
-#define S_IRWXG 0x038 /* 0 0070 */
-#define S_IRGRP 0x020 /* 0 0040 */
-#define S_IWGRP 0x010 /* 0 0020 */
-#define S_IXGRP 0x008 /* 0 0010 */
-
-#define S_IRWXO 0x007 /* 0 0007 */
-#define S_IROTH 0x004 /* 0 0004 */
-#define S_IWOTH 0x002 /* 0 0002 */
-#define S_IXOTH 0x001 /* 0 0001 */
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+
+#define S_IRWXU 00700
+#define S_IRUSR 00400
+#define S_IWUSR 00200
+#define S_IXUSR 00100
+
+#define S_IRWXG 00070
+#define S_IRGRP 00040
+#define S_IWGRP 00020
+#define S_IXGRP 00010
+
+#define S_IRWXO 00007
+#define S_IROTH 00004
+#define S_IWOTH 00002
+#define S_IXOTH 00001
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
+
+/*
+ * Linux kernel version definition
+ */
+
+#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
+
/*
* linux ioctl coding definitions
*/
#define _IOC_SIZEBITS 14
#define _IOC_DIRBITS 2
-#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
-/*
- * Io vector ...
- */
-
-struct iovec
-{
+/* i/o vector sgructure ... */
+struct iovec {
void *iov_base;
size_t iov_len;
};
+/* idr support routines */
+struct idr_context *cfs_idr_init();
+int cfs_idr_remove(struct idr_context *idp, int id);
+int cfs_idr_get_new(struct idr_context *idp, void *ptr);
+int cfs_idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id);
+void *cfs_idr_find(struct idr_context *idp, int id);
+void cfs_idr_exit(struct idr_context *idp);
+
+/* runtime time routines for both kenrel and user mode */
+extern int cfs_isalpha(int);
+extern int cfs_isspace(int);
+extern int cfs_isupper(int);
+extern int cfs_isdigit(int);
+extern int cfs_isxdigit(int);
#define ULONG_LONG_MAX ((__u64)(0xFFFFFFFFFFFFFFFF))
/*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
-static inline __u64
-strtoull(
- char *nptr,
- char **endptr,
- int base)
+__u64 strtoull(char *nptr, char **endptr,int base);
+
+/*
+ * getopt routines
+ */
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+ for unrecognized options. */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized. */
+
+extern int optopt;
+
+
+struct option
{
- char *s = nptr;
- __u64 acc, cutoff;
- int c, neg = 0, any, cutlim;
-
- /*
- * See strtol for comments as to the logic used.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- cutoff = (__u64)ULONG_LONG_MAX / (__u64)base;
- cutlim = (int)((__u64)ULONG_LONG_MAX % (__u64)base);
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = ULONG_LONG_MAX;
- } else if (neg)
- acc = 0 - acc;
- if (endptr != 0)
- *endptr = (char *) (any ? s - 1 : nptr);
- return (acc);
-}
+ const char *name;
+ /* has_arg can't be an enum because some compilers complain about
+ type mismatches in all the code that assumes it is an int. */
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'. */
+# define no_argument 0
+# define required_argument 1
+# define optional_argument 2
+
+extern int getopt(int ___argc, char *const *___argv, const char *__shortopts);
+extern int getopt_long (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind);
+extern int getopt_long_only (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind);
+
+extern char *strcasestr (const char *phaystack, const char *pneedle);
+
+/*
+ * global environment runtime routine
+ */
+
+static __inline char * __cdecl cfs_getenv(const char *ENV) {return NULL;}
+static __inline void __cdecl set_getenv(const char *ENV, const char *value, int overwrite) {}
+
+int setenv(const char *envname, const char *envval, int overwrite);
+
+struct utsname {
+ char sysname[64];
+ char nodename[64];
+ char release[128];
+ char version[128];
+ char machine[64];
+};
+
+int uname(struct utsname *uts);
#endif