Changeset 3687


Ignore:
Timestamp:
Mar 15, 2011, 11:57:10 PM (14 years ago)
Author:
bird
Message:

libc: Reimplemented pathconf and fpathconf. References #44.

Location:
trunk/libc/src
Files:
4 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/kNIX/Makefile.kmk

    r3683 r3687  
    4949    $(PATH_LIBC_SRC)/kNIX/b_fsFileStat.c \
    5050    $(PATH_LIBC_SRC)/kNIX/b_fsFileStatFH.c \
     51    $(PATH_LIBC_SRC)/kNIX/b_fsInfoPathConf.c \
     52    $(PATH_LIBC_SRC)/kNIX/b_fsPathConf.c \
    5153    $(PATH_LIBC_SRC)/kNIX/b_fsSymlinkRead.c \
    5254    $(PATH_LIBC_SRC)/kNIX/b_fsSymlinkStat.c \
     
    6062    $(PATH_LIBC_SRC)/kNIX/b_ioFileSizeSet.c \
    6163    $(PATH_LIBC_SRC)/kNIX/b_ioFHToPath.c \
     64    $(PATH_LIBC_SRC)/kNIX/b_ioPathConf.c \
    6265    $(PATH_LIBC_SRC)/kNIX/b_ioRead.c \
    6366    $(PATH_LIBC_SRC)/kNIX/b_ioSeek.c \
  • trunk/libc/src/kNIX/kNIX.h

    r3683 r3687  
    238238__LIBC_PFSINFO __libc_back_fsInfoObjAddRef(__LIBC_PFSINFO pFsInfo);
    239239void __libc_back_fsInfoObjRelease(__LIBC_PFSINFO pFsInfo);
     240int __libc_back_fsInfoPathConf(__LIBC_PFSINFO pFsInfo, int iName, long *plValue);
    240241
    241242uint32_t __libc_back_djb2(const char *psz);
  • trunk/libc/src/kNIX/os2/fs-os2.c

    r3630 r3687  
    281281     * Setup the the executable path rewrite rule.
    282282     */
    283     PTIB pTib; 
     283    PTIB pTib;
    284284    PPIB pPib;
    285285    DosGetInfoBlocks(&pTib, &pPib);
    286286    APIRET rc = DosQueryModuleName(pPib->pib_hmte, sizeof(__libc_gszExecPath), &__libc_gszExecPath[0]);
    287     if (!rc) 
     287    if (!rc)
    288288    {
    289289        char *psz = strchr(&__libc_gszExecPath[0], '\0');
    290         while (     psz > &__libc_gszExecPath[0] 
     290        while (     psz > &__libc_gszExecPath[0]
    291291               &&   *psz != '\\'
    292292               &&   *psz != '/'
     
    309309    if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof(ulBootDrive)))
    310310        ulBootDrive = 'C' - 'A' - 1; /* A = 1 */
    311     __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0] 
     311    __libc_gszTmpDir[0] = __libc_gszSystemRoot[0] = __libc_gszSystemDrive[0]
    312312        = (char)ulBootDrive + 'A' - 1;
    313313
     
    463463{
    464464    static char achBuffer[384]; /* we're protected by the mutex, don't assume too much stack! */
    465     ULONG       cb = sizeof(achBuffer);
     465    ULONG       cb    = sizeof(achBuffer);
    466466    PFSQBUFFER2 pfsqb = (PFSQBUFFER2)achBuffer;
    467467
    468     /* init the structure */
    469     pFsInfo->fZeroNewBytes = 0;
    470     pFsInfo->fUnixEAs = 0;
    471     pFsInfo->Dev = Dev;
    472     pFsInfo->szName[0] = '\0';
    473     pFsInfo->szMountpoint[0] = minor(Dev);
    474     pFsInfo->szMountpoint[1] = ':';
    475     pFsInfo->szMountpoint[2] = '\0';
    476     pFsInfo->szMountpoint[3] = '\0';
     468    /* init the structure with defaults. */
     469    pFsInfo->fZeroNewBytes      = 0;
     470    pFsInfo->fUnixEAs           = 0;
     471    pFsInfo->fChOwnRestricted   = 1;
     472    pFsInfo->fNoNameTrunc       = 1;
     473    pFsInfo->cFileSizeBits      = 64;
     474    pFsInfo->cchMaxPath         = CCHMAXPATH;
     475    pFsInfo->cchMaxName         = CCHMAXPATHCOMP;
     476    pFsInfo->cchMaxSymlink      = CCHMAXPATH;
     477    pFsInfo->cMaxLinks          = 1;
     478    pFsInfo->cchMaxTermCanon    = MAX_CANON;
     479    pFsInfo->cchMaxTermInput    = MAX_INPUT;
     480    pFsInfo->cbPipeBuf          = _POSIX_PIPE_BUF;
     481    pFsInfo->cbBlock            = 512;
     482    pFsInfo->cbXferIncr         = 0x1000;
     483    pFsInfo->cbXferMax          = 0xf000;
     484    pFsInfo->cbXferMin          = 0x1000;
     485    pFsInfo->uXferAlign         = 0x1000;
     486    pFsInfo->Dev                = Dev;
     487    pFsInfo->szName[0]          = '\0';
     488    pFsInfo->szMountpoint[0]    = minor(Dev);
     489    pFsInfo->szMountpoint[1]    = ':';
     490    pFsInfo->szMountpoint[2]    = '\0';
     491    pFsInfo->szMountpoint[3]    = '\0';
    477492
    478493    /* query fs info */
     
    482497    if (!rc)
    483498        strncat(pFsInfo->szName, (const char *)&pfsqb->szName[pfsqb->cbName + 1], sizeof(pFsInfo->szName) - 1);
    484     if (    !strcmp(pFsInfo->szName, "JFS")
    485         ||  !strcmp(pFsInfo->szName, "HPFS")
    486         ||  !strcmp(pFsInfo->szName, "FAT"))
     499    if (!strcmp(pFsInfo->szName, "HPFS"))
    487500    {
    488501        pFsInfo->fZeroNewBytes  = 1;
    489502        pFsInfo->fUnixEAs       = 1;
     503        /** @todo detect HPFS386? */
     504    }
     505    else if (!strcmp(pFsInfo->szName, "JFS"))
     506    {
     507        pFsInfo->fZeroNewBytes  = 1;
     508        pFsInfo->fUnixEAs       = 1;
     509    }
     510    else if (!strcmp(pFsInfo->szName, "FAT"))
     511    {
     512        pFsInfo->fZeroNewBytes  = 1;
     513        pFsInfo->fUnixEAs       = 1;
     514        pFsInfo->cchMaxName     = 8+1+3;
    490515    }
    491516    else if (!strcmp(pFsInfo->szName, "LAN"))
     
    493518        /* should find a way of getting the remote fs... */
    494519        pFsInfo->fZeroNewBytes  = 1;    /* for performance reasons, assume it zeros. */
    495         pFsInfo->fUnixEAs       = 0;
     520        pFsInfo->cbXferMin      = 0x200;
     521        pFsInfo->cbXferIncr     = 0x200;
    496522    }
    497523    else if (!strcmp(pFsInfo->szName, "RAMFS"))
    498     {
    499524        pFsInfo->fZeroNewBytes  = 0;
    500         pFsInfo->fUnixEAs       = 1; /* but it doesn't zero */
    501     }
    502525    /*else if (!strcmp(pFsInfo->szName, "FAT32"))
    503     {
    504         pFsInfo->fZeroNewBytes  = 0;
    505         pFsInfo->fUnixEAs       = 0;
    506     }*/
    507     else
    508     {
    509         pFsInfo->fZeroNewBytes  = 0;
    510         pFsInfo->fUnixEAs       = 0;
    511     }
     526    { } */
    512527
    513528    LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d fUnixEAs=%d\n",
     
    699714 *
    700715 * @returns 0 on success.
    701  * @returns Negative error code (errno.h) on failiure.
     716 * @returns Negative error code (errno.h) on failure.
    702717 * @param   pszUserPath     The user path.
    703718 * @parm    fFlags          Flags controlling the operation of the function.
     
    728743 *
    729744 * @returns 0 on success.
    730  * @returns Negative error code (errno.h) on failiure.
     745 * @returns Negative error code (errno.h) on failure.
    731746 * @param   pszUserPath     The user path.
    732747 * @parm    fFlags          Flags controlling the operation of the function.
  • trunk/libc/src/libc/misc/Makefile.kmk

    r2935 r3687  
    6767    $(PATH_LIBC_SRC)/libc/misc/fnmatch.c \
    6868    $(PATH_LIBC_SRC)/libc/misc/fnslashi.c \
    69     $(PATH_LIBC_SRC)/libc/misc/fpathcon.c \
     69    $(PATH_LIBC_SRC)/libc/misc/fpathconf.c \
    7070    $(PATH_LIBC_SRC)/libc/misc/fstatfs.c \
    7171    $(PATH_LIBC_SRC)/libc/misc/fullpath.c \
  • trunk/libc/src/libc/misc/pathconf.c

    r151 r3687  
    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 }
Note: See TracChangeset for help on using the changeset viewer.