Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xinstall simplify metadata logging, and add metadata...



details:   https://anonhg.NetBSD.org/src/rev/e1a9f35faa3b
branches:  trunk
changeset: 517767:e1a9f35faa3b
user:      perry <perry%NetBSD.org@localhost>
date:      Mon Nov 19 02:51:00 2001 +0000

description:
simplify metadata logging, and add metadata logging for hard links.

diffstat:

 usr.bin/xinstall/xinstall.c |  48 ++++++++++----------------------------------
 1 files changed, 11 insertions(+), 37 deletions(-)

diffs (131 lines):

diff -r edc2ecfb4860 -r e1a9f35faa3b usr.bin/xinstall/xinstall.c
--- a/usr.bin/xinstall/xinstall.c       Mon Nov 19 02:46:50 2001 +0000
+++ b/usr.bin/xinstall/xinstall.c       Mon Nov 19 02:51:00 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xinstall.c,v 1.58 2001/11/12 19:08:31 tv Exp $ */
+/*     $NetBSD: xinstall.c,v 1.59 2001/11/19 02:51:00 perry Exp $      */
 
 /*
  * Copyright (c) 1987, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
 #else
-__RCSID("$NetBSD: xinstall.c,v 1.58 2001/11/12 19:08:31 tv Exp $");
+__RCSID("$NetBSD: xinstall.c,v 1.59 2001/11/19 02:51:00 perry Exp $");
 #endif
 #endif /* not lint */
 
@@ -98,14 +98,13 @@
 
 void   backup(const char *);
 void   copy(int, char *, int, char *, off_t);
-const char *inotype(u_int);
 void   install(char *, char *, u_int);
 void   install_dir(char *, u_int);
 int    main(int, char *[]);
 void   makelink(char *, char *);
 int    parseid(char *, id_t *);
 void   strip(char *);
-void   metadata_log(const char *, mode_t, struct timeval *, const char *);
+void   metadata_log(const char *, const char *, struct timeval *, const char *);
 void   usage(void);
 
 int
@@ -339,7 +338,7 @@
                                err(1, "link %s -> %s", from_name, to_name);
                }
                else {
-                       /* XXX: need to log hard link metadata ? */
+                       metadata_log(to_name, "hlink", NULL, from_name);
                        return;
                }
        }
@@ -351,7 +350,7 @@
                        err(1, "%s", src);
                if (symlink(src, to_name) == -1)
                        err(1, "symlink %s -> %s", src, to_name);
-               metadata_log(to_name, S_IFLNK, NULL, src);
+               metadata_log(to_name, "link", NULL, src);
                return;
        }
 
@@ -379,7 +378,7 @@
 
                if (symlink(lnk, dst) == -1)
                        err(1, "symlink %s -> %s", lnk, dst);
-               metadata_log(dst, S_IFLNK, NULL, lnk);
+               metadata_log(dst, "link", NULL, lnk);
                return;
        }
 
@@ -389,7 +388,7 @@
         */
        if (symlink(from_name, to_name) == -1)
                err(1, "symlink %s -> %s", from_name, to_name);
-       metadata_log(to_name, S_IFLNK, NULL, from_name);
+       metadata_log(to_name, "link", NULL, from_name);
 }
 
 /*
@@ -550,7 +549,7 @@
                        warn("%s: chflags", to_name);
        }
 
-       metadata_log(to_name, S_IFREG, tv, NULL);
+       metadata_log(to_name, "file", tv, NULL);
 }
 
 /*
@@ -722,32 +721,7 @@
            || chmod(path, mode) == -1 )) {
                 warn("%s", path);
        }
-       metadata_log(path, S_IFDIR, NULL, NULL);
-}
-
-const char *
-inotype(u_int type)
-{
-
-       switch (type & S_IFMT) {
-       case S_IFBLK:
-               return ("block");
-       case S_IFCHR:
-               return ("char");
-       case S_IFDIR:
-               return ("dir");
-       case S_IFIFO:
-               return ("fifo");
-       case S_IFREG:
-               return ("file");
-       case S_IFLNK:
-               return ("link");
-       case S_IFSOCK:
-               return ("socket");
-       default:
-               return ("unknown");
-       }
-       /* NOTREACHED */
+       metadata_log(path, "dir", NULL, NULL);
 }
 
 /*
@@ -756,7 +730,7 @@
  *     metafp, to allow permissions to be set correctly by other tools.
  */
 void
-metadata_log(const char *path, mode_t type, struct timeval *tv,
+metadata_log(const char *path, const char *type, struct timeval *tv,
        const char *link)
 {
        const char      extra[] = { ' ', '\t', '\n', '\\', '#', '\0' };
@@ -776,7 +750,7 @@
 
        strsvis(buf, path, VIS_CSTYLE, extra);          /* encode name */
        fprintf(metafp, ".%s%s type=%s mode=%#o",       /* print details */
-           buf[0] == '/' ? "" : "/", buf, inotype(type), mode);
+           buf[0] == '/' ? "" : "/", buf, type, mode);
        if (link)
                fprintf(metafp, " link=%s", link);
        if (owner)



Home | Main Index | Thread Index | Old Index