Re: Was someone looking for a BSD licensed stat(1)?
On Sun, 1 Aug 1999, Keith Stevenson wrote: the features that were requested. I honestly haven't figured out how to implement the display of selected fields yet. I realize that this isn't a Attached is a diff that takes care of that. Basically, the user can specify a format that looks like "%f\t%U\t%A" to get the files name, the username of the owner, and the last access time seperated by tabs followed by a new line. All of the supported format specifiers are documented in the man page. I looked around for another version of stat that does this but could not locate one; therefore the format specifiers are what made sense to me. There is also limited support for C-style escape sequences (no \nnn). Have a nice day! Jamie diff -c stat/stat.1 stat-jph/stat.1 *** stat/stat.1 Sun Aug 1 23:18:48 1999 --- stat-jph/stat.1 Sun Aug 1 23:50:31 1999 *** *** 42,71 The options are as follows: .Bl -tag -width Fl .It Fl d ! dereference symlinks .It Fl f ! read filenames to be stat-ed from file ( - means stdin) .It Fl g ! show time elements in GMT time zone. (implies -s) .It Fl h ! print usage summary .It Fl i ! ignore errors .It Fl l ! display one element per line .It Fl s ! print mode, uid, gid, and times as strings .It Fl t ! terse output .It Fl o Ar opts ! output only selected elements of struct stat .It Fl f Ar file ! read filenames to be stat-ed from file ( - means stdin) .El .Sh EXAMPLES An example or two will go here .Pp .Sh SEE ALSO .Xr stat 2 .Rs .Sh AUTHORS --- 42,107 The options are as follows: .Bl -tag -width Fl .It Fl d ! Follow symbolic links. .It Fl f ! Read filenames to be stat-ed from file ( - means stdin). .It Fl g ! Show time elements in GMT time zone. (implies -s) .It Fl h ! Print usage summary. .It Fl i ! Ignore errors. .It Fl l ! Display one element per line. .It Fl s ! Print mode, uid, gid, and times as strings. .It Fl t ! Terse output. .It Fl o Ar opts ! Output only selected elements of struct stat. The following ! formatting tags are permitted: ! .Bl -tag -width Fl ! .It Ar %A ! last access time ! .It Ar %C ! file creation time ! .It Ar %G ! file group (group name) ! .It Ar %M ! last modify time ! .It Ar %P ! file permission mode (symbolic) ! .It Ar %U ! file owner (username) ! .It Ar %b ! blocks allocated for file ! .It Ar %d ! device file is on ! .It Ar %f ! file name ! .It Ar %g ! file group (gid) ! .It Ar %i ! inode ! .It Ar %l ! number of hard links to file ! .It Ar %p ! file permission mode (octal) ! .It Ar %s ! file size in blocks ! .It Ar %t ! type of file ! .It Ar %u ! file owner (uid) ! .El .It Fl f Ar file ! Read filenames to be stat-ed from file ( - means stdin). .El .Sh EXAMPLES An example or two will go here .Pp .Sh SEE ALSO + .Xr ls 1 , .Xr stat 2 .Rs .Sh AUTHORS *** *** 73,76 .Sh DIAGNOSTICS Most errors are the result of bad filenames. .Sh BUGS ! Some features (-f, -i, -o) are currently unimplemented --- 109,112 .Sh DIAGNOSTICS Most errors are the result of bad filenames. .Sh BUGS ! Some features (-f and -i) are currently unimplemented diff -c stat/stat.c stat-jph/stat.c *** stat/stat.c Sun Aug 1 23:17:14 1999 --- stat-jph/stat.c Sun Aug 1 23:34:29 1999 *** *** 57,62 --- 57,65 void terseprint(const char*, const char*, const char*, const char*, struct stat*, struct group*, struct passwd*, struct tm*, struct tm*, struct tm*, int); + void customprint(const char *, const char*, const char*, const char*, +const char*, struct stat*, struct group*, struct passwd*, +struct tm*, struct tm*, struct tm*, int); int vstat(const char*, struct stat*, int); *** *** 78,85 struct stat inode; struct tm *atime, *mtime, *ctime; ! extern char *optarg; ! extern int optind; /* flags */ --- 81,87 struct stat inode; struct tm *atime, *mtime, *ctime; ! char *oformat; /* flags */ *** *** 113,122 f_listout = 1; break; case 'o': - printf("Unimplemented.\n"); - exit(EX_OK); f_customout = 1; f_listout = 1; break; case 's': f_stringout = 1; --- 115,123 f_listout = 1; break; case 'o': f_customout = 1; f_listout = 1; + oformat = optarg; break; case 's':
Re: Was someone looking for a BSD licensed stat(1)?
I've put a new version of stat(1) up for review. I've incorporated a few of the features that were requested. I honestly haven't figured out how to implement the display of selected fields yet. I realize that this isn't a huge step forward over the previous revision, but my hacking hours are limited. Code is available at: http://www.kagekaze.org/stat.tar.gz Regards, --Keith Stevenson-- -- Keith Stevenson System Programmer - Data Center Services - University of Louisville k.steven...@louisville.edu PGP key fingerprint = 4B 29 A8 95 A8 82 EA A2 29 CE 68 DE FC EE B6 A0 To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
It's getting better. I don't like that switch (errno) at all. But work on it some more, make it feature-complete., and I'd love to be able to import it. Also, there's a bug: access: Sun Aug 1 13:46:49 1999 Access: Sun Aug 1 00:09:26 1999 Brian Fundakowski Feldman _ __ ___ ___ ___ ___ gr...@freebsd.org _ __ ___ | _ ) __| \ FreeBSD: The Power to Serve!_ __ | _ \._ \ |) | http://www.FreeBSD.org/ _ |___/___/___/ To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
On Sun, 1 Aug 1999, Keith Stevenson wrote: the features that were requested. I honestly haven't figured out how to implement the display of selected fields yet. I realize that this isn't a Attached is a diff that takes care of that. Basically, the user can specify a format that looks like %f\t%U\t%A to get the files name, the username of the owner, and the last access time seperated by tabs followed by a new line. All of the supported format specifiers are documented in the man page. I looked around for another version of stat that does this but could not locate one; therefore the format specifiers are what made sense to me. There is also limited support for C-style escape sequences (no \nnn). Have a nice day! Jamie diff -c stat/stat.1 stat-jph/stat.1 *** stat/stat.1 Sun Aug 1 23:18:48 1999 --- stat-jph/stat.1 Sun Aug 1 23:50:31 1999 *** *** 42,71 The options are as follows: .Bl -tag -width Fl .It Fl d ! dereference symlinks .It Fl f ! read filenames to be stat-ed from file ( - means stdin) .It Fl g ! show time elements in GMT time zone. (implies -s) .It Fl h ! print usage summary .It Fl i ! ignore errors .It Fl l ! display one element per line .It Fl s ! print mode, uid, gid, and times as strings .It Fl t ! terse output .It Fl o Ar opts ! output only selected elements of struct stat .It Fl f Ar file ! read filenames to be stat-ed from file ( - means stdin) .El .Sh EXAMPLES An example or two will go here .Pp .Sh SEE ALSO .Xr stat 2 .Rs .Sh AUTHORS --- 42,107 The options are as follows: .Bl -tag -width Fl .It Fl d ! Follow symbolic links. .It Fl f ! Read filenames to be stat-ed from file ( - means stdin). .It Fl g ! Show time elements in GMT time zone. (implies -s) .It Fl h ! Print usage summary. .It Fl i ! Ignore errors. .It Fl l ! Display one element per line. .It Fl s ! Print mode, uid, gid, and times as strings. .It Fl t ! Terse output. .It Fl o Ar opts ! Output only selected elements of struct stat. The following ! formatting tags are permitted: ! .Bl -tag -width Fl ! .It Ar %A ! last access time ! .It Ar %C ! file creation time ! .It Ar %G ! file group (group name) ! .It Ar %M ! last modify time ! .It Ar %P ! file permission mode (symbolic) ! .It Ar %U ! file owner (username) ! .It Ar %b ! blocks allocated for file ! .It Ar %d ! device file is on ! .It Ar %f ! file name ! .It Ar %g ! file group (gid) ! .It Ar %i ! inode ! .It Ar %l ! number of hard links to file ! .It Ar %p ! file permission mode (octal) ! .It Ar %s ! file size in blocks ! .It Ar %t ! type of file ! .It Ar %u ! file owner (uid) ! .El .It Fl f Ar file ! Read filenames to be stat-ed from file ( - means stdin). .El .Sh EXAMPLES An example or two will go here .Pp .Sh SEE ALSO + .Xr ls 1 , .Xr stat 2 .Rs .Sh AUTHORS *** *** 73,76 .Sh DIAGNOSTICS Most errors are the result of bad filenames. .Sh BUGS ! Some features (-f, -i, -o) are currently unimplemented --- 109,112 .Sh DIAGNOSTICS Most errors are the result of bad filenames. .Sh BUGS ! Some features (-f and -i) are currently unimplemented diff -c stat/stat.c stat-jph/stat.c *** stat/stat.c Sun Aug 1 23:17:14 1999 --- stat-jph/stat.c Sun Aug 1 23:34:29 1999 *** *** 57,62 --- 57,65 void terseprint(const char*, const char*, const char*, const char*, struct stat*, struct group*, struct passwd*, struct tm*, struct tm*, struct tm*, int); + void customprint(const char *, const char*, const char*, const char*, +const char*, struct stat*, struct group*, struct passwd*, +struct tm*, struct tm*, struct tm*, int); int vstat(const char*, struct stat*, int); *** *** 78,85 struct stat inode; struct tm *atime, *mtime, *ctime; ! extern char *optarg; ! extern int optind; /* flags */ --- 81,87 struct stat inode; struct tm *atime, *mtime, *ctime; ! char *oformat; /* flags */ *** *** 113,122 f_listout = 1; break; case 'o': - printf(Unimplemented.\n); - exit(EX_OK); f_customout = 1; f_listout = 1; break; case 's': f_stringout = 1; --- 115,123 f_listout = 1; break; case 'o': f_customout = 1; f_listout = 1; + oformat = optarg; break; case 's':
Was someone looking for a BSD licensed stat(1)?
I hacked this together last night. The only GNU code I looked at was the Linux stat(1u) man page. (A man page is forthcoming, especially if there is some interest in using this implementation.) The code is also available at http://www.kagekaze.org/stat.c Regards, --Keith Stevenson-- -- Keith Stevenson System Programmer - Data Center Services - University of Louisville [EMAIL PROTECTED] PGP key fingerprint = 4B 29 A8 95 A8 82 EA A2 29 CE 68 DE FC EE B6 A0 /* stat.c: Human readable interface to stat(2) system call */ /*- * Copyright (c) 1999 Keith Stevenson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: stat.c,v 1.2 1999/07/28 19:33:10 ktstev01 Exp $ */ #ifndef lint static const char copyright[] = "Copyright (c) 1999\nKeith Stevenson. All rights reserved.\n"; static const char rcsid[] = "$Id: stat.c,v 1.2 1999/07/28 19:33:10 ktstev01 Exp $"; #endif /* not lint */ #include sys/types.h #include sys/stat.h #include errno.h #include grp.h #include pwd.h #include stdio.h #include string.h #include sysexits.h #include time.h /* stat: Display the contents of an inode in a human friendly format. */ int main(int argc, char *argv[]) { charftype[20]; charfmode[11]; int count; struct group*gp; struct passwd *pw; struct stat inode; struct tm *atime, *mtime, *ctime; for (count = 1; count argc; count++) { if (lstat(argv[count], inode) != -1) { /* Initialize */ memset(fmode, '-', sizeof(fmode)); fmode[10] = '\0'; /* Interpret file type */ switch (inode.st_mode S_IFMT) { case S_IFIFO: strncpy(ftype, "FIFO", sizeof(ftype)); fmode[0] = 'p'; break; case S_IFCHR: strncpy(ftype, "Character Special", sizeof(ftype)); fmode[0] = 'c'; break; case S_IFDIR: strncpy(ftype, "Directory", sizeof(ftype)); fmode[0] = 'd'; break; case S_IFBLK: strncpy(ftype, "Block Special", sizeof(ftype)); fmode[0] = 'b'; break; case S_IFREG: strncpy(ftype, "Regular", sizeof(ftype)); break; case S_IFLNK: strncpy(ftype, "Symbolic Link", sizeof(ftype)); fmode[0] = 'l'; break; case S_IFSOCK: strncpy(ftype, "Socket", sizeof(ftype)); fmode[0] = 's'; break; case S_IFWHT: strncpy(ftype, "Whiteout", sizeof(ftype)); fmode[0] = '?'; break; default: strncpy(ftype, "Unknown", sizeof(ftype)); fmode[0] = '?'; break; } /* Interpret file mode */ if (inode.st_mode S_IRUSR) fmode[1] =
Re: Was someone looking for a BSD licensed stat(1)?
Since you've got it in RCS, you shouldn't have any problem adding new features. How about a selectable display of fields, and ability to put them in machine-readable (read: no cut required) form? I'd suggest having a function that would printf "%s: whatever", arg1 for humans and "whatever" for machines, selectable by something like a -c "compact output flag." Here's the GPLd stat I have: {"/usr"}# stat stat [-cihsv] [-o opts] [-f file] [filename ...] -h this help -v verbose output -c compact output -i ignore errors -s stop on error -f read filenames to be stat-ed from file (- means stdin) -d dereference symbolic links. -o opts output options (case insensitive): a access time c creation time d device g group i inode l links m mode n file name o modification time s size t type u owner Brian Fundakowski Feldman _ __ ___ ___ ___ ___ [EMAIL PROTECTED] _ __ ___ | _ ) __| \ FreeBSD: The Power to Serve!_ __ | _ \._ \ |) | http://www.FreeBSD.org/ _ |___/___/___/ To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
On Wed, Jul 28, 1999 at 04:01:10PM -0400, Brian F. Feldman wrote: Since you've got it in RCS, you shouldn't have any problem adding new features. How about a selectable display of fields, and ability to put them in machine-readable (read: no cut required) form? I'd suggest having a function that would printf "%s: whatever", arg1 for humans and "whatever" for machines, selectable by something like a -c "compact output flag." Here's the GPLd stat I have: Sure, I can work on that. It would be helpful if you could include a few sample outputs that I could work from. The current version already solves my problems, but I'll be happy to hack away at it if you are interested in including it in FreeBSD in some way. Regards, --Keith Stevenson-- -- Keith Stevenson System Programmer - Data Center Services - University of Louisville [EMAIL PROTECTED] PGP key fingerprint = 4B 29 A8 95 A8 82 EA A2 29 CE 68 DE FC EE B6 A0 To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
According to Keith Stevenson: Sure, I can work on that. It would be helpful if you could include a few sample outputs that I could work from. You may also want to look at the builtin stat(1) function in zsh too. 3.1.5+ only, I don't think 3.1.4 had it. BTW 3.1.6 now pretty close to release. stat [ -gnNlLtTrs ] [ -f fd ] [ -H hash ] [ -A array ] [ -F fmt ] [ +element ] [ file ... ] The command acts as a front end to the stat system call (see stat(2)). If the stat call fails, the appropriate system error message printed and status 1 is returned. The fields of struct stat give information about the files provided as arguments to the command. In addition to those available from the stat call, an extra element `link' is pro- vided. These elements are: device The number of the device on which the file resides. inode The unique number of the file on this device (`inode' number). mode The mode of the file; that is, the file's type and access permissions. With the -s option, this will be returned as a string corresponding to the first column in the display of the ls -l command. nlink The number of hard links to the file. uidThe user ID of the owner of the file. With the -s option, this is displayed as a user name. gidThe group ID of the file. With the -s option, this is displayed as a group name. rdev The raw device number. This is only useful for special devices. size The size of the file in bytes. atime mtime ctime The last access, modification and inode change times of the file, respectively, as the number of seconds since midnight GMT on 1st January, 1970. With the -s option, these are printed as strings for the local time zone; the format can be altered with the -F option, and with the -g option the times are in GMT. blksize The number of bytes in one allocation block on the device on which the file resides. block The number of disk blocks used by the file. link If the file is a link and the -L option is in effect, this contains the name of the file linked to, otherwise it is empty. Note that if this element is selected (``stat +link'') then the -L option is automatically used. A particular element may be selected by including its name preceded by a `+' in the option list; only one element is allowed. The element may be short- ened to any unique set of leading characters. Oth- erwise, all elements will be shown for all files. Options: -A array Instead of displaying the results on stan- dard output, assign them to an array, one struct stat element per array element for each file in order. In this case neither the name of the element nor the name of the files is provided unless the -t or -n options are provided, respectively. In the former case the element name appears as a prefix to the appropriate array element and in the latter case the file name appears as a separate array element preceding all the others. Other formatting options are respected. -H hash Similar to -A, but instead assign the values to hash. The keys are the elements listed above. If the -n option is provided then the name of the file is included in the hash with key name. -f fd Use the file on file descriptor fd instead of named files; no list of file names is allowed in this case. -F fmt Supplies a strftime (see strftime(3)) string for the formatting of the time elements. The -s option is implied. -g Show the time elements in the
Was someone looking for a BSD licensed stat(1)?
I hacked this together last night. The only GNU code I looked at was the Linux stat(1u) man page. (A man page is forthcoming, especially if there is some interest in using this implementation.) The code is also available at http://www.kagekaze.org/stat.c Regards, --Keith Stevenson-- -- Keith Stevenson System Programmer - Data Center Services - University of Louisville k.steven...@louisville.edu PGP key fingerprint = 4B 29 A8 95 A8 82 EA A2 29 CE 68 DE FC EE B6 A0 /* stat.c: Human readable interface to stat(2) system call */ /*- * Copyright (c) 1999 Keith Stevenson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: stat.c,v 1.2 1999/07/28 19:33:10 ktstev01 Exp $ */ #ifndef lint static const char copyright[] = Copyright (c) 1999\nKeith Stevenson. All rights reserved.\n; static const char rcsid[] = $Id: stat.c,v 1.2 1999/07/28 19:33:10 ktstev01 Exp $; #endif /* not lint */ #include sys/types.h #include sys/stat.h #include errno.h #include grp.h #include pwd.h #include stdio.h #include string.h #include sysexits.h #include time.h /* stat: Display the contents of an inode in a human friendly format. */ int main(int argc, char *argv[]) { charftype[20]; charfmode[11]; int count; struct group*gp; struct passwd *pw; struct stat inode; struct tm *atime, *mtime, *ctime; for (count = 1; count argc; count++) { if (lstat(argv[count], inode) != -1) { /* Initialize */ memset(fmode, '-', sizeof(fmode)); fmode[10] = '\0'; /* Interpret file type */ switch (inode.st_mode S_IFMT) { case S_IFIFO: strncpy(ftype, FIFO, sizeof(ftype)); fmode[0] = 'p'; break; case S_IFCHR: strncpy(ftype, Character Special, sizeof(ftype)); fmode[0] = 'c'; break; case S_IFDIR: strncpy(ftype, Directory, sizeof(ftype)); fmode[0] = 'd'; break; case S_IFBLK: strncpy(ftype, Block Special, sizeof(ftype)); fmode[0] = 'b'; break; case S_IFREG: strncpy(ftype, Regular, sizeof(ftype)); break; case S_IFLNK: strncpy(ftype, Symbolic Link, sizeof(ftype)); fmode[0] = 'l'; break; case S_IFSOCK: strncpy(ftype, Socket, sizeof(ftype)); fmode[0] = 's'; break; case S_IFWHT: strncpy(ftype, Whiteout, sizeof(ftype)); fmode[0] = '?'; break; default: strncpy(ftype, Unknown, sizeof(ftype)); fmode[0] = '?'; break; } /* Interpret file mode */ if (inode.st_mode S_IRUSR) fmode[1] = 'r';
Re: Was someone looking for a BSD licensed stat(1)?
Since you've got it in RCS, you shouldn't have any problem adding new features. How about a selectable display of fields, and ability to put them in machine-readable (read: no cut required) form? I'd suggest having a function that would printf %s: whatever, arg1 for humans and whatever for machines, selectable by something like a -c compact output flag. Here's the GPLd stat I have: {/usr}# stat stat [-cihsv] [-o opts] [-f file] [filename ...] -h this help -v verbose output -c compact output -i ignore errors -s stop on error -f read filenames to be stat-ed from file (- means stdin) -d dereference symbolic links. -o opts output options (case insensitive): a access time c creation time d device g group i inode l links m mode n file name o modification time s size t type u owner Brian Fundakowski Feldman _ __ ___ ___ ___ ___ gr...@freebsd.org _ __ ___ | _ ) __| \ FreeBSD: The Power to Serve!_ __ | _ \._ \ |) | http://www.FreeBSD.org/ _ |___/___/___/ To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
On Wed, Jul 28, 1999 at 04:01:10PM -0400, Brian F. Feldman wrote: Since you've got it in RCS, you shouldn't have any problem adding new features. How about a selectable display of fields, and ability to put them in machine-readable (read: no cut required) form? I'd suggest having a function that would printf %s: whatever, arg1 for humans and whatever for machines, selectable by something like a -c compact output flag. Here's the GPLd stat I have: Sure, I can work on that. It would be helpful if you could include a few sample outputs that I could work from. The current version already solves my problems, but I'll be happy to hack away at it if you are interested in including it in FreeBSD in some way. Regards, --Keith Stevenson-- -- Keith Stevenson System Programmer - Data Center Services - University of Louisville k.steven...@louisville.edu PGP key fingerprint = 4B 29 A8 95 A8 82 EA A2 29 CE 68 DE FC EE B6 A0 To Unsubscribe: send mail to majord...@freebsd.org with unsubscribe freebsd-hackers in the body of the message
Re: Was someone looking for a BSD licensed stat(1)?
According to Keith Stevenson: Sure, I can work on that. It would be helpful if you could include a few sample outputs that I could work from. You may also want to look at the builtin stat(1) function in zsh too. 3.1.5+ only, I don't think 3.1.4 had it. BTW 3.1.6 now pretty close to release. stat [ -gnNlLtTrs ] [ -f fd ] [ -H hash ] [ -A array ] [ -F fmt ] [ +element ] [ file ... ] The command acts as a front end to the stat system call (see stat(2)). If the stat call fails, the appropriate system error message printed and status 1 is returned. The fields of struct stat give information about the files provided as arguments to the command. In addition to those available from the stat call, an extra element `link' is pro- vided. These elements are: device The number of the device on which the file resides. inode The unique number of the file on this device (`inode' number). mode The mode of the file; that is, the file's type and access permissions. With the -s option, this will be returned as a string corresponding to the first column in the display of the ls -l command. nlink The number of hard links to the file. uidThe user ID of the owner of the file. With the -s option, this is displayed as a user name. gidThe group ID of the file. With the -s option, this is displayed as a group name. rdev The raw device number. This is only useful for special devices. size The size of the file in bytes. atime mtime ctime The last access, modification and inode change times of the file, respectively, as the number of seconds since midnight GMT on 1st January, 1970. With the -s option, these are printed as strings for the local time zone; the format can be altered with the -F option, and with the -g option the times are in GMT. blksize The number of bytes in one allocation block on the device on which the file resides. block The number of disk blocks used by the file. link If the file is a link and the -L option is in effect, this contains the name of the file linked to, otherwise it is empty. Note that if this element is selected (``stat +link'') then the -L option is automatically used. A particular element may be selected by including its name preceded by a `+' in the option list; only one element is allowed. The element may be short- ened to any unique set of leading characters. Oth- erwise, all elements will be shown for all files. Options: -A array Instead of displaying the results on stan- dard output, assign them to an array, one struct stat element per array element for each file in order. In this case neither the name of the element nor the name of the files is provided unless the -t or -n options are provided, respectively. In the former case the element name appears as a prefix to the appropriate array element and in the latter case the file name appears as a separate array element preceding all the others. Other formatting options are respected. -H hash Similar to -A, but instead assign the values to hash. The keys are the elements listed above. If the -n option is provided then the name of the file is included in the hash with key name. -f fd Use the file on file descriptor fd instead of named files; no list of file names is allowed in this case. -F fmt Supplies a strftime (see strftime(3)) string for the formatting of the time elements. The -s option is implied. -g Show the time elements in the GMT