RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [email protected] Module: rpm Date: 12-Jun-2017 08:55:35 Branch: rpm-5_4 Handle: 2017061206553400 Modified files: (Branch: rpm-5_4) rpm/rpmio tmount.c Log: - WIP. Summary: Revision Changes Path 1.1.2.3 +69 -94 rpm/rpmio/tmount.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/tmount.c ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 tmount.c --- rpm/rpmio/tmount.c 10 Jun 2017 00:22:36 -0000 1.1.2.2 +++ rpm/rpmio/tmount.c 12 Jun 2017 06:55:34 -0000 1.1.2.3 @@ -37,100 +37,6 @@ }; /*==============================================================*/ -#ifdef DYING -const char * rpmioB2N(struct poptOption * optTable, unsigned optFlags) -{ - char t[BUFSIZ]; - char * te = t; - struct poptOption * opt; - -#define POPT_MASK (POPT_ARGFLAG_LOGICALOPS|POPT_ARGFLAG_NOT|POPT_ARG_MASK) - for (opt=optTable; opt->longName || opt->shortName || opt->arg; opt++) { - int argInfo = opt->argInfo; - - switch (argInfo & POPT_MASK) { - case POPT_BIT_SET: - case POPT_BIT_CLR: - if (!(optFlags & opt->val)) - continue; - break; - default: - continue; - break; - } - if (te > t) - *te++ = '|'; - if (opt->argDescrip) - te = stpcpy(te, opt->argDescrip); - else - te += sprintf(te, "0x%x", opt->val); - optFlags &= ~opt->val; /* XXX first found only. */ - } -#undef POPT_MASK - if (te == t) - te = stpcpy(te, "0x0"); - *te = '\0'; - return xstrdup(t); -} - -unsigned rpmioN2B(struct poptOption * optTable, const char * options) -{ - ARGV_t av = NULL; - int xx = argvSplit(&av, options, ","); - int ac = argvCount(av); - struct poptOption * opt; - unsigned optFlags = 0; - (void)xx; - - for (int i = 0; i < ac; i++) { - const char * o = av[i]; - int negate = 0; - - /* Handle negated options. */ - if (*o == '!') { - negate ^= 1; - o++; - } - if (strchr("Nn", o[0]) && strchr("Oo", o[1])) { - negate ^= 1; - o += 2; - } - if (!(o && *o)) - continue; - - for (opt=optTable; opt->longName || opt->shortName || opt->arg; opt++) { - - if (opt->longName == NULL || strcasecmp(o, opt->longName)) - continue; - - int argInfo = opt->argInfo; - if (negate && (argInfo & POPT_ARGFLAG_TOGGLE)) { - argInfo &= ~POPT_ARGFLAG_TOGGLE; - if (argInfo == POPT_BIT_SET) - argInfo = POPT_BIT_CLR; - else if (argInfo == POPT_BIT_CLR) - argInfo = POPT_BIT_SET; - argInfo |= POPT_ARGFLAG_TOGGLE; - } - switch (argInfo & POPT_ARG_MASK) { - case POPT_ARG_VAL: - (void) poptSaveInt((int *)&optFlags, argInfo, (long)opt->val); - break; - default: - break; - } - o = NULL; /* XXX option processed. */ - break; - } - if (o) - fprintf(stderr, "*** unknown option \"%s\" was ignored\n", o); - } - av = argvFree(av); - return optFlags; -} -#endif /* DYING */ - -/*==============================================================*/ static int rpmmuList(const char *fn, FILE *ofp) { FILE * ifp = NULL; @@ -171,6 +77,69 @@ return rc; } +static int rpmmuGetFSTypes(ARGV_t *avp, const char *fnav[]) +{ + const char *fn = NULL; + FD_t fd = NULL; + ARGV_t av = NULL; + int ac = 0; + int rc = 0; + int xx; + + if (fnav) + while ((fn = *fnav++) != NULL) { +fprintf(stderr, "*** Fopen(%s)\n", fn); + fd = Fopen(fn, "rbm.fpio"); + if (fd && !Ferror(fd)) { + ARGV_t nav = NULL; + int nac; + xx = argvFgets(&nav, fd); + xx = Fclose(fd); + nac = argvCount(nav); + for (int i = 0; i < nac; i++) { + ARGV_t xav = NULL; + xx = argvSplit(&xav, nav[i], NULL); + if (xav[1]) { + const char * s = xav[0]; + xav[0] = xav[1]; + xav[1] = s; + } + nav[i] = _free(nav[i]); + nav[i] = argvJoin(xav, ':'); + xav = argvFree(xav); + } + xx = argvAppend(&av, nav); + nav = argvFree(nav); + } + int ac = argvCount(av); + if (!strcmp(av[ac-1], "*")) { + av[ac-1] = _free(av[ac-1]); + continue; + } + break; + } + + xx = argvSort(av, NULL); + ac = argvCount(av); + for (int i = 1, j = 0; i < ac; i++) { + if (!strcmp(av[i], av[j])) + av[i] = _free(av[i]); + else if (++j < i) { + av[j] = av[i]; + av[i] = NULL; + } + } + +argvPrint(__FUNCTION__, av, NULL); + + if (avp) + *avp = av; + else + av = argvFree(av); + + return rc; +} + /*==============================================================*/ #if !defined(POPT_BIT_XOR) @@ -448,12 +417,18 @@ }; poptContext con = rpmioInit(argc, argv, rpmmountOptionsTable); + int ec = 0; int rc; mu->av = (ARGV_t) poptGetArgs(con); mu->ac = argvCount(mu->av); + const char *fnav[] = { "/etc/filesystems", "/proc/filesystems", NULL }; + ARGV_t fstypes = NULL; + rc = rpmmuGetFSTypes(&fstypes, fnav); + fstypes = argvFree(fstypes); + mu->mflags = rpmioMountFlags; fprintf(stderr, "*** flags: 0x%lx\n", mu->mflags); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository [email protected]
