文档介绍:实验6、LINUX环境编程-2学生姓名:李亚军学号:6100412196专业班级:,理解LINUX环境中的命令行参数的使用。,实现简单的LINUX命令ls功能。(1)#include<>#include<>#include<>#include<>#include<sys/>#include<>#include<>#include<>#include<>#include<>#include<>#include<>#include<>#include<>#include<sys/>#include<linux/>#defineOPT_v0x0001/*-v选项:查看本软件版本*/#defineOPT_h0x0002/*-h选项:查看本软件帮助*/#defineOPT_l0x0004/*-l选项:长型(long)显示*/#defineOPT_a0x0008/*-a选项:显示所有文件(all)*/#defineOPT_R0x0010/*-R选项:显示子目录内容*/#defineOPT_f0x0020/*-f选项:不排序*/#ESS0typedefstruct_Node{charpath[1024];charname[256];intlength;structstatst;struct_Node*pnext;}nNode;intcreatelslink(char*path,intflag,nNode**head){DIR*dp;structdirent*entry;structstatstatbuf;nNode*p;charabspath[1024];if((dp=opendir(path))==NULL){fprintf(stderr,"cannotopendirectory:%s\n",path);return-1;}if(chdir(path)==-1){fprintf(stderr,"cannotcddirectory:%s\n",path);return-2;}if(NULL==getcwd(abspath,1024)){fprintf(stderr,"getcwderror!\n"); return-3;}while((entry=readdir(dp))!=NULL){lstat(entry->d_name,&statbuf);if((!(flag&OPT_a))&&(entry->d_name[0]=='.'))/*没有选项-(或目录)名*/continue;else{p=(nNode*)malloc(sizeof(nNode));p->pnext=*head;*head=p;(*head)->length=strlen(entry->d_name);strcpy((*head)->path,abspath);strcpy((*head)->name,entry->d_name);memcpy(&