linuxÇý¶¯ ×ÔÐýËøµÄÔËÓÃ
linuxÇý¶¯ ×ÔÐýËøµÄÔËÓÃ
//hello.c
#define __NO_VERSION__
#include <linux/module.h>
#include <linux/config.h>
#include <linux/version.h>
#include <asm/uaccess.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <asm/page.h>
#include <linux/poll.h>
#include <linux/kdev_t.h>
#include <asm/semaphore.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
unsigned int test_major = 0;
static int global_var=0;
static int globalvar_count = 0;
char *mystr="wodeshen" ;
static struct semaphore sem;
static spinlock_t spin = SPIN_LOCK_UNLOCKED; //ºê¶¨Òå ÒѾ³õʼ»¯
static ssize_t read_test(struct file *file,char *buf,size_t count,loff_t *f_pos)
{
int left;
printk(KERN_INFO "read_test\n");
if (verify_area(VERIFY_WRITE,buf,count) == -EFAULT )
return -EFAULT;
if (down_interruptible(&sem))
{
return - ERESTARTSYS;
}
printk("copy_to_user======2=======\n");
copy_to_user(buf, mystr, strlen(mystr));
/*
for(left = count ; left > 0 ; left--)
{
__put_user('1',buf);
buf++;
}
*/
up(&sem);
//return sizeof(int);
return strlen(mystr);
}
static ssize_t write_test(struct file *file, const char *buf, size_t count, loff_t *f_pos)
{
if (down_interruptible(&sem))
{
return - ERESTARTSYS;
}
if (copy_from_user(&global_var, buf, sizeof(int)))
{
up(&sem);
return - EFAULT;
}
up(&sem);
printk(KERN_INFO "write_test\n");
return sizeof(int);
}
static int open_test(struct inode *inode,struct file *file )
{
spin_lock(&spin);
printk("globalvar open\n");
//ÁÙ½ç×ÊÔ´·ÃÎÊ
if (globalvar_count)
{
spin_unlock(&spin);
return - EBUSY;
}
globalvar_count++;
//ÊÍ·Å×Ô
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......
shell ±à³ÌÖÐʹÓõ½µÃifÓï¾äÄÚÅжϲÎÊý
–b µ±file´æÔÚ²¢ÇÒÊÇ¿éÎļþʱ·µ»ØÕæ
-c µ±file´æÔÚ²¢ÇÒÊÇ×Ö·ûÎļþʱ·µ»ØÕæ
-d µ±pathname´æÔÚ²¢ÇÒÊÇÒ»¸öĿ¼ʱ·µ»ØÕæ
-e µ±pathnameÖ¸¶¨µÄÎļþ»òĿ¼´æÔÚʱ·µ»ØÕæ
-f µ±file´æÔÚ²¢ÇÒÊÇÕý¹æÎļþʱ·µ»ØÕæ
-g µ±ÓÉpathnameÖ¸¶¨µÄÎļþ»òĿ¼´æÔÚ²¢ÇÒÉèÖÃÁËSGIDλʱ·µ»ØÎ ......
һ.ΪʲôҪѧlinux?
µ±È»×îÖØÒªÊÇ°®ºÃºÍÐËȤ£¡Èç¹ûÄãÕâÖÖ±ØҪѧ£¬»òÕ߸ù±¾²»Ï²»¶£¬Çë²»ÒªÀË·Ñʱ¼ä£¬ÄãѧҲѧ²»ºÃ£¡
¶þ.Æð²½
ÄãÓ¦¸ÃΪ×Ô¼º´´ÔìÒ»¸öѧϰlinuxµÄ»·¾³--ÔÚµçÄÔÉÏ×°Ò»¸ölinux»òunix
ÎÊÌâ1£º°æ±¾µÄÑ¡Ôñ
±±ÃÀÓÃredhat,Å·ÖÞÓÃSuSE,×ÀÃæmandrake½Ï¶à£¬¶ødebianÊǼ¼Êõ×îÏȽøµÄlinux
¿ª·¢ÈËÔ±ÖÐÓà ......
Parsing command line arguments:
Parameter "silent" = true
java.lang.ArrayIndexOutOfBoundsException: 2
at oracle.net.ca.CmdlineArgs.parseArgs(Unknown Source)
at oracle.net.ca.I ......