X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=cpmls.c;fp=cpmls.c;h=6bc6bad89b6f757c2651d41d8a3a108c9b89cdd3;hb=e835c6ef8d5a9d39cf0f2875faf38e63636045ba;hp=3721d2e0bb7c3d50e4169024032b0485e74768a5;hpb=b1e873c5b2f6376bb39ff0fda1464cbbacbae5f7;p=debian%2Fcpmtools diff --git a/cpmls.c b/cpmls.c index 3721d2e..6bc6bad 100644 --- a/cpmls.c +++ b/cpmls.c @@ -10,10 +10,6 @@ #include "getopt_.h" #include "cpmfs.h" - -#ifdef USE_DMALLOC -#include -#endif /*}}}*/ /* variables */ /*{{{*/ @@ -27,23 +23,42 @@ static int namecmp(const void *a, const void *b) return strcmp(*((const char * const *)a),*((const char * const *)b)); } /*}}}*/ +/* onlyuser0 -- do all entries belong to user 0? */ /*{{{*/ +static int onlyuser0(char ** const dirent, int entries) +{ + int i; + + for (i=0; i2) { int i,j,k,l,announce,user; @@ -143,7 +159,7 @@ static void old3dir(char **dirent, int entries, struct cpmInode *ino) struct cpmStat statbuf; struct cpmInode file; - if (entries) + if (entries>2) { int i,j,k,l,announce,user, attrib; int totalBytes=0,totalRecs=0; @@ -166,7 +182,8 @@ static void old3dir(char **dirent, int entries, struct cpmInode *ino) { if (user) putchar('\n'); printf("Directory For Drive A: User %2.1d\n\n",user); - printf(" Name Bytes Recs Attributes Prot Update Create\n"); + printf(" Name Bytes Recs Attributes Prot Update %s\n", + ino->sb->cnotatime ? "Create" : "Access"); printf("------------ ------ ------ ------------ ------ -------------- --------------\n\n"); } announce=2; @@ -181,7 +198,7 @@ static void old3dir(char **dirent, int entries, struct cpmInode *ino) totalRecs+=(statbuf.size+127)/128; printf(" %5.1ldk",(long) (statbuf.size+buf.f_bsize-1) / buf.f_bsize*(buf.f_bsize/1024)); - printf(" %6.1ld ",(long)(statbuf.size/128)); + printf(" %6.1ld ",(long)((statbuf.size+127)/128)); putchar((attrib & CPM_ATTR_F1) ? '1' : ' '); putchar((attrib & CPM_ATTR_F2) ? '2' : ' '); putchar((attrib & CPM_ATTR_F3) ? '3' : ' '); @@ -199,12 +216,17 @@ static void old3dir(char **dirent, int entries, struct cpmInode *ino) tmp=localtime(&statbuf.mtime); printf("%02d/%02d/%02d %02d:%02d ",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min); } - else if (statbuf.ctime) printf(" "); - if (statbuf.ctime) + else printf(" "); + if (ino->sb->cnotatime && statbuf.ctime) { tmp=localtime(&statbuf.ctime); printf("%02d/%02d/%02d %02d:%02d",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min); } + else if (!ino->sb->cnotatime && statbuf.atime) + { + tmp=localtime(&statbuf.atime); + printf("%02d/%02d/%02d %02d:%02d",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min); + } putchar('\n'); ++l; } @@ -340,20 +362,21 @@ int main(int argc, char *argv[]) const char *format; const char *devopts=NULL; int c,usage=0; - struct cpmSuperBlock drive; + struct cpmSuperBlock super; struct cpmInode root; int style=0; int changetime=0; + int uppercase=0; int inode=0; char **gargv; int gargc; static char starlit[2]="*"; - static char * const star[]={starlit}; + static char * const star[]={ starlit }; /*}}}*/ /* parse options */ /*{{{*/ if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; - while ((c=getopt(argc,argv,"cT:f:ih?dDFlA"))!=EOF) switch(c) + while ((c=getopt(argc,argv,"cT:f:ih?dDFlAu"))!=EOF) switch(c) { case 'f': format=optarg; break; case 'T': devopts=optarg; break; @@ -366,6 +389,7 @@ int main(int argc, char *argv[]) case 'A': style=5; break; case 'c': changetime=1; break; case 'i': inode=1; break; + case 'u': uppercase=1; break; } if (optind==argc) usage=1; @@ -373,17 +397,21 @@ int main(int argc, char *argv[]) if (usage) { - fprintf(stderr,"Usage: %s [-f format] [-T libdsk-type] [-d|-D|-F|-A|[-l][-c][-i]] image [file ...]\n",cmd); +#ifdef HAVE_LIBDSK_H + fprintf(stderr,"Usage: %s [-f format] [-T libdsk-type] [-d|-D|-F|-A|[-l][-c][-i]] [-u] image [file ...]\n",cmd); +#else + fprintf(stderr,"Usage: %s [-f format] [-d|-D|-F|-A|[-l][-c][-i]] [-u] image [file ...]\n",cmd); +#endif exit(1); } /*}}}*/ /* open image */ /*{{{*/ - if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts))) + if ((err=Device_open(&super.dev,image,O_RDONLY,devopts))) { fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); exit(1); } - if (cpmReadSuper(&drive,&root,format)==-1) + if (cpmReadSuper(&super,&root,format,uppercase)==-1) { fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); exit(1); @@ -396,5 +424,7 @@ int main(int argc, char *argv[]) else if (style==3) old3dir(gargv,gargc,&root); else if (style==5) lsattr(gargv, gargc, &root); else ls(gargv,gargc,&root,style==4,changetime,inode); + cpmglobfree(gargv,gargc); + cpmUmount(&super); exit(0); }