[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [d-i] today's treecompare



On Sat, Oct 20, 2001 at 01:03:12AM -0800, Ethan Benson wrote:
> but parsing some basically informative verbosity output from a utility
> is a damned fragile kludge of a way to do something, what if the
> format of this output changes in the future?

Agree with the sentiment, but changing the output of dd after all this
time is probably a shooting offense.

A 'stat' program would be handy, where perl was not readily available.
Here's a prototype:

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>

    int main(int argc, char *argv[])
    {
	struct stat buf;

	if (argc != 2) {
	    fprintf(stderr, "usage: %s FILE\n", argv[0]);
	    exit(EXIT_FAILURE);
	}

	if (stat(argv[1], &buf))
	    perror("stat");

	printf("%u %lu %u %u %u %u %u %lu %lu %lu %ld %ld %ld %ld %ld\n",
	       buf.st_dev, buf.st_ino, buf.st_mode, buf.st_nlink, buf.st_uid,
	       buf.st_gid, buf.st_rdev, buf.st_size, buf.st_blksize,
	       buf.st_blocks, buf.st_atime, buf.st_mtime, buf.st_ctime);

	exit(EXIT_SUCCESS);
    }

Regards,

Mark.



Reply to: