From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <98284170025363.tru64-unix-managers.marc@archive.invalid> From: Iwan R Tamimi Date: Thu, 22 Feb 2001 09:49:15 +0000 To: tru64-unix-managers Subject: SUMMARY: Info on file creation/modification up to the second X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=98284170025363 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------_=_NextPart_001_01C09CB4.B7D9858A" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C09CB4.B7D9858A Content-Type: text/plain; charset="iso-8859-1" Hi All, I thank you for the very quick answer to: James Sainsbury and J.A. Gutierrez o James sugested to make c program using the stat() function. or using the gnu ls which is part of fileutils which has this command: % ls -l --full-time passwd -rw-r--r-- 1 root root 858 Tue Jan 30 14:55:36 2001 passwd o Mr. Gutierrez even give me the C source code to do it: .c------------------------------------------------------------------ #include #include #include #include #include #include #include main( int argc, char **argv) { struct stat sbp; int f; int isdevice=0; struct passwd *pw; struct group *gr; char *name; int error=0; if ( argc == 1 ) { fprintf(stderr,"Use: %s filename(s)\n",argv[0]); exit(1); } for( f=1; f>8) & 0xff, sbp.st_rdev & 0xff ); fprintf(stdout, "Resides on device:%d,%d\n", (sbp.st_dev>>8) & 0xff, sbp.st_dev & 0xff); fprintf(stdout, "I-node: %d; Links: %d; Size: %ld\n", sbp.st_ino, sbp.st_nlink, sbp.st_size); if (( pw=getpwuid(sbp.st_uid))==NULL) name="???"; else name=pw->pw_name; fprintf(stdout, "Owner ID: %d; Name: %s\n", sbp.st_uid, name); if (( gr=getgrgid(sbp.st_gid))==NULL) name="???"; else name=gr->gr_name; fprintf(stdout, "Group ID: %d; Name: %s\n", sbp.st_gid, name); if ((sbp.st_mode & S_ISUID )== S_ISUID ) fprintf(stdout, "Set-user-ID\n"); if ((sbp.st_mode & S_ISGID )== S_ISGID ) fprintf(stdout, "Set-group-ID\n"); if ((sbp.st_mode & S_ISVTX )== S_ISVTX ) fprintf(stdout, "Save swapped text after use\n"); fprintf(stdout, "Permissions: %o\n",sbp.st_mode & 0xfff); fprintf(stdout, "Last access: %s", asctime(localtime(&sbp.st_atime ))); fprintf(stdout, "Last modification: %s", asctime(localtime(&sbp.st_mtime ))); fprintf(stdout, "Last status change: %s", asctime(localtime(&sbp.st_ctime ))); } } exit(error); } --------------------------------------------------------------------------- Thank you all for the very quick response and the informations. Best Regards, Iwan ------_=_NextPart_001_01C09CB4.B7D9858A Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable SUMMARY: Info on file creation/modification up to the = second

Hi All,

I thank you for the very quick answer to:
James Sainsbury and
J.A. Gutierrez

o  James sugested to make c program using the = stat() function. or using the gnu ls which is part of fileutils which = has this command:

% ls -l --full-time passwd
-rw-r--r--    1 = root     = root          858 Tue Jan = 30 14:55:36 2001 passwd

o Mr. Gutierrez even give me the C source code to do = it:

.c-------------------------------------------------------------= -----
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <errno.h>


main( int argc, char **argv)
{
        struct = stat     sbp;
        int     =         =         f;
        int     =         =         isdevice=3D0;
        struct = passwd   *pw;
        struct = group    *gr;
        char    =         =         *name;
        int     =         =         =         error=3D0;

        if ( argc = =3D=3D 1 )
        {
        =         fprintf(stderr,"Use: %s = filename(s)\n",argv[0]);
        =         exit(1);
        }
        for( = f=3D1; f<argc; f ++)
        {
        =         printf("\n\tName:\t%s\n",argv[f]);

        =         if ( = stat(argv[f],&sbp)=3D=3D-1)
        =         {
        =         =         perror("stat");
        =         =         error++;
        =         }
        =         else
        =         {
        =         =         switch = (sbp.st_mode & S_IFMT)
        =         =         {
        =         =         =         case = S_IFIFO:
        =         =         =         =         fprintf(stdout,"\t\tnamed pipe (fifo)\n");
        =         =         =         =         break;
        =         =         =         case = S_IFCHR:
        =         =         =         =         fprintf(stdout,"\t\tcharacter special\n");
        =         =         =         =         isdevice=3D1;
        =         =         =         =         break;
        =         =         =         case = S_IFDIR:
        =         =         =         =         fprintf(stdout,"\t\tdirectory\n");
        =         =         =         =         break;
        =         =         =         case = S_IFBLK:
        =         =         =         =         fprintf(stdout,"\t\tblock special\n");
        =              = ;           =         isdevice=3D1;
        =         =         =         =         break;
        =         =         =         case = S_IFREG:
        =         =         =         =         fprintf(stdout,"\t\tregular\n");
        =         =         =         =         break;
        =         =         =         case = S_IFLNK:
        =         =         =         =         fprintf(stdout,"\t\tsymbolic link\n");
        =         =         =         =         break;
        =         =         =         case = S_IFSOCK:
        =         =         =         =         fprintf(stdout,"\t\tsocket\n");
        =         =         =         =         break;
        =         =         =         default:
        =         =         =         =         fprintf(stdout,"\t\tunknown\n");
        =         =         =         =         break;
        =         =         }
        =        =20
        =         =         if = (isdevice)
        =         =         =         fprintf(stdout, "Device number:%d,%d\n",
        =         =         =         =         =         (sbp.st_rdev>>8) & 0xff,
        =         =         =         =         =         sbp.st_rdev = & 0xff );

        =         =         =         fprintf(stdout, "Resides on device:%d,%d\n",
        =         =         =         =         =         (sbp.st_dev>>8) & 0xff,
        =         =         =         =         =         sbp.st_dev = & 0xff);
        =        =20
        =         =         =         fprintf(stdout, "I-node: %d; Links: %d; Size: = %ld\n",
        =         =         =         =         =         sbp.st_ino, = sbp.st_nlink, sbp.st_size);

        =         =         =         if (( = pw=3Dgetpwuid(sbp.st_uid))=3D=3DNULL)
        =         =         =         =         name=3D"???";
        =         =         =         else
        =         =         =         =         name=3Dpw->pw_name;

        =         =         =         fprintf(stdout, "Owner ID: %d; Name: %s\n", = sbp.st_uid, name);


        =         =         =         if (( = gr=3Dgetgrgid(sbp.st_gid))=3D=3DNULL)
        =         =         =         =         name=3D"???";
        =         =              = ;   else
        =         =         =         =         name=3Dgr->gr_name;

        =         =         =         fprintf(stdout, "Group ID: %d; Name: %s\n", = sbp.st_gid, name);

        =         =         =         if = ((sbp.st_mode & S_ISUID )=3D=3D S_ISUID )
        =         =         =         =         fprintf(stdout, "Set-user-ID\n");

        =         =         =         if = ((sbp.st_mode & S_ISGID )=3D=3D S_ISGID )
        =         =         =         =         fprintf(stdout, "Set-group-ID\n");

        =         =         =         if = ((sbp.st_mode & S_ISVTX )=3D=3D S_ISVTX )
        =         =         =         =         fprintf(stdout, "Save swapped text after = use\n");

        =         =         =         fprintf(stdout, "Permissions: %o\n",sbp.st_mode = & 0xfff);
        =         =         =         fprintf(stdout, "Last = access:         = %s",
        =         =         =         =         asctime(localtime(&sbp.st_atime )));
        =         =         =         fprintf(stdout, "Last modification:   = %s",
        =         =         =         =         asctime(localtime(&sbp.st_mtime )));
        =         =         =         fprintf(stdout, "Last status change:  = %s",
        =         =         =              = ;   asctime(localtime(&sbp.st_ctime = )));

        =         }
        }
        exit(error);
}

---------------------------------------------------------------= ------------

Thank you all for the very quick response and the = informations.

Best Regards,

Iwan

------_=_NextPart_001_01C09CB4.B7D9858A--