Home | History | Annotate | Line # | Download | only in zbsdmod
compat_linux.h revision 1.1
      1 /*	$OpenBSD: compat_linux.h,v 1.5 2006/01/15 17:58:27 deraadt Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2005 Uwe Stuehler <uwe (at) bsdx.de>
      5  *
      6  * Permission to use, copy, modify, and distribute this software for any
      7  * purpose with or without fee is hereby granted, provided that the above
      8  * copyright notice and this permission notice appear in all copies.
      9  *
     10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17  */
     18 
     19 /*
     20  * Declare the things that we need from the Linux headers.
     21  */
     22 
     23 #define	IS_ERR(ptr)	((unsigned long)(ptr) > (unsigned long)-1000L)
     24 
     25 #define MKDEV(ma,mi)	((ma)<<8 | (mi))
     26 
     27 #define S_IFBLK		0060000
     28 #define S_IFCHR		0020000
     29 
     30 struct file;
     31 struct inode;
     32 
     33 #define	ELFSIZE	32
     34 #include <sys/exec_elf.h>
     35 #include <sys/types.h>
     36 #include <sys/errno.h>
     37 
     38 typedef long loff_t;
     39 
     40 struct file_operations {
     41 	struct module *owner;
     42 	void (*llseek) (void);
     43 	ssize_t (*read) (struct file *, char *, size_t, loff_t *);
     44 	ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
     45 	void (*readdir) (void);
     46 	void (*poll) (void);
     47 	void (*ioctl) (void);
     48 	void (*mmap) (void);
     49 	int (*open) (struct inode *, struct file *);
     50 	void (*flush) (void);
     51 	int (*release) (struct inode *, struct file *);
     52 	void (*fsync) (void);
     53 	void (*fasync) (void);
     54 	void (*lock) (void);
     55 	void (*readv) (void);
     56 	void (*writev) (void);
     57 	void (*sendpage) (void);
     58 	void (*get_unmapped_area)(void);
     59 #ifdef MAGIC_ROM_PTR
     60 	void (*romptr) (void);
     61 #endif /* MAGIC_ROM_PTR */
     62 };
     63 
     64 extern	struct file *open_exec(const char *);
     65 extern	void fput(struct file *);
     66 extern	int kernel_read(struct file *, unsigned long, char *, unsigned long);
     67 extern	int memcmp(const void *, const void *, size_t);
     68 extern	int register_chrdev(unsigned int, const char *, struct file_operations *);
     69 extern	int unregister_chrdev(unsigned int, const char *);
     70 extern	void printk(const char *, ...);
     71 extern	void *memcpy(void *, const void *, size_t);
     72 
     73 /* Linux LKM support */
     74 static const char __module_kernel_version[] __attribute__((section(".modinfo"))) =
     75 "kernel_version=" UTS_RELEASE;
     76 static const char __module_using_checksums[] __attribute__((section(".modinfo"))) =
     77 "using_checksums=1";
     78 
     79 /* procfs support */
     80 struct proc_dir_entry {
     81         unsigned short low_ino;
     82         unsigned short namelen;
     83         const char *name;
     84         unsigned short mode;
     85         unsigned short nlink;
     86         unsigned short uid;
     87         unsigned short gid;
     88         unsigned long size;
     89         void *proc_iops; /* inode operations */
     90         struct file_operations * proc_fops;
     91         void *get_info;
     92         struct module *owner;
     93         struct proc_dir_entry *next, *parent, *subdir;
     94         void *data;
     95         void *read_proc;
     96         void *write_proc;
     97         volatile int count;
     98         int deleted;
     99         unsigned short rdev;
    100 };
    101 extern	struct proc_dir_entry proc_root;
    102 extern	struct proc_dir_entry *proc_mknod(const char*, unsigned short,
    103     struct proc_dir_entry*, unsigned short);
    104 extern	void remove_proc_entry(const char *, struct proc_dir_entry *);
    105