Use regular POSIX functions instead of "RPC" clones
- we only care about local files
This commit is contained in:
parent
fb90b8b4eb
commit
9cbf0349b8
4
build.c
4
build.c
|
@ -226,7 +226,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
|
|||
|
||||
if (specut != URL_IS_DASH) {
|
||||
struct stat st;
|
||||
if (Stat(specURL, &st) < 0) {
|
||||
if (stat(specURL, &st) < 0) {
|
||||
rpmlog(RPMLOG_ERR, _("failed to stat %s: %m\n"), specURL);
|
||||
rc = 1;
|
||||
goto exit;
|
||||
|
@ -277,7 +277,7 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
|
|||
}
|
||||
|
||||
if (ba->buildMode == 't')
|
||||
(void) Unlink(specURL);
|
||||
(void) unlink(specURL);
|
||||
rc = 0;
|
||||
|
||||
exit:
|
||||
|
|
|
@ -22,13 +22,13 @@ static void doRmSource(rpmSpec spec)
|
|||
int rc;
|
||||
|
||||
#if 0
|
||||
rc = Unlink(spec->specFile);
|
||||
rc = unlink(spec->specFile);
|
||||
#endif
|
||||
|
||||
for (p = spec->sources; p != NULL; p = p->next) {
|
||||
if (! (p->flags & RPMBUILD_ISNO)) {
|
||||
const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
|
||||
rc = Unlink(fn);
|
||||
rc = unlink(fn);
|
||||
fn = _free(fn);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static void doRmSource(rpmSpec spec)
|
|||
for (p = pkg->icon; p != NULL; p = p->next) {
|
||||
if (! (p->flags & RPMBUILD_ISNO)) {
|
||||
const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
|
||||
rc = Unlink(fn);
|
||||
rc = unlink(fn);
|
||||
fn = _free(fn);
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ fprintf(stderr, "*** addMacros\n");
|
|||
exit:
|
||||
if (scriptName) {
|
||||
if (!rc)
|
||||
(void) Unlink(scriptName);
|
||||
(void) unlink(scriptName);
|
||||
scriptName = _free(scriptName);
|
||||
}
|
||||
if (u != NULL) {
|
||||
|
@ -324,7 +324,7 @@ int buildSpec(rpmts ts, rpmSpec spec, int what, int test)
|
|||
doRmSource(spec);
|
||||
|
||||
if (what & RPMBUILD_RMSPEC)
|
||||
(void) Unlink(spec->specFile);
|
||||
(void) unlink(spec->specFile);
|
||||
|
||||
exit:
|
||||
if (rc && rpmlogGetNrecs() > 0) {
|
||||
|
|
|
@ -1204,7 +1204,7 @@ static void genCpioListAndHeader(FileList fl,
|
|||
|
||||
buf[0] = '\0';
|
||||
if (S_ISLNK(flp->fl_mode)) {
|
||||
buf[Readlink(flp->diskURL, buf, BUFSIZ)] = '\0';
|
||||
buf[readlink(flp->diskURL, buf, BUFSIZ)] = '\0';
|
||||
if (fl->buildRootURL) {
|
||||
const char * buildRoot;
|
||||
(void) urlPath(fl->buildRootURL, &buildRoot);
|
||||
|
@ -1440,7 +1440,7 @@ static int addFile(FileList fl, const char * diskURL,
|
|||
statp->st_atime = now;
|
||||
statp->st_mtime = now;
|
||||
statp->st_ctime = now;
|
||||
} else if (Lstat(diskURL, statp)) {
|
||||
} else if (lstat(diskURL, statp)) {
|
||||
rpmlog(RPMLOG_ERR, _("File not found: %s\n"), diskURL);
|
||||
fl->processingFailed = 1;
|
||||
return RPMLOG_ERR;
|
||||
|
@ -1701,7 +1701,7 @@ static int processBinaryFile(Package pkg, FileList fl,
|
|||
const char *diskURL = NULL;
|
||||
int rc = 0;
|
||||
|
||||
doGlob = Glob_pattern_p(fileURL, quote);
|
||||
doGlob = glob_pattern_p(fileURL, quote);
|
||||
|
||||
/* Check that file starts with leading "/" */
|
||||
{ const char * fileName;
|
||||
|
@ -1738,7 +1738,7 @@ static int processBinaryFile(Package pkg, FileList fl,
|
|||
}
|
||||
|
||||
rc = rpmGlob(diskURL, &argc, &argv);
|
||||
if (rc == 0 && argc >= 1 && !Glob_pattern_p(argv[0], quote)) {
|
||||
if (rc == 0 && argc >= 1 && !glob_pattern_p(argv[0], quote)) {
|
||||
for (i = 0; i < argc; i++) {
|
||||
rc = addFile(fl, argv[i], NULL);
|
||||
argv[i] = _free(argv[i]);
|
||||
|
@ -2191,7 +2191,7 @@ int processSourceFiles(rpmSpec spec)
|
|||
flp->fileURL = xstrdup(diskPath);
|
||||
flp->verifyFlags = RPMVERIFY_ALL;
|
||||
|
||||
if (Stat(diskURL, &flp->fl_st)) {
|
||||
if (stat(diskURL, &flp->fl_st)) {
|
||||
rpmlog(RPMLOG_ERR, _("Bad file: %s: %s\n"),
|
||||
diskURL, strerror(errno));
|
||||
fl.processingFailed = 1;
|
||||
|
|
10
build/pack.c
10
build/pack.c
|
@ -443,7 +443,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
|
|||
|
||||
(void) Fclose(fd);
|
||||
fd = NULL;
|
||||
(void) Unlink(fileName);
|
||||
(void) unlink(fileName);
|
||||
|
||||
if (rc)
|
||||
goto exit;
|
||||
|
@ -581,14 +581,14 @@ exit:
|
|||
fd = NULL;
|
||||
}
|
||||
if (sigtarget) {
|
||||
(void) Unlink(sigtarget);
|
||||
(void) unlink(sigtarget);
|
||||
sigtarget = _free(sigtarget);
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
rpmlog(RPMLOG_NOTICE, _("Wrote: %s\n"), fileName);
|
||||
else
|
||||
(void) Unlink(fileName);
|
||||
(void) unlink(fileName);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -666,10 +666,10 @@ int packageBinaries(rpmSpec spec)
|
|||
const char *dn;
|
||||
*binDir = '\0';
|
||||
dn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
|
||||
if (Stat(dn, &st) < 0) {
|
||||
if (stat(dn, &st) < 0) {
|
||||
switch(errno) {
|
||||
case ENOENT:
|
||||
if (Mkdir(dn, 0755) == 0)
|
||||
if (mkdir(dn, 0755) == 0)
|
||||
break;
|
||||
default:
|
||||
rpmlog(RPMLOG_ERR,_("cannot create %s: %s\n"),
|
||||
|
|
|
@ -34,7 +34,7 @@ static int checkOwners(const char * urlfn)
|
|||
{
|
||||
struct stat sb;
|
||||
|
||||
if (Lstat(urlfn, &sb)) {
|
||||
if (lstat(urlfn, &sb)) {
|
||||
rpmlog(RPMLOG_ERR, _("Bad source: %s: %s\n"),
|
||||
urlfn, strerror(errno));
|
||||
return RPMLOG_ERR;
|
||||
|
@ -187,7 +187,7 @@ static const char *doUntar(rpmSpec spec, int c, int quietly)
|
|||
if (sp->flags & RPMTAG_NOSOURCE && autofetchnosource) {
|
||||
struct stat st;
|
||||
int rc;
|
||||
if (Lstat(urlfn, &st) != 0 && errno == ENOENT &&
|
||||
if (lstat(urlfn, &st) != 0 && errno == ENOENT &&
|
||||
urlIsUrl(sp->fullSource) != URL_IS_UNKNOWN) {
|
||||
if ((rc = urlGetFile(sp->fullSource, urlfn)) != 0) {
|
||||
rpmlog(RPMLOG_ERR,
|
||||
|
|
22
lib/fsm.c
22
lib/fsm.c
|
@ -1919,10 +1919,10 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
case FSM_UNLINK:
|
||||
if (fsm->mapFlags & CPIO_SBIT_CHECK) {
|
||||
struct stat stb;
|
||||
if (Lstat(fsm->path, &stb) == 0 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
|
||||
if (lstat(fsm->path, &stb) == 0 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
|
||||
chmod(fsm->path, stb.st_mode & 0777);
|
||||
}
|
||||
rc = Unlink(fsm->path);
|
||||
rc = unlink(fsm->path);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s) %s\n", cur,
|
||||
fsm->path, (rc < 0 ? strerror(errno) : ""));
|
||||
|
@ -1930,7 +1930,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
rc = (errno == ENOENT ? CPIOERR_ENOENT : CPIOERR_UNLINK_FAILED);
|
||||
break;
|
||||
case FSM_RENAME:
|
||||
rc = Rename(fsm->opath, fsm->path);
|
||||
rc = rename(fsm->opath, fsm->path);
|
||||
#if defined(ETXTBSY)
|
||||
if (rc && errno == ETXTBSY) {
|
||||
char * path = alloca(strlen(fsm->path) + sizeof("-RPMDELETE"));
|
||||
|
@ -1939,8 +1939,8 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
* XXX HP-UX (and other os'es) don't permit rename to busy
|
||||
* XXX files.
|
||||
*/
|
||||
rc = Rename(fsm->path, path);
|
||||
if (!rc) rc = Rename(fsm->opath, fsm->path);
|
||||
rc = rename(fsm->path, path);
|
||||
if (!rc) rc = rename(fsm->opath, fsm->path);
|
||||
}
|
||||
#endif
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
|
@ -1949,7 +1949,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
if (rc < 0) rc = CPIOERR_RENAME_FAILED;
|
||||
break;
|
||||
case FSM_MKDIR:
|
||||
rc = Mkdir(fsm->path, (st->st_mode & 07777));
|
||||
rc = mkdir(fsm->path, (st->st_mode & 07777));
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, 0%04o) %s\n", cur,
|
||||
fsm->path, (unsigned)(st->st_mode & 07777),
|
||||
|
@ -1957,7 +1957,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
if (rc < 0) rc = CPIOERR_MKDIR_FAILED;
|
||||
break;
|
||||
case FSM_RMDIR:
|
||||
rc = Rmdir(fsm->path);
|
||||
rc = rmdir(fsm->path);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s) %s\n", cur,
|
||||
fsm->path, (rc < 0 ? strerror(errno) : ""));
|
||||
|
@ -2025,7 +2025,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
if (rc < 0) rc = CPIOERR_SYMLINK_FAILED;
|
||||
break;
|
||||
case FSM_LINK:
|
||||
rc = Link(fsm->opath, fsm->path);
|
||||
rc = link(fsm->opath, fsm->path);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, %s) %s\n", cur,
|
||||
fsm->opath, fsm->path, (rc < 0 ? strerror(errno) : ""));
|
||||
|
@ -2050,7 +2050,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
if (rc < 0) rc = CPIOERR_MKNOD_FAILED;
|
||||
break;
|
||||
case FSM_LSTAT:
|
||||
rc = Lstat(fsm->path, ost);
|
||||
rc = lstat(fsm->path, ost);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL) && rc && errno != ENOENT)
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, ost) %s\n", cur,
|
||||
fsm->path, (rc < 0 ? strerror(errno) : ""));
|
||||
|
@ -2060,7 +2060,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
}
|
||||
break;
|
||||
case FSM_STAT:
|
||||
rc = Stat(fsm->path, ost);
|
||||
rc = stat(fsm->path, ost);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL) && rc && errno != ENOENT)
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, ost) %s\n", cur,
|
||||
fsm->path, (rc < 0 ? strerror(errno) : ""));
|
||||
|
@ -2071,7 +2071,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
|
|||
break;
|
||||
case FSM_READLINK:
|
||||
/* XXX NUL terminated result in fsm->rdbuf, len in fsm->rdnb. */
|
||||
rc = Readlink(fsm->path, fsm->rdbuf, fsm->rdsize - 1);
|
||||
rc = readlink(fsm->path, fsm->rdbuf, fsm->rdsize - 1);
|
||||
if (_fsm_debug && (stage & FSM_SYSCALL))
|
||||
rpmlog(RPMLOG_DEBUG, " %8s (%s, rdbuf, %d) %s\n", cur,
|
||||
fsm->path, (int)(fsm->rdsize -1), (rc < 0 ? strerror(errno) : ""));
|
||||
|
|
|
@ -19,7 +19,7 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname)
|
|||
struct stat st;
|
||||
int rc;
|
||||
|
||||
if ((rc = Stat(dpath, &st)) < 0) {
|
||||
if ((rc = stat(dpath, &st)) < 0) {
|
||||
int ut = urlPath(dpath, NULL);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
|
@ -29,7 +29,7 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname)
|
|||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
rc = Mkdir(dpath, 0755);
|
||||
rc = mkdir(dpath, 0755);
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
|
@ -40,7 +40,7 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname)
|
|||
return RPMRC_FAIL;
|
||||
}
|
||||
}
|
||||
if ((rc = Access(dpath, W_OK))) {
|
||||
if ((rc = access(dpath, W_OK))) {
|
||||
rpmlog(RPMLOG_ERR, _("cannot write to %%%s %s\n"), dname, dpath);
|
||||
return RPMRC_FAIL;
|
||||
}
|
||||
|
|
|
@ -669,7 +669,7 @@ exit:
|
|||
for (i = 0; i < eiu->numPkgs; i++) {
|
||||
if (eiu->pkgURL[i] == NULL) continue;
|
||||
if (eiu->pkgState[i] == 1)
|
||||
(void) Unlink(eiu->pkgURL[i]);
|
||||
(void) unlink(eiu->pkgURL[i]);
|
||||
eiu->pkgURL[i] = _free(eiu->pkgURL[i]);
|
||||
}
|
||||
eiu->pkgState = _free(eiu->pkgState);
|
||||
|
|
|
@ -66,7 +66,7 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
|
|||
break;
|
||||
}
|
||||
|
||||
if (fn == NULL || Lstat(fn, &sb) != 0) {
|
||||
if (fn == NULL || lstat(fn, &sb) != 0) {
|
||||
*res |= RPMVERIFY_LSTATFAIL;
|
||||
return 1;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
|
|||
char linkto[1024+1];
|
||||
int size = 0;
|
||||
|
||||
if ((size = Readlink(fn, linkto, sizeof(linkto)-1)) == -1)
|
||||
if ((size = readlink(fn, linkto, sizeof(linkto)-1)) == -1)
|
||||
*res |= (RPMVERIFY_READLINKFAIL|RPMVERIFY_LINKTO);
|
||||
else {
|
||||
const char * flink = rpmfiFLink(fi);
|
||||
|
|
|
@ -3237,7 +3237,7 @@ static int rpmioFileExists(const char * urlfn)
|
|||
case URL_IS_HKP: /* XXX WRONG WRONG WRONG */
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_UNKNOWN:
|
||||
if (Stat(fn, &buf)) {
|
||||
if (stat(fn, &buf)) {
|
||||
switch(errno) {
|
||||
case ENOENT:
|
||||
case EINVAL:
|
||||
|
@ -3474,7 +3474,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts,
|
|||
}
|
||||
|
||||
rpmlog(RPMLOG_DEBUG, _("creating directory %s\n"), newrootdbpath);
|
||||
if (Mkdir(newrootdbpath, 0755)) {
|
||||
if (mkdir(newrootdbpath, 0755)) {
|
||||
rpmlog(RPMLOG_ERR, _("creating directory %s: %s\n"),
|
||||
newrootdbpath, strerror(errno));
|
||||
rc = 1;
|
||||
|
@ -3595,7 +3595,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts,
|
|||
exit:
|
||||
if (removedir && !(rc == 0 && nocleanup)) {
|
||||
rpmlog(RPMLOG_DEBUG, _("removing directory %s\n"), newrootdbpath);
|
||||
if (Rmdir(newrootdbpath))
|
||||
if (rmdir(newrootdbpath))
|
||||
rpmlog(RPMLOG_ERR, _("failed to remove directory %s: %s\n"),
|
||||
newrootdbpath, strerror(errno));
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ usrlib_LTLIBRARIES = librpmio.la
|
|||
librpmio_la_SOURCES = \
|
||||
argv.c base64.c digest.h digest.c fts.c macro.c \
|
||||
rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
|
||||
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c url.c ugid.c \
|
||||
rpmpgp.c rpmsq.c rpmsw.c strcasecmp.c url.c ugid.c \
|
||||
rpmio_internal.h rpmlua.h rpmhook.h ugid.h fts.h \
|
||||
rpmstring.c rpmfileutil.c
|
||||
|
||||
|
|
10
rpmio/fts.c
10
rpmio/fts.c
|
@ -136,11 +136,11 @@ Fts_open(char * const * argv, int options,
|
|||
return (NULL);
|
||||
memset(sp, 0, sizeof(*sp));
|
||||
sp->fts_compar = (int (*) (const void *, const void *)) compar;
|
||||
sp->fts_opendir = Opendir;
|
||||
sp->fts_readdir = Readdir;
|
||||
sp->fts_closedir = Closedir;
|
||||
sp->fts_stat = Stat;
|
||||
sp->fts_lstat = Lstat;
|
||||
sp->fts_opendir = opendir;
|
||||
sp->fts_readdir = readdir;
|
||||
sp->fts_closedir = closedir;
|
||||
sp->fts_stat = stat;
|
||||
sp->fts_lstat = lstat;
|
||||
sp->fts_options = options;
|
||||
|
||||
/* Logical walks turn on NOCHDIR; symbolic links are too hard. */
|
||||
|
|
|
@ -338,7 +338,7 @@ int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid)
|
|||
savec = de[1];
|
||||
de[1] = '\0';
|
||||
|
||||
rc = Stat(d, &st);
|
||||
rc = stat(d, &st);
|
||||
if (rc) {
|
||||
switch(errno) {
|
||||
default:
|
||||
|
@ -347,7 +347,7 @@ int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid)
|
|||
case ENOENT:
|
||||
break;
|
||||
}
|
||||
rc = Mkdir(d, mode);
|
||||
rc = mkdir(d, mode);
|
||||
if (rc)
|
||||
return errno;
|
||||
created = 1;
|
||||
|
@ -741,7 +741,7 @@ int rpmGlob(const char * patterns, int * argcPtr, const char *** argvPtr)
|
|||
int local = (ut == URL_IS_PATH) || (ut == URL_IS_UNKNOWN);
|
||||
glob_t gl;
|
||||
|
||||
if (!local || (!Glob_pattern_p(av[j], 0) && strchr(path, '~') == NULL)) {
|
||||
if (!local || (!glob_pattern_p(av[j], 0) && strchr(path, '~') == NULL)) {
|
||||
argv = xrealloc(argv, (argc+2) * sizeof(*argv));
|
||||
argv[argc] = xstrdup(av[j]);
|
||||
if (_debug)
|
||||
|
@ -752,7 +752,7 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, argv[argc]);
|
|||
|
||||
gl.gl_pathc = 0;
|
||||
gl.gl_pathv = NULL;
|
||||
rc = Glob(av[j], GLOB_TILDE, Glob_error, &gl);
|
||||
rc = glob(av[j], GLOB_TILDE, NULL, &gl);
|
||||
if (rc)
|
||||
goto exit;
|
||||
|
||||
|
@ -798,7 +798,7 @@ if (_debug)
|
|||
fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, globURL);
|
||||
argv[argc++] = xstrdup(globURL);
|
||||
}
|
||||
Globfree(&gl);
|
||||
globfree(&gl);
|
||||
globURL = _free(globURL);
|
||||
}
|
||||
|
||||
|
|
|
@ -839,7 +839,7 @@ DBGIO(fd, (stderr, "==>\tufdOpen(\"%s\",%x,0%o) %s\n", url, (unsigned)flags, (un
|
|||
|
||||
static struct FDIO_s ufdio_s = {
|
||||
ufdRead, ufdWrite, ufdSeek, ufdClose, XfdLink, XfdFree, XfdNew, fdFileno,
|
||||
ufdOpen, NULL, fdGetFp, NULL, Mkdir, Chdir, Rmdir, Rename, Unlink
|
||||
ufdOpen, NULL, fdGetFp, NULL, mkdir, chdir, rmdir, rename, unlink
|
||||
};
|
||||
FDIO_t ufdio = &ufdio_s ;
|
||||
|
||||
|
@ -1713,6 +1713,6 @@ exit:
|
|||
|
||||
static struct FDIO_s fpio_s = {
|
||||
ufdRead, ufdWrite, fdSeek, ufdClose, XfdLink, XfdFree, XfdNew, fdFileno,
|
||||
ufdOpen, NULL, fdGetFp, NULL, Mkdir, Chdir, Rmdir, Rename, Unlink
|
||||
ufdOpen, NULL, fdGetFp, NULL, mkdir, chdir, rmdir, rename, unlink
|
||||
};
|
||||
FDIO_t fpio = &fpio_s ;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include "misc/glob.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
@ -105,101 +103,6 @@ int Fileno(FD_t fd);
|
|||
*/
|
||||
int Fcntl(FD_t fd, int op, void *lip);
|
||||
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* \name RPMRPC Interface.
|
||||
*/
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* mkdir(2) clone.
|
||||
*/
|
||||
int Mkdir(const char * path, mode_t mode);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* chdir(2) clone.
|
||||
*/
|
||||
int Chdir(const char * path);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* rmdir(2) clone.
|
||||
*/
|
||||
int Rmdir(const char * path);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* rename(2) clone.
|
||||
*/
|
||||
int Rename(const char * oldpath, const char * newpath);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* link(2) clone.
|
||||
*/
|
||||
int Link(const char * oldpath, const char * newpath);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* unlink(2) clone.
|
||||
*/
|
||||
int Unlink(const char * path);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* readlink(2) clone.
|
||||
*/
|
||||
int Readlink(const char * path, char * buf, size_t bufsiz);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* stat(2) clone.
|
||||
*/
|
||||
int Stat(const char * path, struct stat * st);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* lstat(2) clone.
|
||||
*/
|
||||
int Lstat(const char * path, struct stat * st);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* access(2) clone.
|
||||
*/
|
||||
int Access(const char * path, int amode);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* glob_pattern_p(3) clone.
|
||||
*/
|
||||
int Glob_pattern_p (const char *pattern, int quote);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* glob_error(3) clone.
|
||||
*/
|
||||
int Glob_error(const char * epath, int eerrno);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* glob(3) clone.
|
||||
*/
|
||||
int Glob(const char * pattern, int flags,
|
||||
int errfunc(const char * epath, int eerrno),
|
||||
glob_t * pglob);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* globfree(3) clone.
|
||||
*/
|
||||
void Globfree( glob_t * pglob);
|
||||
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* opendir(3) clone.
|
||||
*/
|
||||
DIR * Opendir(const char * path);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* readdir(3) clone.
|
||||
*/
|
||||
struct dirent * Readdir(DIR * dir);
|
||||
|
||||
/** \ingroup rpmrpc
|
||||
* closedir(3) clone.
|
||||
*/
|
||||
int Closedir(DIR * dir);
|
||||
|
||||
|
||||
|
||||
/** \ingroup rpmio
|
||||
* \name RPMIO Utilities.
|
||||
*/
|
||||
|
|
413
rpmio/rpmrpc.c
413
rpmio/rpmrpc.c
|
@ -1,413 +0,0 @@
|
|||
/** \ingroup rpmio
|
||||
* \file rpmio/rpmrpc.c
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#if defined(HAVE_PTHREAD_H)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <rpmurl.h>
|
||||
#include <rpmstring.h>
|
||||
#include "rpmio/rpmio_internal.h"
|
||||
|
||||
#include "rpmio/ugid.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* =============================================================== */
|
||||
int Mkdir (const char * path, mode_t mode)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return mkdir(path, mode);
|
||||
}
|
||||
|
||||
int Chdir (const char * path)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return chdir(path);
|
||||
}
|
||||
|
||||
int Rmdir (const char * path)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return rmdir(path);
|
||||
}
|
||||
|
||||
/* XXX rpmdb.c: analogue to rename(2). */
|
||||
|
||||
int Rename (const char * oldpath, const char * newpath)
|
||||
{
|
||||
const char *oe = NULL;
|
||||
const char *ne = NULL;
|
||||
int oldut, newut;
|
||||
|
||||
/* XXX lib/install.c used to rely on this behavior. */
|
||||
if (!strcmp(oldpath, newpath)) return 0;
|
||||
|
||||
oldut = urlPath(oldpath, &oe);
|
||||
switch (oldut) {
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
|
||||
newut = urlPath(newpath, &ne);
|
||||
switch (newut) {
|
||||
case URL_IS_PATH:
|
||||
oldpath = oe;
|
||||
newpath = ne;
|
||||
break;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return rename(oldpath, newpath);
|
||||
}
|
||||
|
||||
int Link (const char * oldpath, const char * newpath)
|
||||
{
|
||||
const char *oe = NULL;
|
||||
const char *ne = NULL;
|
||||
int oldut, newut;
|
||||
|
||||
oldut = urlPath(oldpath, &oe);
|
||||
switch (oldut) {
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
|
||||
newut = urlPath(newpath, &ne);
|
||||
switch (newut) {
|
||||
case URL_IS_PATH:
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath);
|
||||
if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) &&
|
||||
!xstrncasecmp(oldpath, newpath, (oe - oldpath))))
|
||||
return -2;
|
||||
oldpath = oe;
|
||||
newpath = ne;
|
||||
break;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return link(oldpath, newpath);
|
||||
}
|
||||
|
||||
/* XXX build/build.c: analogue to unlink(2). */
|
||||
|
||||
int Unlink(const char * path) {
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
int Stat(const char * path, struct stat * st)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return stat(path, st);
|
||||
}
|
||||
|
||||
int Lstat(const char * path, struct stat * st)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return lstat(path, st);
|
||||
}
|
||||
|
||||
int Readlink(const char * path, char * buf, size_t bufsiz)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
/* FIX: *buf is undefined */
|
||||
return readlink(path, buf, bufsiz);
|
||||
}
|
||||
|
||||
int Access(const char * path, int amode)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return access(path, amode);
|
||||
}
|
||||
|
||||
/* glob_pattern_p() taken from bash
|
||||
* Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc.
|
||||
*
|
||||
* Return nonzero if PATTERN has any special globbing chars in it.
|
||||
*/
|
||||
int Glob_pattern_p (const char * pattern, int quote)
|
||||
{
|
||||
const char *p;
|
||||
int open = 0;
|
||||
char c;
|
||||
|
||||
(void) urlPath(pattern, &p);
|
||||
while ((c = *p++) != '\0')
|
||||
switch (c) {
|
||||
case '?':
|
||||
case '*':
|
||||
return (1);
|
||||
case '\\':
|
||||
if (quote && *p != '\0')
|
||||
p++;
|
||||
continue;
|
||||
|
||||
case '[':
|
||||
open = 1;
|
||||
continue;
|
||||
case ']':
|
||||
if (open)
|
||||
return (1);
|
||||
continue;
|
||||
|
||||
case '+':
|
||||
case '@':
|
||||
case '!':
|
||||
if (*p == '(')
|
||||
return (1);
|
||||
continue;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int Glob_error(const char * epath, int eerrno)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Glob(const char *pattern, int flags,
|
||||
int errfunc(const char * epath, int eerrno), glob_t *pglob)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(pattern, &lpath);
|
||||
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
pattern = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_FTP:
|
||||
default:
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
return glob(pattern, flags, errfunc, pglob);
|
||||
}
|
||||
|
||||
void Globfree(glob_t *pglob)
|
||||
{
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Globfree(%p)\n", pglob);
|
||||
globfree(pglob);
|
||||
}
|
||||
|
||||
DIR * Opendir(const char * path)
|
||||
{
|
||||
const char * lpath;
|
||||
int ut = urlPath(path, &lpath);
|
||||
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Opendir(%s)\n", path);
|
||||
switch (ut) {
|
||||
case URL_IS_PATH:
|
||||
path = lpath;
|
||||
case URL_IS_UNKNOWN:
|
||||
break;
|
||||
case URL_IS_DASH:
|
||||
case URL_IS_HKP:
|
||||
case URL_IS_FTP:
|
||||
case URL_IS_HTTPS:
|
||||
case URL_IS_HTTP:
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
return opendir(path);
|
||||
}
|
||||
|
||||
struct dirent * Readdir(DIR * dir)
|
||||
{
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Readdir(%p)\n", (void *)dir);
|
||||
if (dir == NULL)
|
||||
return NULL;
|
||||
return readdir(dir);
|
||||
}
|
||||
|
||||
int Closedir(DIR * dir)
|
||||
{
|
||||
if (_rpmio_debug)
|
||||
fprintf(stderr, "*** Closedir(%p)\n", (void *)dir);
|
||||
if (dir == NULL)
|
||||
return 0;
|
||||
return closedir(dir);
|
||||
}
|
|
@ -24,9 +24,9 @@ static void printDir(const char * path)
|
|||
int i;
|
||||
|
||||
fprintf(stderr, "===== %s\n", path);
|
||||
dir = Opendir(path);
|
||||
dir = opendir(path);
|
||||
i = 0;
|
||||
while ((dp = Readdir(dir)) != NULL) {
|
||||
while ((dp = readdir(dir)) != NULL) {
|
||||
fprintf(stderr, "%5d (%x,%x) %x %x %s\n", i++,
|
||||
(unsigned) dp->d_ino,
|
||||
(unsigned) dp->d_off,
|
||||
|
@ -34,7 +34,7 @@ fprintf(stderr, "%5d (%x,%x) %x %x %s\n", i++,
|
|||
(unsigned) dp->d_type,
|
||||
dp->d_name);
|
||||
}
|
||||
xx = Closedir(dir);
|
||||
xx = closedir(dir);
|
||||
}
|
||||
|
||||
static struct poptOption optionsTable[] = {
|
||||
|
|
|
@ -40,12 +40,12 @@ fprintf(stderr, "===== %s\n", path);
|
|||
gl.gl_pathc = 0;
|
||||
gl.gl_pathv = NULL;
|
||||
gl.gl_offs = 0;
|
||||
rc = Glob(path, 0, Glob_error, &gl);
|
||||
rc = glob(path, 0, NULL, &gl);
|
||||
fprintf(stderr, "*** Glob rc %d\n", rc);
|
||||
if (rc == 0)
|
||||
for (i = 0; i < gl.gl_pathc; i++)
|
||||
fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]);
|
||||
Globfree(&gl);
|
||||
globfree(&gl);
|
||||
}
|
||||
|
||||
static struct poptOption optionsTable[] = {
|
||||
|
|
|
@ -66,7 +66,7 @@ fprintf(stderr, "===> Fclose rc %d\n", xx);
|
|||
static int unlinkFile(const char * path)
|
||||
{
|
||||
fprintf(stderr, "===== Unlink %s\n", path);
|
||||
return Unlink(path);
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
static void doFile(const char * path)
|
||||
|
@ -86,7 +86,7 @@ fprintf(stderr, "===== %s\n", path);
|
|||
xx = writeFile(path);
|
||||
#if 0
|
||||
xx = readFile(path);
|
||||
xx = Unlink(path);
|
||||
xx = unlink(path);
|
||||
|
||||
xx = unlink("/home/toad/tput.txt");
|
||||
xx = unlink("/var/ftp/tput.txt");
|
||||
|
|
|
@ -291,7 +291,7 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : N
|
|||
case URL_IS_DASH:
|
||||
case URL_IS_UNKNOWN:
|
||||
if ((rc = ufdGetFile(sfd, tfd))) {
|
||||
(void) Unlink(dest);
|
||||
(void) unlink(dest);
|
||||
/* XXX FIXME: sfd possibly closed by copyData */
|
||||
(void) Fclose(sfd) ;
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ static int ftsStashLatest(FTSENT * fts, rpmts ts)
|
|||
items[i] = newItem();
|
||||
items[i]->path = xstrdup(fts->fts_path);
|
||||
st = fts->fts_statp;
|
||||
if (st == NULL && Stat(fts->fts_accpath, &sb) == 0)
|
||||
if (st == NULL && stat(fts->fts_accpath, &sb) == 0)
|
||||
st = &sb;
|
||||
|
||||
if (st != NULL) {
|
||||
|
@ -447,7 +447,7 @@ static void initGlobs(rpmts ts, const char ** argv)
|
|||
buf[0] = '\0';
|
||||
if (argv != NULL && * argv != NULL) {
|
||||
const char * arg;
|
||||
int single = (Glob_pattern_p(argv[0], 0) && argv[1] == NULL);
|
||||
int single = (glob_pattern_p(argv[0], 0) && argv[1] == NULL);
|
||||
char * t;
|
||||
|
||||
t = buf;
|
||||
|
|
Loading…
Reference in New Issue