Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux 0.11 ÄÚºËѧϰ fcntl.c


/*
 *  linux/fs/fcntl.c
 *
 *  (C) 1991  Linus Torvalds
 */
#include <string.h>
#include <errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <asm/segment.h>
#include <fcntl.h>
#include <sys/stat.h>
extern int sys_close(int fd);
/* ¸´ÖÆÎļþ¾ä±ú£¬²ÎÊýfdÊÇÖ¸Ó븴ÖƵÄÎļþ¾ä±ú£¬argÊÇÖ¸¶¨ÐÂÎļþµÄ¾ä±úµÄ×îСֵ */
static int dupfd(unsigned int fd, unsigned int arg)
{
// Èç¹ûÎļþ¾ä±úÖµ´óÓÚÒ»¸ö³ÌÐò×î¶à´ò¿ªÎļþÊýNR_OPEN£¬»òÕ߸þä±úµÄÎļþ½á¹¹²»´æÔÚ£¬Ôò³ö´í£¬
// ·µ»Ø³ö´íÂë²¢Í˳ö
if (fd >= NR_OPEN || !current->filp[fd])
return -EBADF;
// Èç¹ûÖ¸¶¨µÄоä±úÖµarg ´óÓÚ×î¶à´ò¿ªÎļþÊý£¬Ôò³ö´í
if (arg >= NR_OPEN)
return -EINVAL;
// ÔÚµ±Ç°½ø³ÌµÄÎļþ½á¹¹Ö¸ÕëÊý×éÖÐÑ°ÕÒË÷ÒýºÅ´óÓÚµÈÓÚarg µ«»¹Ã»ÓÐʹÓõÄÏî
while (arg < NR_OPEN)
if (current->filp[arg])
arg++;
else
break;
// Èç¹ûÕÒµ½µÄоä±úÖµarg ´óÓÚ×î¶à´ò¿ªÎļþÊý£¬Ôò³ö´í
if (arg >= NR_OPEN)
return -EMFILE;
// ÔÚÔËÐÐexec()ÀຯÊýʱ²»¹Ø±Õ¸Ã¾ä±ú
current->close_on_exec &= ~(1<<arg);
// Áî¸ÃÎļþ½á¹¹Ö¸ÕëµÈÓÚÔ­¾ä±úfd µÄÖ¸Õ룬²¢½«ÎļþÒýÓüÆÊýÔö1
(current->filp[arg] = current->filp[fd])->f_count++;
return arg;
}
/* ¸´ÖÆÎļþ¾ä±úϵͳµ÷Óú¯Êý */
int sys_dup2(unsigned int oldfd, unsigned int newfd)
{
// Èô¾ä±únewfd ÒѾ­´ò¿ª£¬ÔòÊ×ÏȹرÕÖ®
sys_close(newfd);
// ¸´ÖƲ¢·µ»Øоä±ú
return dupfd(oldfd,newfd);
}
/* ¸´ÖÆÎļþ¾ä±úϵͳµ÷Óú¯Êý¡£Ð¾ä±úµÄÖµÊǵ±Ç°×îСµÄδÓþä±ú */
int sys_dup(unsigned int fildes)
{
return dupfd(fildes,0);
}
/* Îļþ¿ØÖÆϵͳµ÷Óú¯Êý */
int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
{
struct file * filp;
// Èç¹ûÎļþ¾ä±úÖµ´óÓÚÒ»¸ö½ø³Ì×î¶à´ò¿ªÎļþÊýNR_OPEN£¬»òÕ߸þä±úµÄÎļþ½á¹¹Ö¸ÕëΪ¿Õ£¬Ôò³ö´í£¬
// ·µ»Ø³ö´íÂë²¢Í˳ö
if (fd >= NR_OPEN || !(filp = current->filp[fd]))
return -EBADF;
switch (cmd)
{
case F_DUPFD: // ¸´ÖÆÎļþ¾ä±ú
return dupfd(fd,arg);
case F_GETFD: // È¡Îļþ¾ä±úµÄÖ


Ïà¹ØÎĵµ£º

Linuxѧϰ±Ê¼Ç——DHCP·þÎñ


£­¡¢¸ÅÄî
       1¡¢DHCP£º¶¯Ì¬Ö÷»úÅäÖÃЭÒé
                     ×÷ÓãºÓÃÓÚ¼ò»¯IPÅä¹ÜÀíµÄTCP/IP±ê×¼¡£
       2¡¢DHCP¹¤×÷Á÷³Ì£º
 &nb ......

linuxÏÂvncserverÅäÖÃÓëwinÏÂvnc¿Í»§¶Ë


linuxÏÂvncserverÅäÖÃÓëwinÏÂvnc¿Í»§¶Ë


8 Nov, 2008
 
¹ÜÀí&·þÎñ

< type="text/javascript"><!--
google_ad_client = "pub-7056129240767270";
/* 300x250, ´´½¨ÓÚ 09-2-13 */
google_ad_slot = "270491 ......

Unix/Linux ϵͳ×Ô¶¯»¯¹ÜÀí: ½ø³Ì¹ÜÀíƪ


Unix/Linux ½ø³Ì¹ÜÀíÏà¹ØÃüÁî½éÉÜ
½ø³ÌÊDzÙ×÷ϵͳÓÃÓÚ¿ØÖÆϵͳ×ÊԴʹÓõÄʵÌå¡£Unix/Linux ½ø³Ì¹ÜÀíÏà¹ØµÄÃüÁîÖ÷ÒªÓÐÒÔϼ¸¸ö£¬ÔÚºóÃæµÄ½Å±¾ÊµÏÖÖлáÓõ½²¿·ÖÃüÁî¡£
ÏÔʾ½ø³ÌÊôÐÔÃüÁî
ps ÃüÁ¸ÃÃüÁîÊÇ×î»ù±¾Í¬Ê±Ò²ÊǷdz£Ç¿´óµÄ½ø³Ì²é¿´ÃüÁÓÃÓÚ±¨¸æ½ø³Ì±êʶ¡¢Óû§¡¢CPU ʱ¼äÏûºÄÒÔ¼°ÆäËûÊôÐÔ¡£ÀûÓÃËü¿ÉÒÔÈ·¶¨ÓÐÄÄÐ ......

linuxʹÓü¼ÇÉ

ÎÒÓõ½µÄLinux¼¼ÇÉ 
1.linuxÉÏÍø:
ʹÓÃrootÓû§µÇ½ʹÓà adsl-setupÃüÁÅäÖÃppp0
³öÏÖdefault¾ÍĬÈϻسµ,²ÉÓÃĬÈÏÉèÖÃ
½øÈëDNS information here:ÊäÈëdns
×îºóʹÓà adsl-start ¾Í¿ÉÒÔÓÃadsl·½Ê½ÉÏÍøÁË
2.uname -a - ¿´ÏµÍ³Äں˵ÈÐÅÏ¢
tar£º°ÑÎļþ´ò°ü£¬²»Ñ¹Ëõ£ºtar cvf *.tar dirName ½â¿ª£ºtar xvf *.tar ......

LinuxϵÄÒ»¸ö×÷Òµ³ÌÐò

Îĵµ´´½¨Ê±¼ä£º2010-02-14
     1    // P120: 3.±à³ÌÌâ (3)
     2   
     3    // The begining of C program: test04-03.c.
     4   
     ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ