Changeset 3695 for branches


Ignore:
Timestamp:
Mar 16, 2011, 12:30:51 AM (14 years ago)
Author:
bird
Message:

0.6: Backported fpathconf and pathconf reimplementation. Fixes #44.

Location:
branches/libc-0.6/src/emx
Files:
1 deleted
6 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h

    r3102 r3695  
    157157 */
    158158void __libc_Back_fsSync(void);
     159
     160/**
     161 * Query filesystem configuration information by path.
     162 *
     163 * @returns 0 on success.
     164 * @returns Negative error code (errno.h) on failure.
     165 * @param   pszPath     Path to query info about.
     166 * @param   iName       Which path config variable to query.
     167 * @param   plValue     Where to return the value.
     168 * @sa      __libc_Back_ioPathConf, fpathconf, pathconf, sysconf.
     169 */
     170int __libc_Back_fsPathConf(const char *pszPath, int iName, long *plValue);
    159171
    160172/**
     
    507519 */
    508520int __libc_Back_ioFHToPath(int fh, char *pszPath, size_t cchPath);
     521
     522/**
     523 * Query filesystem configuration information by file handle.
     524 *
     525 * @returns 0 on success.
     526 * @returns Negative error code (errno.h) on failure.
     527 * @param   fh          The handle to query config info about.
     528 * @param   iName       Which path config variable to query.
     529 * @param   plValue     Where to return the configuration value.
     530 * @sa      __libc_Back_fsPathConf, fpathconf, pathconf, sysconf.
     531 */
     532int __libc_Back_ioPathConf(int fh, int iName, long *plValue);
    509533
    510534/** @} */
  • branches/libc-0.6/src/emx/include/emx/io.h

    r2522 r3695  
    322322    /** Does the file system provide sufficient EA support for UNIX attributes? */
    323323    unsigned            fUnixEAs : 1;
     324    /** _PC_CHOWN_RESTRICTED - Is chown and chgrp restricted the typical unix way. */
     325    unsigned            fChOwnRestricted : 1;
     326    /** _PC_NO_TRUNC - Indicates whether too long names will cause errors or be truncated. */
     327    unsigned            fNoNameTrunc : 1;
     328    /** _PC_FILESIZEBITS - The bitsize of the type required to store the max file size. */
     329    unsigned            cFileSizeBits : 7;
     330    /** _PC_PATH_MAX - The maximum path length. */
     331    unsigned short      cchMaxPath;
     332    /** _PC_NAME_MAX - The maximum path length. */
     333    unsigned short      cchMaxName;
     334    /** _PC_SYMLINK_MAX - The maximum symlink length. */
     335    unsigned short      cchMaxSymlink;
     336    /** _PC_LINK_MAX - The maximum number of hard links per file. */
     337    unsigned short      cMaxLinks;
     338    /** _PC_MAX_CANON - The maximum number of bytes in a terminal canonical input queue. */
     339    unsigned short      cchMaxTermCanon;
     340    /** _PC_MAX_INPUT - The maximum number of bytes in a canonical input queue. */
     341    unsigned short      cchMaxTermInput;
     342    /** _PC_PIPE_BUF  - The maximum number of bytes that is guaranteed to be atomic when writing to a pipe. */
     343    unsigned            cbPipeBuf;
     344    /** _PC_ALLOC_SIZE_MIN - The (smallest) block allocation size of the file system.  */
     345    unsigned            cbBlock;
     346    /** _PC_REC_XFER_ALIGN - The recommended buffer alignment for transfers. */
     347    unsigned short      uXferAlign;
     348    /** _PC_REC_INCR_XFER_SIZE - The increments to walk between the min and max transfer sizes. */
     349    unsigned short      cbXferIncr;
     350    /** _PC_REC_MAX_XFER_SIZE  - The maximum recommended transfer size. */
     351    unsigned long       cbXferMax;
     352    /** _PC_REC_MIN_XFER_SIZE  - The minimum recommended transfer size. */
     353    unsigned long       cbXferMin;
    324354    /** Device number of the device the filesystem resides on.
    325355     * On OS/2 the device number is derived from the driveletter. */
  • branches/libc-0.6/src/emx/src/lib/libc.def

    r3102 r3695  
    19611961
    19621962
     1963    "___libc_Back_fsPathConf" @1959
     1964    "___libc_Back_ioPathConf" @1960
  • branches/libc-0.6/src/emx/src/lib/misc/pathconf.c

    r151 r3695  
    1 /* pathconf.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * LIBC - pathconf().
     5 *
     6 * Copyright (c) 2011 knut st. osmundsen <bird@innotek.de>
     7 *
     8 *
     9 * This file is part of InnoTek LIBC.
     10 *
     11 * InnoTek LIBC is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published
     13 * by the Free Software Foundation; either version 2 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with InnoTek LIBC; if not, write to the Free Software
     23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     24 *
     25 */
    226
     27
     28/*******************************************************************************
     29*   Header Files                                                               *
     30*******************************************************************************/
    331#include "libc-alias.h"
     32#include <errno.h>
    433#include <unistd.h>
    5 #include <limits.h>
    6 #include <errno.h>
     34#include <InnoTekLIBC/backend.h>
     35#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
     36#include <InnoTekLIBC/logstrict.h>
    737
    8 /* Return the POSIX.1  minimum values, for now. */
    938
    10 long _STD(pathconf) (const char *path, int name)
     39long _STD(pathconf)(const char *pszPath, int iName)
    1140{
    12   switch (name)
    13     {
    14     case _PC_LINK_MAX:
    15       return _POSIX_LINK_MAX;
     41    LIBCLOG_ENTER("pszPath=%p:{%s} iName=%d\n", pszPath, pszPath, iName);
     42    long lValue;
     43    int rc = __libc_Back_fsPathConf(pszPath, iName, &lValue);
     44    if (!rc)
     45        LIBCLOG_RETURN_LONG(lValue);
     46    errno = -rc;
     47    LIBCLOG_ERROR_RETURN_LONG(-1L);
     48}
    1649
    17     case _PC_MAX_CANON:
    18       return _POSIX_MAX_CANON;
    19 
    20     case _PC_MAX_INPUT:
    21       return _POSIX_MAX_INPUT;
    22 
    23     case _PC_NAME_MAX:
    24       return _POSIX_NAME_MAX;
    25 
    26     case _PC_PATH_MAX:
    27       return _POSIX_PATH_MAX;
    28 
    29     case _PC_PIPE_BUF:
    30       return _POSIX_PIPE_BUF;
    31 
    32     case _PC_CHOWN_RESTRICTED:
    33       return 1;
    34 
    35     case _PC_NO_TRUNC:
    36       return 1;                 /* TODO */
    37 
    38     case _PC_VDISABLE:
    39       return 0;
    40 
    41     default:
    42       errno = EINVAL;
    43       return -1;
    44     }
    45 }
  • branches/libc-0.6/src/emx/src/lib/sys/b_fs.h

    r2538 r3695  
    466466int __libc_back_fsInfoSupportUnixEAs(const char *pszNativePath);
    467467
     468int __libc_back_fsInfoPathConf(__LIBC_PFSINFO pFsInfo, int iName, long *plValue);
     469
    468470__END_DECLS
    469471
  • branches/libc-0.6/src/emx/src/lib/sys/b_fsInfoPathConf.c

    r3687 r3695  
    2525 */
    2626
    27 #include "kNIX.h"
    28 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
    29 #include <klibc/logstrict.h>
    3027#include <unistd.h>
    3128#include <limits.h>
     29#include <errno.h>
     30#include "syscalls.h"
     31#include "b_fs.h"
     32#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
     33#include <InnoTekLIBC/logstrict.h>
    3234
    3335/**
     
    117119}
    118120
     121
  • branches/libc-0.6/src/emx/src/lib/sys/b_fsPathConf.c

    r3687 r3695  
    2525 */
    2626
    27 #include "kNIX.h"
     27#include "syscalls.h"
     28#include "b_fs.h"
     29#include <InnoTekLIBC/backend.h>
    2830#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
    29 #include <klibc/logstrict.h>
     31#include <InnoTekLIBC/logstrict.h>
    3032
    3133/**
     
    5254    if (!rc)
    5355    {
    54         __LIBC_PFSINFO *pFsInfo = __libc_back_fsInfoObjByPath(pszNativePath);
    55         rc = __libc_back_fsinfoPathConf(pFsInfo, iName, plValue);
     56        __LIBC_PFSINFO pFsInfo = __libc_back_fsInfoObjByPath(szNativePath);
     57        rc = __libc_back_fsInfoPathConf(pFsInfo, iName, plValue);
    5658        __libc_back_fsInfoObjRelease(pFsInfo);
    5759    }
  • branches/libc-0.6/src/emx/src/lib/sys/b_ioPathConf.c

    r3687 r3695  
    2525 */
    2626
    27 #include "kNIX.h"
     27#include "syscalls.h"
     28#include <InnoTekLIBC/backend.h>
    2829#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
    29 #include <klibc/logstrict.h>
     30#include <InnoTekLIBC/logstrict.h>
     31#include "b_fs.h"
    3032
    3133/**
     
    4850     */
    4951    __LIBC_PFH pFH;
    50     int rc = __libc_FHGet(fh, &pFH);
     52    int rc = __libc_FHEx(fh, &pFH);
    5153    if (rc == 0)
    52     {
    5354        rc = __libc_back_fsInfoPathConf(pFH->pFsInfo, iName, plValue);
    54         __libc_FHPut(pFH);
    55     }
    5655    LIBCLOG_MIX_RETURN_INT(rc);
    5756}
  • branches/libc-0.6/src/emx/src/lib/sys/fs.c

    r3289 r3695  
    337337     * Setup the the executable path rewrite rule.
    338338     */
    339     PTIB pTib; 
     339    PTIB pTib;
    340340    PPIB pPib;
    341341    DosGetInfoBlocks(&pTib, &pPib);
    342342    rc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]);
    343     if (!rc) 
     343    if (!rc)
    344344    {
    345345        char *psz = strchr(&__libc_gszExecPath[0], '\0');
    346         while (     psz > &__libc_gszExecPath[0] 
     346        while (     psz > &__libc_gszExecPath[0]
    347347               &&   *psz != '\\'
    348348               &&   *psz != '/'
     
    365365    if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof(ulBootDrive)))
    366366        ulBootDrive = 'C' - 'A' - 1; /* A = 1 */
    367     __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0] 
     367    __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0]
    368368        = (char)ulBootDrive + 'A' - 1;
    369369
     
    18001800    PFSQBUFFER2 pfsqb = (PFSQBUFFER2)achBuffer;
    18011801
    1802     /* init the structure */
    1803     pFsInfo->fZeroNewBytes = 0;
    1804     pFsInfo->fUnixEAs = 0;
    1805     pFsInfo->Dev = Dev;
    1806     pFsInfo->szName[0] = '\0';
    1807     pFsInfo->szMountpoint[0] = minor(Dev);
    1808     pFsInfo->szMountpoint[1] = ':';
    1809     pFsInfo->szMountpoint[2] = '\0';
    1810     pFsInfo->szMountpoint[3] = '\0';
     1802    /* init the structure with defaults. */
     1803    pFsInfo->fZeroNewBytes      = 0;
     1804    pFsInfo->fUnixEAs           = 0;
     1805    pFsInfo->fChOwnRestricted   = 1;
     1806    pFsInfo->fNoNameTrunc       = 1;
     1807    pFsInfo->cFileSizeBits      = 64;
     1808    pFsInfo->cchMaxPath         = CCHMAXPATH;
     1809    pFsInfo->cchMaxName         = CCHMAXPATHCOMP;
     1810    pFsInfo->cchMaxSymlink      = CCHMAXPATH;
     1811    pFsInfo->cMaxLinks          = 1;
     1812    pFsInfo->cchMaxTermCanon    = MAX_CANON;
     1813    pFsInfo->cchMaxTermInput    = MAX_INPUT;
     1814    pFsInfo->cbPipeBuf          = _POSIX_PIPE_BUF;
     1815    pFsInfo->cbBlock            = 512;
     1816    pFsInfo->cbXferIncr         = 0x1000;
     1817    pFsInfo->cbXferMax          = 0xf000;
     1818    pFsInfo->cbXferMin          = 0x1000;
     1819    pFsInfo->uXferAlign         = 0x1000;
     1820    pFsInfo->Dev                = Dev;
     1821    pFsInfo->szName[0]          = '\0';
     1822    pFsInfo->szMountpoint[0]    = minor(Dev);
     1823    pFsInfo->szMountpoint[1]    = ':';
     1824    pFsInfo->szMountpoint[2]    = '\0';
     1825    pFsInfo->szMountpoint[3]    = '\0';
    18111826
    18121827    /* query fs info */
     
    18161831    if (!rc)
    18171832        strncat(pFsInfo->szName, (const char *)&pfsqb->szName[pfsqb->cbName + 1], sizeof(pFsInfo->szName) - 1);
    1818     if (    !strcmp(pFsInfo->szName, "JFS")
    1819         ||  !strcmp(pFsInfo->szName, "HPFS")
    1820         ||  !strcmp(pFsInfo->szName, "FAT"))
     1833    if (!strcmp(pFsInfo->szName, "HPFS"))
    18211834    {
    18221835        pFsInfo->fZeroNewBytes  = 1;
    18231836        pFsInfo->fUnixEAs       = 1;
     1837        /** @todo detect HPFS386? */
     1838    }
     1839    else if (!strcmp(pFsInfo->szName, "JFS"))
     1840    {
     1841        pFsInfo->fZeroNewBytes  = 1;
     1842        pFsInfo->fUnixEAs       = 1;
     1843    }
     1844    else if (!strcmp(pFsInfo->szName, "FAT"))
     1845    {
     1846        pFsInfo->fZeroNewBytes  = 1;
     1847        pFsInfo->fUnixEAs       = 1;
     1848        pFsInfo->cchMaxName     = 8+1+3;
    18241849    }
    18251850    else if (!strcmp(pFsInfo->szName, "LAN"))
     
    18271852        /* should find a way of getting the remote fs... */
    18281853        pFsInfo->fZeroNewBytes  = 1;    /* for performance reasons, assume it zeros. */
    1829         pFsInfo->fUnixEAs       = 0;
     1854        pFsInfo->cbXferMin      = 0x200;
     1855        pFsInfo->cbXferIncr     = 0x200;
    18301856    }
    18311857    else if (!strcmp(pFsInfo->szName, "RAMFS"))
    1832     {
    18331858        pFsInfo->fZeroNewBytes  = 0;
    1834         pFsInfo->fUnixEAs       = 1; /* but it doesn't zero */
    1835     }
    18361859    /*else if (!strcmp(pFsInfo->szName, "FAT32"))
    1837     {
    1838         pFsInfo->fZeroNewBytes  = 0;
    1839         pFsInfo->fUnixEAs       = 0;
    1840     }*/
    1841     else
    1842     {
    1843         pFsInfo->fZeroNewBytes  = 0;
    1844         pFsInfo->fUnixEAs       = 0;
    1845     }
     1860    { } */
    18461861
    18471862    LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d fUnixEAs=%d\n",
Note: See TracChangeset for help on using the changeset viewer.