⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 631.html

📁 Jsp001精华文章离线版.很不错的,主要是针对JSP的相关内容的
💻 HTML
📖 第 1 页 / 共 2 页
字号:
        /* 抽取NFS filehandle中的filesystem ID */<br>        if(sscanf(argv[1], "%x", &amp;fsid) != 1) {<br>                fprintf(stderr, "illegal parameters: arg#1\n") ;<br>               exit(1) ;<br>        }<br><br>        /* 抽取NFS filehandle中的 inode号码 */<br>        if(sscanf(argv[4], "%x", &amp;ino) != 1) {<br>                fprintf(stderr, "illegal parameters: arg#4\n") ;<br>               exit(1) ;<br>        }<br><br>        /* 打开/etc/mnttab文件 */<br>        if((fp = fopen(MNTTAB, "r")) == NULL) {<br>                perror(MNTTAB) ;<br>                exit(1) ;<br>        }<br><br>        /* 从mnttab 抽取当前mount着的filesystem名 */<br>        while(! (ret = getmntent(fp, &amp;mnt))) {<br>                /*<br>                 * 忽略MNT_TOOLONG, MNT_TOOMANY, MNT_TOOFEW <br>                 */<br>                if(ret &gt; 0)<br>                        continue ;<br><br>                /* 忽略UFS mount以外的filesystem */<br>                if(strcmp(mnt.mnt_fstype, MNTTYPE_UFS))<br>                        continue ;<br><br>                /* 抽取filesystem信息 */<br>                if(statvfs(mnt.mnt_mountp, &amp;vfs) &lt; 0) {<br>                        perror(mnt.mnt_mountp) ;<br>                        continue ;<br>                }<br><br>                /* 检查filesystem id是否一致 */<br>                if(fsid == vfs.f_fsid)<br>                        break ;<br>        }<br>        fclose(fp) ;<br><br>        /* 查看有无相应的 filesystem */<br>        if(ret &lt; 0) {<br>                fprintf(stderr, "Could not get mount point\n") ;<br>               exit(1) ;<br>        }<br><br>        /* 将工作点移动到filesystem的mount位置 */<br>        if(chdir(mnt.mnt_mountp) &lt; 0) {<br>                perror(mnt.mnt_mountp) ;<br>                exit(1) ;<br>        }<br><br>        /* 查找具有相同inode的文件 */<br>        if((fn = find_inode(".", ino)) == NULL) {<br>                fprintf(stderr, "no file with this filehandle\n") ;<br>                exit(1) ;<br>        }<br>        else {<br>                printf("\nUNIX PATH: %s\n", fn) ;<br>        }<br>        exit(0) ;<br>}<br><br>/*<br> *   递归检索filesystem树。发现相同的inode时返回。<br> */<br>char *<br>find_inode(char *name, int ino)<br>{<br>        DIR     *dp ;<br>        char    *str ;<br>        char    cwd[MAXPATHLEN] ;<br>        struct  stat    stat ;<br>        struct  dirent  *de ;<br>        static  char    buf[MAXPATHLEN] ;<br>#       define  PARENT  (cwd[0] == '\0' ? "(null)" : cwd)<br><br>        /* 保存当前工作点*/<br>        if((getcwd(cwd, MAXPATHLEN)) == NULL)<br>                perror("getcwd") ;<br><br>        /*<br>         * 由于需要识别链接文件,因此不能使用stat()函数,而需要使用<br>         *  lstat()函数。<br>         */<br>        if(lstat(name, &amp;stat) &lt; 0) {<br>                sprintf(buf, "%s/%s", PARENT, name) ;<br>                perror(buf) ;<br>                return(NULL) ;<br>        }<br><br>        /* 查看inode号码是否一致 */<br>        if(stat.st_ino == ino) {<br>                /* 一致,返回文件名 */<br>                sprintf(buf, "%s/%s", PARENT, name) ;<br>                return(buf) ;<br>        }<br><br>        /* 查看是否为目录 */<br>        if(! S_ISDIR(stat.st_mode))<br>                return(NULL) ;<br><br>        /* 移动到目录下 */<br>        if(chdir(name) &lt; 0) {<br>                sprintf(buf, "%s/%s", PARENT, name) ;<br>                perror(buf) ;<br>                return(NULL) ;<br>        }<br><br>        /* 打开目录 */<br>        if((dp = opendir(".")) == NULL) {<br>                sprintf(buf, "%s/%s", PARENT, name) ;<br>                perror(buf) ;<br>                if(chdir("..") &lt; 0) {<br>                        sprintf(buf, "%s/%s/..", PARENT, name) ;<br>                       perror(buf) ;<br>                }<br>                return(NULL) ;<br>        }<br><br>        /*<br>         * 递归检索当前目录,忽略"."和".."文件 <br>    */<br>        while((de = readdir(dp)) != NULL) {<br>                if((! strcmp(de-&gt;d_name, ".")) ||<br>                                (! strcmp(de-&gt;d_name, "..")))<br>                        continue ;<br>                if((str = find_inode(de-&gt;d_name, ino)) != NULL) {<br>                        closedir(dp) ;<br>                        return(str) ;<br>                }<br>        }<br>        /*<br>         * 当前目录检索完毕,返回上层目录。<br>         */<br>        if(chdir("..") &lt; 0) {<br>                sprintf(buf, "%s/%s/..", PARENT, name) ;<br>                perror(buf) ;<br>        }<br>        closedir(dp) ;<br>        return(NULL) ;<br>}<br><br>5. 执行 <br>% cc -o findfh findfh.c <br><br>% findfh 0080000C 00000002 000A0000 00024914<br>           62DA8A7E 000A0000 0001EF07 788C7F8A<br><br>UNIX PATH: /mnt/WWW/httpd/htdocs/index.htm<br><br>(钱飞/fei@come.or.jp)<br><br>--------------------------------------------------------------------------------<br></p></td>
  </tr>
</table>

<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=631">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>0</font> 分,你认为它对你有帮助吗?
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=631&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>0</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=631&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>0</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=631&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>0</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=631&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>0</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=631"></script>
<p><CENTER>
Copyright &copy; 2001 - 2009 JSP001.com . All Rights Reserved <P>

<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -