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等协议 ......
作者:fbysss
msn:jameslastchina@hotmail.com
blog:blog.csdn.net/fbysss
声明:本文由fbysss整理编写,转载请注明出处
关键字:shell编程
背景
同事求助。
需求
一个文本文件,要得到最后一行与倒数第一行相减的结果。
测试文 ......
Emebedded System and Application(Linux)
Goal
--
掌握嵌入式系统开发的流程,系统移植的方法,编写Bootloader
(Be familiar with the process of ES Developing
, System Migration
amd Bootloader Programming
)
Requriem ......
Linux LVM 的使用详解
http://blog.csdn.net/icejadelove/archive/2009/10/30/4747657.aspx
摘要:Linux用户安装Linux操作系统时遇到的一个最常见的难以决定的问题就是如何正确地给评估各分区大小,以分配合适的硬盘空间。而遇到出现某个分区空间耗尽时,解决的方法通常是使用符号链接,或者使用调整分区大小的工具(比如P ......
一. 文件一次读入速度
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 ......