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;
}
相关文档:
最近想在Linux主机上架设Oracle RAC,所以不断地收集相关资料,并进行实际研究.
相信大家很快就可以在我的博客中看到相关的研究心得了.
在Linux学习的这段时间,感觉它真是非常奇妙,让我对它的兴趣也越来越浓了,希望能够更好 ......
Linux 编译安装 MYSQL 5.1 与 Innodb
编译mysql5
代码:
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/data \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--with-extra-charsets=all \
--with-charset=utf8 \
- ......
参考网址:
http://trac.edgewall.org/wiki/TracInstall
http://trac.edgewall.org/wiki/TracInstallPlatforms
http://trac.edgewall.org/wiki/TracOnRhel5
http://dag.wieers.com/rpm/FAQ.php#B
http://tech.idv2.com/2008/12/26/install-trac-on-linux/
软件下载地址:
trac:http://trac.edgewall.org/wiki/TracDo ......
一. 文件一次读入速度
linux下读文件这东西最后都是要通过系统调用sys_read(fd,buf,count)来实现的,所以如果要提高速度,就是最简单地调用sys_read的封装,比如直接用read()或fread()。下面是我在linux下的几个测试。
首先创建一个130M数据文件 dd if=/dev/zero of=data bs=1024k count=130
[dd if=/dev/zero of=data b ......