linux系统编程代码1
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <time.h>
#include <unistd.h>
#define TIME_STRING_BUF 50
char * timestring(time_t t,char *buf)
{
struct tm *local;
local=localtime((&t);
strftime(buf,TIME_STRING_BUF,"%c",local);
return buf;
}
int statfile(const char * file)
{
struct stat statbuf;
char timebuf[TIME_STRING_BUF];
if (lstat(file,%statbuf))
{
fprintf(stderr,"could not lstat %s:%s\n",file,stderror(errno));
return 1;
}
printf("filename : %s\n",file);
printf("on device : major %d/minor %d inode number: %ld\n",major(statbuf.st_dev),minor(statbuf,st_dev),statbuf .st_ino)) )
printf("size :%-10ld type : %07o permissons :%05o",statbuf,st_size,statbuf .st_mode&S_IFMT,statbuf .st_mode&~(S_IFMT));
printf("ower :%d group :%d number of links :%d\n",statbuf .st_uid,statbuf .st_uid,statbuf .st_gid,statbuf .stnlink);
printf("change time :%s\n",timeString(statbuf ,st_ctime ,timeBuf));
printf("modified time :%s\n",timeString(statbuf ,st_ctime ,timeBuf));
printf("access time :%s\n",timeString(statbuf ,st_ctime ,timeBuf));
return 0;
int
main(int argc,const char **argv)
{
int i;
int rc=0;
for (i=1;i<argv;i++)
{
rc|=statFile(argv[i]);
if((argc-i)>1)
printf("\n");
}
return rc;
}
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
Linux diff与patch的深入分析
http://blog.csdn.net/vrix/archive/2009/08/25/4483906.aspx
diff的输出格式分为传统格式和统一格式
1)diff的传统格式输出.
############################################
cat before.txt
输出:
This is a line to be deleted
This is a line that will be changed
This is a line ......
Linux 引导过程内幕
引导 Linux® 系统的过程包括很多阶段。不管您是引导一个标准的 x86 桌面系统,还是引导一台嵌入式的 PowerPC® 机器,很多流程都惊人地相似。本文将探索 Linux 的引导过程,从最初的引导到启动第一个用户空间应用程序。在本文介绍的过程中,您将学习到各种与引导有关的主题, ......
原文网址:http://blog.chinaunix.net/u1/51562/showart_1341707.html
一:前言
RCU机制出现的比较早,只是在linux kernel中一直到2.5版本的时候才被采用.关于RCU机制,这里就不做过多的介绍了,网上有很多有关RCU介绍和使用的文档.请自行查阅.本文主要是从linux kernel源代码的角度.来分析RCU的实现.
在讨论RCU的实 ......
Chapter 1: Thread
① thread functions
1. pthread_self();
2. thread existing
you can get the value of rval_ptr just by pthread_join(pthread_t tht, void ** rval_ptr)
cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this functio ......