From c272049116d4644e8c0af2e115dc100a6ca2d884 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Sat, 29 Dec 2007 15:56:59 -0500 Subject: [PATCH] Use fstat() instead of stat() when opening rpm. --- rpm.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rpm.c b/rpm.c index dc5d355..0eac911 100644 --- a/rpm.c +++ b/rpm.c @@ -128,16 +128,18 @@ razor_rpm_open(const char *filename) rpm = malloc(sizeof *rpm); memset(rpm, 0, sizeof *rpm); - if (stat(filename, &buf) < 0) { - fprintf(stderr, "no such file %s (%m)\n", filename); - return NULL; - } fd = open(filename, O_RDONLY); if (fd < 0) { fprintf(stderr, "couldn't open %s\n", filename); return NULL; } + + if (fstat(fd, &buf) < 0) { + fprintf(stderr, "failed to stat %s (%m)\n", filename); + return NULL; + } + rpm->size = buf.st_size; rpm->map = mmap(NULL, rpm->size, PROT_READ, MAP_PRIVATE, fd, 0); if (rpm->map == MAP_FAILED) { @@ -290,7 +292,9 @@ create_path(struct installer *installer, buffer); return -1; } - /* FIXME: permissions */ + + /* FIXME: What to do about permissions for dirs we + * have to create but are not in the cpio archive? */ } *p++ = '/'; -- 1.7.1