From owner-freebsd-ports Thu Nov 11 4:20: 6 1999 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id DC51414DE1 for ; Thu, 11 Nov 1999 04:20:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id EAA10740; Thu, 11 Nov 1999 04:20:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from relay1.bcs.zp.ua (bcs-zyx-eth.marka.net.ua [195.248.171.202]) by hub.freebsd.org (Postfix) with ESMTP id 1DFC814DC9 for ; Thu, 11 Nov 1999 04:15:12 -0800 (PST) (envelope-from serg@bcs3.bcs.zp.ua) Received: from bcs3.bcs.zp.ua (bcs3.bcs.zp.ua [212.8.35.73]) by relay1.bcs.zp.ua (8.9.3/8.9.3) with ESMTP id OAA16593 for ; Thu, 11 Nov 1999 14:15:09 +0200 (EET) Received: (from serg@localhost) by bcs3.bcs.zp.ua (8.9.3/8.9.3) id OAA65054; Thu, 11 Nov 1999 14:15:09 +0200 (EET) (envelope-from serg) Message-Id: <199911111215.OAA65054@bcs3.bcs.zp.ua> Date: Thu, 11 Nov 1999 14:15:09 +0200 (EET) From: serg@bcs.zp.ua Reply-To: serg@bcs.zp.ua To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: ports/14824: ports/sysutils/stat error Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 14824 >Category: ports >Synopsis: no '\0' at the end of buffer >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Nov 11 04:20:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Sergey Shkonda >Release: FreeBSD 3.3-STABLE i386 >Organization: Business Computer Service >Environment: >Description: Sometimes stat(1) outputs bad character at the end of file descrption >How-To-Repeat: cd /tmp touch ab abc stat abc ab >Fix: Here is the patches *** stat.1.orig Sun Feb 16 15:16:52 1997 --- stat.1 Sun Aug 29 18:11:32 1999 *************** *** 44,49 **** --- 44,51 ---- %m Modified time. %c Status change time. %b # of blocks allocated. + %n File name + %N File name in form "name" or "name" -> "name" .fi .SH "SEE ALSO" stat(2), ls(1) --- stat.fmt.c.orig Sun Feb 16 15:12:33 1997 +++ stat.fmt.c Sat Nov 6 22:04:08 1999 @@ -25,6 +25,8 @@ %m Modified time. %c Status change time. %b # of blocks allocated. + %n File name + %N File name in form "name" or "name" -> "name" * libraries used: standard + getopt * compile time parameters: @@ -62,7 +64,7 @@ char *progname; /* Name we're called as */ char *fmt_app __P((char *, char *)); -void FmtInode __P((char *, char*, struct stat *)); +void FmtInode __P((char *, char*, struct stat *, char*, char*)); void Usage __P((void)); @@ -92,6 +94,7 @@ #define LBUFSIZ 256 /* Length of symbolic link translation buffer */ char Lbuf [LBUFSIZ]; /* Symbolic link translation buffer */ + Lbuf[0] = 0; if( lstat(filename,&Sbuf) == FAIL) { fprintf(stderr,"Can't lstat %s\n",filename); return(FAIL); @@ -104,12 +107,9 @@ } if( count < LBUFSIZ) Lbuf[count] = '\0'; - printf(" File: \"%s\" -> \"%s\"\n", filename, Lbuf); - } else - printf(" File: \"%s\"\n", filename); - + } - FmtInode(buf, fmt_str, &Sbuf); + FmtInode(buf, fmt_str, &Sbuf, filename, Lbuf); printf("%s\n", buf); @@ -402,6 +402,8 @@ ** %m Modified time. ** %c Status change time. ** %b # of blocks allocated. +** %n File name +** %N File name in form "name" or "name" -> "name" ** ** Use a backslash to 'hide' any special character, e.g. '%' ** @@ -411,9 +413,11 @@ */ void -FmtInode(buf, fmt, ip) +FmtInode(buf, fmt, ip, name, lbuf) char *buf, - *fmt; + *fmt, + *name, + *lbuf; struct stat *ip; { char auxbuf [64]; @@ -429,6 +433,18 @@ *bufp++ = c; } else { switch (c = *fmt++) { + case 'n': /* File name */ + sprintf(auxbuf, "%s", name); + bufp = fmt_app(auxbuf, bufp); + break; + case 'N': + if (lbuf[0]) + sprintf(auxbuf, "\"%s\" -> \"%s\"", + name, lbuf); + else + sprintf(auxbuf, "\"%s\"", name); + bufp = fmt_app(auxbuf, bufp); + break; case 'f': /* Filetype */ TypeToS(auxbuf, ip); bufp = fmt_app(auxbuf, bufp); @@ -500,6 +516,7 @@ } } } + *bufp=0; } /* ** USAGE -- Display a reminder @@ -549,7 +566,7 @@ * Set some defaults ... */ - fmt_str = " Size: %s\tAllocated Blocks: %b\tFiletype: %f\n Mode: (%p)\tUid: (%u) Gid: (%g)\nDevice: %d\tInode: %i\tLinks: %l\t%t\nAccess: %a\nModify: %m\nChange: %c\n"; + fmt_str = " File: %N\n Size: %s\tAllocated Blocks: %b\tFiletype: %f\n Mode: (%p)\tUid: (%u) Gid: (%g)\nDevice: %d\tInode: %i\tLinks: %l\t%t\nAccess: %a\nModify: %m\nChange: %c\n"; /* * Check for flag arguments ... >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message