VirtualBox

Changeset 68147 in vbox


Ignore:
Timestamp:
Jul 27, 2017 8:58:09 PM (7 years ago)
Author:
vboxsync
Message:

iprt/isomaker: Added file & dir mode manipulation APIs and options.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/fsisomaker.h

    r67800 r68147  
    118118 */
    119119RTDECL(int) RTFsIsoMakerSetJolietRockRidgeLevel(RTFSISOMAKER hIsoMaker, uint8_t uLevel);
     120
     121/**
     122 * Sets the default file mode settings.
     123 *
     124 * @returns IRPT status code.
     125 * @param   hIsoMaker           The ISO maker handle.
     126 * @param   fMode               The default file mode.
     127 */
     128RTDECL(int) RTFsIsoMakerSetDefaultFileMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode);
     129
     130/**
     131 * Sets the default dir mode settings.
     132 *
     133 * @returns IRPT status code.
     134 * @param   hIsoMaker           The ISO maker handle.
     135 * @param   fMode               The default dir mode.
     136 */
     137RTDECL(int) RTFsIsoMakerSetDefaultDirMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode);
     138
     139/**
     140 * Sets the forced file mode, if @a fForce is true also the default mode is set.
     141 *
     142 * @returns IRPT status code.
     143 * @param   hIsoMaker           The ISO maker handle.
     144 * @param   fMode               The file mode.
     145 * @param   fForce              Indicate whether forced mode is active or not.
     146 */
     147RTDECL(int) RTFsIsoMakerSetForcedFileMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode, bool fForce);
     148
     149/**
     150 * Sets the forced dir mode, if @a fForce is true also the default mode is set.
     151 *
     152 * @returns IRPT status code.
     153 * @param   hIsoMaker           The ISO maker handle.
     154 * @param   fMode               The dir mode.
     155 * @param   fForce              Indicate whether forced mode is active or not.
     156 */
     157RTDECL(int) RTFsIsoMakerSetForcedDirMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode, bool fForce);
    120158
    121159/**
  • trunk/include/iprt/mangling.h

    r68121 r68147  
    933933# define RTFsIsoMakerSetRockRidgeLevel                  RT_MANGLER(RTFsIsoMakerSetRockRidgeLevel)
    934934# define RTFsIsoMakerSetJolietRockRidgeLevel            RT_MANGLER(RTFsIsoMakerSetJolietRockRidgeLevel)
     935# define RTFsIsoMakerSetDefaultDirMode                  RT_MANGLER(RTFsIsoMakerSetDefaultDirMode)
     936# define RTFsIsoMakerSetDefaultFileMode                 RT_MANGLER(RTFsIsoMakerSetDefaultFileMode)
     937# define RTFsIsoMakerSetForcedDirMode                   RT_MANGLER(RTFsIsoMakerSetForcedDirMode)
     938# define RTFsIsoMakerSetForcedFileMode                  RT_MANGLER(RTFsIsoMakerSetForcedFileMode)
    935939# define RTFsIsoMakerSetSysAreaContent                  RT_MANGLER(RTFsIsoMakerSetSysAreaContent)
    936940# define RTFsIsoMakerSetStringProp                      RT_MANGLER(RTFsIsoMakerSetStringProp)
  • trunk/src/VBox/Runtime/common/fs/isomaker.cpp

    r68025 r68147  
    507507    RTFMODE                 fDefaultDirMode;
    508508
     509    /** Forced file mode mask (permissions only). */
     510    RTFMODE                 fForcedFileMode;
     511    /** Set if fForcedFileMode is active. */
     512    bool                    fForcedFileModeActive;
     513    /** Set if fForcedDirMode is active. */
     514    bool                    fForcedDirModeActive;
     515    /** Forced directory mode mask (permissions only). */
     516    RTFMODE                 fForcedDirMode;
     517
    509518    /** Number of common source files. */
    510519    uint32_t                cCommonSources;
     
    818827        pThis->fDefaultDirMode              = 0555 | RTFS_TYPE_DIRECTORY | RTFS_DOS_DIRECTORY | RTFS_DOS_READONLY;
    819828
     829        //pThis->fForcedFileMode            = 0;
     830        //pThis->fForcedFileModeActive      = false;
     831        //pThis->fForcedDirModeActive       = false;
     832        //pThis->fForcedDirMode             = 0;
     833
    820834        //pThis->cCommonSources             = 0;
    821835        //pThis->paCommonSources            = NULL;
     
    12161230
    12171231    pThis->Joliet.uRockRidgeLevel = uLevel;
     1232    return VINF_SUCCESS;
     1233}
     1234
     1235
     1236/**
     1237 * Sets the default file mode settings.
     1238 *
     1239 * @returns IRPT status code.
     1240 * @param   hIsoMaker           The ISO maker handle.
     1241 * @param   fMode               The default file mode.
     1242 */
     1243RTDECL(int) RTFsIsoMakerSetDefaultFileMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode)
     1244{
     1245    PRTFSISOMAKERINT pThis = hIsoMaker;
     1246    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET(pThis);
     1247    Assert(!(fMode & ~RTFS_UNIX_ALL_PERMS));
     1248
     1249    pThis->fDefaultFileMode &= ~RTFS_UNIX_ALL_PERMS;
     1250    pThis->fDefaultFileMode |= fMode & RTFS_UNIX_ALL_PERMS;
     1251    return VINF_SUCCESS;
     1252}
     1253
     1254
     1255/**
     1256 * Sets the default dir mode settings.
     1257 *
     1258 * @returns IRPT status code.
     1259 * @param   hIsoMaker           The ISO maker handle.
     1260 * @param   fMode               The default dir mode.
     1261 */
     1262RTDECL(int) RTFsIsoMakerSetDefaultDirMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode)
     1263{
     1264    PRTFSISOMAKERINT pThis = hIsoMaker;
     1265    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET(pThis);
     1266    Assert(!(fMode & ~RTFS_UNIX_ALL_PERMS));
     1267
     1268    pThis->fDefaultDirMode &= ~RTFS_UNIX_ALL_PERMS;
     1269    pThis->fDefaultDirMode |= fMode & RTFS_UNIX_ALL_PERMS;
     1270    return VINF_SUCCESS;
     1271}
     1272
     1273
     1274/**
     1275 * Sets the forced file mode, if @a fForce is true also the default mode is set.
     1276 *
     1277 * @returns IRPT status code.
     1278 * @param   hIsoMaker           The ISO maker handle.
     1279 * @param   fMode               The file mode.
     1280 * @param   fForce              Indicate whether forced mode is active or not.
     1281 */
     1282RTDECL(int) RTFsIsoMakerSetForcedFileMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode, bool fForce)
     1283{
     1284    PRTFSISOMAKERINT pThis = hIsoMaker;
     1285    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET(pThis);
     1286    Assert(!(fMode & ~RTFS_UNIX_ALL_PERMS));
     1287
     1288    pThis->fForcedFileMode       = fMode & RTFS_UNIX_ALL_PERMS;
     1289    pThis->fForcedFileModeActive = fForce;
     1290    if (fForce)
     1291    {
     1292        pThis->fDefaultFileMode &= ~RTFS_UNIX_ALL_PERMS;
     1293        pThis->fDefaultFileMode |= fMode & RTFS_UNIX_ALL_PERMS;
     1294    }
     1295    return VINF_SUCCESS;
     1296}
     1297
     1298
     1299/**
     1300 * Sets the forced dir mode, if @a fForce is true also the default mode is set.
     1301 *
     1302 * @returns IRPT status code.
     1303 * @param   hIsoMaker           The ISO maker handle.
     1304 * @param   fMode               The dir mode.
     1305 * @param   fForce              Indicate whether forced mode is active or not.
     1306 */
     1307RTDECL(int) RTFsIsoMakerSetForcedDirMode(RTFSISOMAKER hIsoMaker, RTFMODE fMode, bool fForce)
     1308{
     1309    PRTFSISOMAKERINT pThis = hIsoMaker;
     1310    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET(pThis);
     1311    Assert(!(fMode & ~RTFS_UNIX_ALL_PERMS));
     1312
     1313    pThis->fForcedDirModeActive  = fForce;
     1314    pThis->fForcedDirMode        = fMode & RTFS_UNIX_ALL_PERMS;
     1315    if (fForce)
     1316    {
     1317        pThis->fDefaultDirMode  &= ~RTFS_UNIX_ALL_PERMS;
     1318        pThis->fDefaultDirMode  |= fMode & RTFS_UNIX_ALL_PERMS;
     1319    }
    12181320    return VINF_SUCCESS;
    12191321}
     
    28882990        pObj->AccessedTime      = pObjInfo->AccessTime;
    28892991        pObj->fMode             = pObjInfo->Attr.fMode;
     2992        if (enmType == RTFSISOMAKEROBJTYPE_DIR ? pThis->fForcedDirModeActive : pThis->fForcedFileModeActive)
     2993            pObj->fMode = (pObj->fMode & ~RTFS_UNIX_ALL_PERMS)
     2994                        | (enmType == RTFSISOMAKEROBJTYPE_DIR ? pThis->fForcedDirMode : pThis->fForcedFileMode);
    28902995        pObj->uid               = pObjInfo->Attr.u.Unix.uid != NIL_RTUID ? pObjInfo->Attr.u.Unix.uid : pThis->uidDefault;
    28912996        pObj->gid               = pObjInfo->Attr.u.Unix.gid != NIL_RTGID ? pObjInfo->Attr.u.Unix.gid : pThis->gidDefault;
  • trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp

    r67871 r68147  
    113113    RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_144,
    114114    RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_288,
     115
     116    RTFSISOMAKERCMD_OPT_NO_FILE_MODE,
     117    RTFSISOMAKERCMD_OPT_NO_DIR_MODE,
    115118
    116119    /*
     
    350353     */
    351354    uint32_t            afNameSpecifiers[RTFSISOMAKERCMD_MAX_NAMES];
     355    /** The forced directory mode. */
     356    RTFMODE             fDirMode;
     357    /** Set if fDirMode should be applied.   */
     358    bool                fDirModeActive;
     359    /** Set if fFileMode should be applied.   */
     360    bool                fFileModeActive;
     361    /** The force file mode. */
     362    RTFMODE             fFileMode;
    352363    /** @} */
    353364
     
    456467    { "--eltorito-floppy-144",          RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_144,            RTGETOPT_REQ_NOTHING },
    457468    { "--eltorito-floppy-288",          RTFSISOMAKERCMD_OPT_ELTORITO_FLOPPY_288,            RTGETOPT_REQ_NOTHING },
     469
     470    { "--no-file-mode",                 RTFSISOMAKERCMD_OPT_NO_FILE_MODE,                   RTGETOPT_REQ_NOTHING },
     471    { "--no-dir-mode",                  RTFSISOMAKERCMD_OPT_NO_DIR_MODE,                    RTGETOPT_REQ_NOTHING },
    458472
    459473#define DD(a_szLong, a_chShort, a_fFlags) { a_szLong, a_chShort, a_fFlags  }, { "-" a_szLong, a_chShort, a_fFlags  }
     
    485499    { "--volume-id",                    RTFSISOMAKERCMD_OPT_VOLUME_ID,                      RTGETOPT_REQ_STRING  }, /* should've been '-V' */
    486500    DD("-volset",                       RTFSISOMAKERCMD_OPT_VOLUME_SET_ID,                  RTGETOPT_REQ_STRING  ),
     501
     502    /* Other: */
     503    DD("-file-mode",                    RTFSISOMAKERCMD_OPT_FILE_MODE,                      RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
     504    DD("-dir-mode",                     RTFSISOMAKERCMD_OPT_DIR_MODE,                       RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
     505    DD("-new-dir-mode",                 RTFSISOMAKERCMD_OPT_NEW_DIR_MODE,                   RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
    487506
    488507    /*
     
    510529    { "--dont-append-dot",              'd',                                                RTGETOPT_REQ_NOTHING },
    511530    { "--deep-directories",             'D',                                                RTGETOPT_REQ_NOTHING },
    512     DD("-dir-mode",                     RTFSISOMAKERCMD_OPT_DIR_MODE,                       RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
    513531    DD("-dvd-video",                    RTFSISOMAKERCMD_OPT_DVD_VIDEO,                      RTGETOPT_REQ_NOTHING ),
    514532    DD("-follow-symlinks",              'f',                                                RTGETOPT_REQ_NOTHING ),
    515     DD("-file-mode",                    RTFSISOMAKERCMD_OPT_FILE_MODE,                      RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
    516533    DD("-gid",                          RTFSISOMAKERCMD_OPT_GID,                            RTGETOPT_REQ_UINT32  ),
    517534    DD("-gui",                          RTFSISOMAKERCMD_OPT_GUI,                            RTGETOPT_REQ_NOTHING ),
     
    549566    DD("-dev",                          'M',                                                RTGETOPT_REQ_STRING  ),
    550567    { "--omit-version-numbers",         'N',                                                RTGETOPT_REQ_NOTHING },
    551     DD("-new-dir-mode",                 RTFSISOMAKERCMD_OPT_NEW_DIR_MODE,                   RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_OCT ),
    552568    DD("-nobak",                        RTFSISOMAKERCMD_OPT_NO_BACKUP_FILES,                RTGETOPT_REQ_NOTHING ),
    553569    DD("-no-bak",                       RTFSISOMAKERCMD_OPT_NO_BACKUP_FILES,                RTGETOPT_REQ_NOTHING ),
     
    25992615
    26002616/**
     2617 * Handles the --dir-mode and --file-mode options.
     2618 *
     2619 * @returns IPRT status code.
     2620 * @param   pOpts               The ISO maker command instance.
     2621 * @param   fDir                True if applies to dir, false if applies to
     2622 *                              files.
     2623 * @param   fMode               The forced mode.
     2624 */
     2625static int rtFsIsoMakerCmdOptSetFileOrDirMode(PRTFSISOMAKERCMDOPTS pOpts, bool fDir, RTFMODE fMode)
     2626{
     2627    /* Change the mode masks. */
     2628    int rc;
     2629    if (fDir)
     2630        rc = RTFsIsoMakerSetForcedDirMode(pOpts->hIsoMaker, fMode, true /*fForced*/);
     2631    else
     2632        rc = RTFsIsoMakerSetForcedFileMode(pOpts->hIsoMaker, fMode, true /*fForced*/);
     2633    if (RT_SUCCESS(rc))
     2634    {
     2635        /* Then enable rock.*/
     2636        rc = RTFsIsoMakerSetRockRidgeLevel(pOpts->hIsoMaker, 2);
     2637        if (RT_SUCCESS(rc))
     2638            return VINF_SUCCESS;
     2639        return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to enable rock ridge: %Rrc", rc);
     2640    }
     2641    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set %s force & default mode mask to %04o: %Rrc",
     2642                                  fMode, fDir ? "directory" : "file", rc);
     2643}
     2644
     2645
     2646/**
     2647 * Handles the --no-dir-mode and --no-file-mode options that counters
     2648 * --dir-mode and --file-mode.
     2649 *
     2650 * @returns IPRT status code.
     2651 * @param   pOpts               The ISO maker command instance.
     2652 * @param   fDir                True if applies to dir, false if applies to
     2653 *                              files.
     2654 */
     2655static int rtFsIsoMakerCmdOptDisableFileOrDirMode(PRTFSISOMAKERCMDOPTS pOpts, bool fDir)
     2656{
     2657    int rc;
     2658    if (fDir)
     2659        rc = RTFsIsoMakerSetForcedDirMode(pOpts->hIsoMaker, 0, false /*fForced*/);
     2660    else
     2661        rc = RTFsIsoMakerSetForcedFileMode(pOpts->hIsoMaker, 0, true /*fForced*/);
     2662    if (RT_SUCCESS(rc))
     2663        return VINF_SUCCESS;
     2664    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to disable forced %s mode mask: %Rrc", fDir ? "directory" : "file", rc);
     2665}
     2666
     2667
     2668
     2669/**
     2670 * Handles the --new-dir-mode option.
     2671 *
     2672 * @returns IPRT status code.
     2673 * @param   pOpts               The ISO maker command instance.
     2674 * @param   fMode               The forced mode.
     2675 */
     2676static int rtFsIsoMakerCmdOptSetNewDirMode(PRTFSISOMAKERCMDOPTS pOpts, RTFMODE fMode)
     2677{
     2678    int rc = RTFsIsoMakerSetDefaultDirMode(pOpts->hIsoMaker, fMode);
     2679    if (RT_SUCCESS(rc))
     2680        return VINF_SUCCESS;
     2681    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set default dir mode mask to %04o: %Rrc", fMode, rc);
     2682}
     2683
     2684
     2685/**
    26012686 * Loads an argument file (e.g. a .iso-file) and parses it.
    26022687 *
     
    27672852                break;
    27682853
     2854            case RTFSISOMAKERCMD_OPT_NO_FILE_MODE:
     2855                rc = rtFsIsoMakerCmdOptDisableFileOrDirMode(pOpts, false /*fDir*/);
     2856                break;
     2857            case RTFSISOMAKERCMD_OPT_NO_DIR_MODE:
     2858                rc = rtFsIsoMakerCmdOptDisableFileOrDirMode(pOpts, true /*fDir*/);
     2859                break;
     2860
     2861
    27692862            /*
    27702863             * Joliet related options.
     
    28852978                pOpts->pszOutFile = ValueUnion.psz;
    28862979                break;
     2980
     2981            case RTFSISOMAKERCMD_OPT_DIR_MODE:
     2982                rc = rtFsIsoMakerCmdOptSetFileOrDirMode(pOpts, true /*fDir*/, ValueUnion.u32);
     2983                break;
     2984
     2985            case RTFSISOMAKERCMD_OPT_FILE_MODE:
     2986                rc = rtFsIsoMakerCmdOptSetFileOrDirMode(pOpts, false /*fDir*/, ValueUnion.u32);
     2987                break;
     2988
     2989            case RTFSISOMAKERCMD_OPT_NEW_DIR_MODE:
     2990                rc = rtFsIsoMakerCmdOptSetNewDirMode(pOpts, ValueUnion.u32);
     2991                break;
     2992
    28872993
    28882994            /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette