/* $Id$ */
/** @file
* IPRT - File System.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/**
* Converts dos-style attributes to Unix attributes.
*
* @returns
* @param fMode The mode mask containing dos-style attributes only.
* @param pszName The filename which this applies to (exe check).
* @param cbName The length of that filename. (optional, set 0)
*/
{
/* everything is readable. */
if (fMode & RTFS_DOS_DIRECTORY)
/* directories are executable. */
else
{
fMode |= RTFS_TYPE_FILE;
{
/* check for executable extension. */
)
}
}
/* Is it really a symbolic link? */
if (fMode & RTFS_DOS_NT_REPARSE_POINT)
/* writable? */
if (!(fMode & RTFS_DOS_READONLY))
return fMode;
}
/**
* Converts Unix attributes to Dos-style attributes.
*
* @returns File mode mask.
* @param fMode The mode mask containing dos-style attributes only.
* @param pszName The filename which this applies to (hidden check).
* @param cbName The length of that filename. (optional, set 0)
*/
{
fMode &= RTFS_UNIX_MASK;
if (RTFS_IS_DIRECTORY(fMode))
if (!(fMode & RTFS_DOS_MASK))
{
fMode |= RTFS_DOS_HIDDEN;
}
return fMode;
}
/**
* Normalizes the give mode mask.
*
* It will create the missing unix or dos mask from the other (one
* of them is required by all APIs), and guess the file type if that's
* missing.
*
* @returns Normalized file mode.
* @param fMode The mode mask that may contain a partial/incomplete mask.
* @param pszName The filename which this applies to (exe check).
* @param cbName The length of that filename. (optional, set 0)
*/
{
if (!(fMode & RTFS_UNIX_MASK))
else if (!(fMode & RTFS_DOS_MASK))
else if (!(fMode & RTFS_TYPE_MASK))
else if (RTFS_IS_DIRECTORY(fMode))
return fMode;
}
/**
* Checks if the file mode is valid or not.
*
* @return true if valid.
* @return false if invalid, done bitching.
* @param fMode The file mode.
*/
{
("%RTfmode\n", fMode), false);
("%RTfmode\n", fMode), false);
/** @todo more checks! */
return true;
}
/**
* Checks if the file mode is valid as a permission mask or not.
*
* @return true if valid.
* @return false if invalid, done bitching.
* @param fMode The file mode.
*/
{
("%RTfmode\n", fMode), false);
/** @todo more checks! */
return true;
}
{
switch (enmType)
{
case RTFSTYPE_UNKNOWN: return "unknown";
case RTFSTYPE_UDF: return "udf";
case RTFSTYPE_ISO9660: return "iso9660";
case RTFSTYPE_FUSE: return "fuse";
case RTFSTYPE_VBOXSHF: return "vboxshf";
case RTFSTYPE_EXT: return "ext";
case RTFSTYPE_EXT2: return "ext2";
case RTFSTYPE_EXT3: return "ext3";
case RTFSTYPE_EXT4: return "ext4";
case RTFSTYPE_XFS: return "xfs";
case RTFSTYPE_CIFS: return "cifs";
case RTFSTYPE_SMBFS: return "smbfs";
case RTFSTYPE_TMPFS: return "tmpfs";
case RTFSTYPE_SYSFS: return "sysfs";
case RTFSTYPE_PROC: return "proc";
case RTFSTYPE_OCFS2: return "ocfs2";
case RTFSTYPE_BTRFS: return "btrfs";
case RTFSTYPE_NTFS: return "ntfs";
case RTFSTYPE_FAT: return "fat";
case RTFSTYPE_ZFS: return "zfs";
case RTFSTYPE_UFS: return "ufs";
case RTFSTYPE_NFS: return "nfs";
case RTFSTYPE_HFS: return "hfs";
case RTFSTYPE_AUTOFS: return "autofs";
case RTFSTYPE_DEVFS: return "devfs";
case RTFSTYPE_HPFS: return "hpfs";
case RTFSTYPE_JFS: return "jfs";
case RTFSTYPE_END: return "end";
case RTFSTYPE_32BIT_HACK: break;
}
/* Don't put this in as 'default:', we wish GCC to warn about missing cases. */
return s_asz[i];
}