From ad46eb4132cbd2c4ee23686a1c52f2fc57afffc5 Mon Sep 17 00:00:00 2001 From: chantra Date: Tue, 8 Feb 2022 17:06:55 -0800 Subject: [PATCH 14/30] [fsm] Call new `rpmpluginsCallFsmFileInstall` in `rpmPackageFilesInstall` Call `rpmpluginsCallFsmFileInstall` for every files to be installed by `rpmPackageFilesInstall`, this allows for plugin such as reflink to write (reflink) a file and make sure the parent directories have already been created. If this was done in `rpmpluginsCallFsmFilePre`, the directories may be missing, which makes file installation fail. --- lib/fsm.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/lib/fsm.c b/lib/fsm.c index feda3750c..711f553d3 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -55,7 +55,6 @@ struct filedata_s { int stage; int setmeta; int skip; - int plugin_contents; rpmFileAction action; const char *suffix; char *fpath; @@ -918,20 +917,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files, fp->setmeta = (fp->skip == 0) && (fp->sb.st_nlink == 1 || fp->action == FA_TOUCH); - switch (rc) { - case RPMRC_OK: - setFileState(fs, fx); - break; - case RPMRC_PLUGIN_CONTENTS: - fp->plugin_contents = 1; - // reduce reads on cpio to this value. Could be zero if - // this is from a hard link. - rc = RPMRC_OK; - break; - default: - fp->action = FA_SKIP; - fp->skip = XFA_SKIPPING(fp->action); - } + setFileState(fs, fx); fsmDebug(rpmfiDN(fi), fp->fpath, fp->action, &fp->sb); fp->stage = FILE_PRE; @@ -984,10 +970,6 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files, if (!rc) { rc = rpmpluginsCallFsmFilePre(plugins, fi, fp->fpath, fp->sb.st_mode, fp->action); - if (rc == RPMRC_PLUGIN_CONTENTS) { - fp->plugin_contents = 1; - rc = RPMRC_OK; - } } if (rc) goto setmeta; /* for error notification */ @@ -1016,15 +998,16 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files, if (fp->action == FA_TOUCH) goto setmeta; - if (S_ISREG(fp->sb.st_mode)) { + rpmRC plugin_rc = rpmpluginsCallFsmFileInstall(plugins, fi, fp->fpath, fp->sb.st_mode, fp->action); + if (!(plugin_rc == RPMRC_PLUGIN_CONTENTS || plugin_rc == RPMRC_OK)){ + rc = plugin_rc; + } else if(plugin_rc == RPMRC_PLUGIN_CONTENTS){ + rc = RPMRC_OK; + } else if (S_ISREG(fp->sb.st_mode)) { if (rc == RPMERR_ENOENT) { - if (fp->plugin_contents) { - rc = RPMRC_OK; - } else { - rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest, - &firstlink, &firstlinkfile, - &di.firstdir, &fd); - } + rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest, + &firstlink, &firstlinkfile, + &di.firstdir, &fd); } } else if (S_ISDIR(fp->sb.st_mode)) { if (rc == RPMERR_ENOENT) { -- 2.35.1