RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 08-Feb-2008 22:02:16
Branch: HEAD Handle: 2008020821021501
Modified files:
rpm CHANGES
rpm/rpmio tdir.c tfts.c tget.c
Log:
- jbj: tweak up tget debugging spew, trick in a Stat(2) on path,
add Stat(2)/Fread(3) stopwatches, display same as "ls -island" output.
Summary:
Revision Changes Path
1.2155 +4 -1 rpm/CHANGES
2.11 +2 -0 rpm/rpmio/tdir.c
2.17 +3 -1 rpm/rpmio/tfts.c
1.13 +107 -10 rpm/rpmio/tget.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2154 -r1.2155 CHANGES
--- rpm/CHANGES 8 Feb 2008 19:42:39 -0000 1.2154
+++ rpm/CHANGES 8 Feb 2008 21:02:15 -0000 1.2155
@@ -1,8 +1,11 @@
5.0.0 -> 5.1a1:
+ - jbj: tweak up tget debugging spew, trick in a Stat(2) on path,
+ add Stat(2)/Fread(3) stopwatches, display same as "ls -island" output.
- proyvind: python: add back RPMSENSE_FIND_REQUIRES, needed by rpmlint
- jbj: use hashFunctionString on URI path for st->st_ino/dp->d_ino values.
- jbj: rpmhash: expose hash{Equality,Function}String routines.
- - jbj: tweak up tdir debugging spew, add a Fts(3) stopwatch, append pesky /.
+ - jbj: tweak up tdir debugging spew, add a Opendir(3) stopwatch,
+ append pesky /.
- jbj: tweak up tfts debugging spew, add a Fts(3) stopwatch, append pesky /.
- jbj: rpmsw: add rpmswPrint to display stopwtch results.
- jbj: rpmdav: fix: check the pesky trailing '/' on collections correctly.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tdir.c
============================================================================
$ cvs diff -u -r2.10 -r2.11 tdir.c
--- rpm/rpmio/tdir.c 8 Feb 2008 16:31:44 -0000 2.10
+++ rpm/rpmio/tdir.c 8 Feb 2008 21:02:16 -0000 2.11
@@ -94,6 +94,8 @@
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
+_url_debug = -1;
+_rpmio_debug = -1;
}
av = poptGetArgs(optCon);
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tfts.c
============================================================================
$ cvs diff -u -r2.16 -r2.17 tfts.c
--- rpm/rpmio/tfts.c 8 Feb 2008 16:31:44 -0000 2.16
+++ rpm/rpmio/tfts.c 8 Feb 2008 21:02:16 -0000 2.17
@@ -228,8 +228,10 @@
rpmIncreaseVerbosity();
rpmIncreaseVerbosity();
_av_debug = -1;
-_dav_debug = 1;
+_dav_debug = -1;
_ftp_debug = -1;
+_url_debug = -1;
+_rpmio_debug = -1;
_rpmmg_debug = 1;
_mire_debug = 1;
}
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/tget.c
============================================================================
$ cvs diff -u -r1.12 -r1.13 tget.c
--- rpm/rpmio/tget.c 7 Feb 2008 23:36:32 -0000 1.12
+++ rpm/rpmio/tget.c 8 Feb 2008 21:02:16 -0000 1.13
@@ -10,21 +10,115 @@
static int _debug = 0;
-static void readFile(const char * path)
+static char * rpmPermsString(mode_t st_mode)
{
+ char *perms = xstrdup("----------");
+
+ if (S_ISREG(st_mode))
+ perms[0] = '-';
+ else if (S_ISDIR(st_mode))
+ perms[0] = 'd';
+ else if (S_ISLNK(st_mode))
+ perms[0] = 'l';
+ else if (S_ISFIFO(st_mode))
+ perms[0] = 'p';
+ /*@-unrecog@*/
+ else if (S_ISSOCK(st_mode))
+ perms[0] = 's';
+ /*@=unrecog@*/
+ else if (S_ISCHR(st_mode))
+ perms[0] = 'c';
+ else if (S_ISBLK(st_mode))
+ perms[0] = 'b';
+ else
+ perms[0] = '?';
+
+ if (st_mode & S_IRUSR) perms[1] = 'r';
+ if (st_mode & S_IWUSR) perms[2] = 'w';
+ if (st_mode & S_IXUSR) perms[3] = 'x';
+
+ if (st_mode & S_IRGRP) perms[4] = 'r';
+ if (st_mode & S_IWGRP) perms[5] = 'w';
+ if (st_mode & S_IXGRP) perms[6] = 'x';
+
+ if (st_mode & S_IROTH) perms[7] = 'r';
+ if (st_mode & S_IWOTH) perms[8] = 'w';
+ if (st_mode & S_IXOTH) perms[9] = 'x';
+
+ if (st_mode & S_ISUID)
+ perms[3] = ((st_mode & S_IXUSR) ? 's' : 'S');
+
+ if (st_mode & S_ISGID)
+ perms[6] = ((st_mode & S_IXGRP) ? 's' : 'S');
+
+ if (st_mode & S_ISVTX)
+ perms[9] = ((st_mode & S_IXOTH) ? 't' : 'T');
+
+ return perms;
+}
+
+static void printStat(const char * path, struct stat * st)
+{
+ size_t nt = 100;
+ char * t = alloca(nt);
+ time_t when = st->st_mtime;
+ struct tm * tm = localtime(&when);
+ size_t nb = strftime(t, nt, "%F %T", tm);
+ const char * perms = rpmPermsString(st->st_mode);
+
+ t[nb] = '\0';
+ /* XXX Note st->st_blocks to convert to linux "ls -island" spew. */
+ fprintf(stderr, "%u %u %s %u %u %u %u %s %s",
+ (unsigned) st->st_ino, (unsigned)st->st_blocks/2,
+ perms, (unsigned)st->st_nlink,
+ (unsigned)st->st_uid, (unsigned)st->st_gid,
+ (unsigned)st->st_size, t, path);
+ fprintf(stderr, "\n");
+ perms = _free(perms);
+}
+
+static int readFile(const char * path)
+{
+ rpmop sop = memset(alloca(sizeof(*sop)), 0, sizeof(*sop));
+ rpmop gop = memset(alloca(sizeof(*gop)), 0, sizeof(*gop));
FD_t fd;
+ struct stat sb;
+ size_t len = 0;
+ int rc;
+ int xx;
fprintf(stderr, "===== %s\n", path);
- fd = Fopen(path, "r");
+ xx = rpmswEnter(sop, 0);
+ rc = Stat(path, &sb);
+ xx = rpmswExit(sop, 1);
+ if (rc < 0)
+ goto exit;
+
+ printStat(path, &sb);
+ if (!S_ISREG(sb.st_mode))
+ goto exit;
+
+ xx = rpmswEnter(gop, 0);
+ fd = Fopen(path, "r.ufdio");
if (fd != NULL) {
- char buf[BUFSIZ];
- size_t len = Fread(buf, 1, sizeof(buf), fd);
- int xx;
+ size_t nb = 8 * BUFSIZ;
+ char * buf = alloca(nb);
+ *buf = '\0';
+ len = Fread(buf, 1, nb-2, fd);
+ buf[BUFSIZ-1] = '\0';
xx = Fclose(fd);
-
- if (len > 0)
- fwrite(buf, 1, len, stderr);
+ if (rpmIsVerbose() && len >= 0) {
+ buf[len] = '\n';
+ buf[len+1] = '\0';
+ fwrite(buf, 1, len+1, stderr);
+ }
}
+ xx = rpmswExit(gop, len);
+
+exit:
+ rpmswPrint("stat:", sop);
+ rpmswPrint(" get:", gop);
+ return rc;
}
static struct poptOption optionsTable[] = {
@@ -54,6 +148,7 @@
int ac;
const char * fn;
int rc;
+ int xx;
while ((rc = poptGetNextOpt(optCon)) > 0) {
const char * optArg = poptGetOptArg(optCon);
@@ -71,8 +166,10 @@
rpmIncreaseVerbosity();
rpmIncreaseVerbosity();
_av_debug = -1;
-_dav_debug = 1;
+_dav_debug = -1;
_ftp_debug = -1;
+_url_debug = -1;
+_rpmio_debug = -1;
}
av = poptGetArgs(optCon);
@@ -83,7 +180,7 @@
}
while ((fn = *av++) != NULL)
- readFile(fn);
+ xx = readFile(fn);
exit:
@@ .
Received on Fri Feb 8 22:02:16 2008