diff options
author | jbj <devnull@localhost> | 2002-08-13 20:40:32 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-08-13 20:40:32 +0000 |
commit | 48a2529ce4b3ab1f677d3de9b70e8cbe14d910c6 (patch) | |
tree | 318f4066a1c3d2eee21732d288e74e0dc963067e /rpmio | |
parent | 9b29055f422cd5f2aeff27b6c80e7c83317920c9 (diff) | |
download | librpm-tizen-48a2529ce4b3ab1f677d3de9b70e8cbe14d910c6.tar.gz librpm-tizen-48a2529ce4b3ab1f677d3de9b70e8cbe14d910c6.tar.bz2 librpm-tizen-48a2529ce4b3ab1f677d3de9b70e8cbe14d910c6.zip |
- fix: rebuilddb stat'ed target, not source, for rename sanity.
- create /var/lib/rpm if non-existent in, say, a chroot.
- erased packages are now repackaged into /var/spool/repackage.
CVS patchset: 5625
CVS date: 2002/08/13 20:40:32
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/rpmio.c | 48 | ||||
-rw-r--r-- | rpmio/rpmio.h | 12 |
2 files changed, 60 insertions, 0 deletions
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index e0613dbd3..81c086aeb 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -3152,6 +3152,54 @@ int Fcntl(FD_t fd, int op, void *lip) /* =============================================================== */ /* Helper routines that may be generally useful. */ +int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) +{ + char * d, * de; + int created = 0; + int rc; + + if (path == NULL) + return -1; + d = alloca(strlen(path)+2); + de = stpcpy(d, path); + de[1] = '\0'; + for (de = d; *de != '\0'; de++) { + struct stat st; + char savec; + + while (*de && *de != '/') de++; + savec = de[1]; + de[1] = '\0'; + + rc = Stat(d, &st); + if (rc) { + switch(errno) { + default: + return errno; + /*@notreached@*/ /*@switchbreak@*/ break; + case ENOENT: + /*@switchbreak@*/ break; + } + rc = Mkdir(d, mode); + if (rc) + return errno; + created = 1; + if (!(uid == (uid_t) -1 && gid == (gid_t) -1)) { + rc = chown(d, uid, gid); + if (rc) + return errno; + } + } else if (!S_ISDIR(st.st_mode)) { + return ENOTDIR; + } + de[1] = savec; + } + rc = 0; + if (created) + rpmMessage(RPMMESS_DEBUG, "created directory(s) %s mode 0%o\n", + path, mode); + return rc; +} /*@-boundswrite@*/ int rpmioSlurp(const char * fn, const byte ** bp, ssize_t * blenp) diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index 1b7ec8492..2a39639e6 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -544,6 +544,18 @@ int fdReadable(FD_t fd, int secs) /*@=exportlocal@*/ /** + * Insure that directories in path exist, creating as needed. + * @param path diretory path + * @param mode directory mode (if created) + * @param uid directory uid (if created), or -1 to skip + * @param gid directory uid (if created), or -1 to skip + * @return 0 on success, errno (or -1) on error + */ +int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) + /*@globals fileSystem, internalState @*/ + /*@modifies fileSystem, internalState @*/; + +/** * FTP and HTTP error codes. */ /*@-typeuse@*/ |