mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added pathconf() and fpathconf() as contributed by Peter Bengtsson. Thank you very much!
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15108 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# $Id: GNUmakefile.68k,v 1.88 2006-07-28 14:02:30 obarthel Exp $
|
# $Id: GNUmakefile.68k,v 1.89 2006-07-28 14:37:27 obarthel Exp $
|
||||||
#
|
#
|
||||||
# :ts=8
|
# :ts=8
|
||||||
#
|
#
|
||||||
@@ -526,10 +526,13 @@ UNIX_LIB = \
|
|||||||
unistd_chdir.o \
|
unistd_chdir.o \
|
||||||
unistd_chdir_exit.o \
|
unistd_chdir_exit.o \
|
||||||
unistd_chown.o \
|
unistd_chown.o \
|
||||||
|
unistd_common_pathconf.o \
|
||||||
|
unistd_fpathconf.o \
|
||||||
unistd_getcwd.o \
|
unistd_getcwd.o \
|
||||||
unistd_lchown.o \
|
unistd_lchown.o \
|
||||||
unistd_link.o \
|
unistd_link.o \
|
||||||
unistd_lockf.o \
|
unistd_lockf.o \
|
||||||
|
unistd_pathconf.o \
|
||||||
unistd_readlink.o \
|
unistd_readlink.o \
|
||||||
unistd_realpath.o \
|
unistd_realpath.o \
|
||||||
unistd_restorepathname.o \
|
unistd_restorepathname.o \
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# $Id: GNUmakefile.os4,v 1.101 2006-07-28 14:02:31 obarthel Exp $
|
# $Id: GNUmakefile.os4,v 1.102 2006-07-28 14:37:27 obarthel Exp $
|
||||||
#
|
#
|
||||||
# :ts=8
|
# :ts=8
|
||||||
#
|
#
|
||||||
@@ -569,10 +569,13 @@ UNIX_LIB = \
|
|||||||
unistd_chdir.o \
|
unistd_chdir.o \
|
||||||
unistd_chdir_exit.o \
|
unistd_chdir_exit.o \
|
||||||
unistd_chown.o \
|
unistd_chown.o \
|
||||||
|
unistd_common_pathconf.o \
|
||||||
|
unistd_fpathconf.o \
|
||||||
unistd_getcwd.o \
|
unistd_getcwd.o \
|
||||||
unistd_lchown.o \
|
unistd_lchown.o \
|
||||||
unistd_link.o \
|
unistd_link.o \
|
||||||
unistd_lockf.o \
|
unistd_lockf.o \
|
||||||
|
unistd_pathconf.o \
|
||||||
unistd_readlink.o \
|
unistd_readlink.o \
|
||||||
unistd_realpath.o \
|
unistd_realpath.o \
|
||||||
unistd_restorepathname.o \
|
unistd_restorepathname.o \
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- Added sysinfo(), ftime(), ulimit(), getrlimit() and setrlimit() as contributed by
|
- Added pathconf(), fpathconf(), sysinfo(), ftime(), ulimit(), getrlimit()
|
||||||
Peter Bengtsson. Thank you very much!
|
and setrlimit() as contributed by Peter Bengtsson. Thank you very much!
|
||||||
|
|
||||||
- Added the missing S_ISSOCKET() macro to <sys/stat.h>. Note that this
|
- Added the missing S_ISSOCKET() macro to <sys/stat.h>. Note that this
|
||||||
is not actually a POSIX feature.
|
is not actually a POSIX feature.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: unistd.h,v 1.18 2006-01-29 09:17:00 obarthel Exp $
|
* $Id: unistd.h,v 1.19 2006-07-28 14:37:28 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -167,6 +167,42 @@ extern int setuid(uid_t uid);
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is for use with pathconf()/fpathconf() */
|
||||||
|
#define _PC_LINK_MAX 0
|
||||||
|
#define _PC_MAX_CANON 1
|
||||||
|
#define _PC_MAX_INPUT 2
|
||||||
|
#define _PC_NAME_MAX 3
|
||||||
|
#define _PC_PATH_MAX 4
|
||||||
|
#define _PC_PIPE_BUF 5
|
||||||
|
#define _PC_CHOWN_RESTRICTED 6
|
||||||
|
#define _PC_NO_TRUNC 7
|
||||||
|
#define _PC_VDISABLE 8
|
||||||
|
#define _PC_SYNC_IO 9
|
||||||
|
#define _PC_ASYNC_IO 10
|
||||||
|
#define _PC_PRIO_IO 11
|
||||||
|
#define _PC_SOCK_MAXBUF 12
|
||||||
|
#define _PC_FILESIZEBITS 13
|
||||||
|
#if 0
|
||||||
|
#define _PC_REC_INCR_XFER_SIZE 14
|
||||||
|
#define _PC_REC_MAX_XFER_SIZE 15
|
||||||
|
#define _PC_REC_MIN_XFER_SIZE 16
|
||||||
|
#define _PC_REC_XFER_ALIGN 17
|
||||||
|
#define _PC_ALLOC_SIZE_MIN 18
|
||||||
|
#endif
|
||||||
|
#define _PC_SYMLINK_MAX 19
|
||||||
|
#define _PC_XATTR_EXISTS 20
|
||||||
|
#define _PC_XATTR_ENABLED 21
|
||||||
|
|
||||||
|
/* Amiga Specific */
|
||||||
|
#define _PC_DOSTYPE 300
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
extern long pathconf(const char *path,int name);
|
||||||
|
extern long fpathconf(int file_descriptor,int name);
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: resource_getrlimit.c,v 1.1 2006-07-28 13:36:16 obarthel Exp $
|
* $Id: resource_getrlimit.c,v 1.2 2006-07-28 14:37:27 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -41,6 +41,10 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
getrlimit(int resource,struct rlimit *rlp)
|
getrlimit(int resource,struct rlimit *rlp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: resource_setrlimit.c,v 1.1 2006-07-28 13:36:16 obarthel Exp $
|
* $Id: resource_setrlimit.c,v 1.2 2006-07-28 14:37:27 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -41,6 +41,10 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
setrlimit(int resource,const struct rlimit *rlp)
|
setrlimit(int resource,const struct rlimit *rlp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: systeminfo_sysinfo.c,v 1.1 2006-07-28 14:02:31 obarthel Exp $
|
* $Id: systeminfo_sysinfo.c,v 1.2 2006-07-28 14:37:27 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -36,6 +36,10 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
#if defined(SOCKET_SUPPORT) && !defined(_SOCKET_HEADERS_H)
|
#if defined(SOCKET_SUPPORT) && !defined(_SOCKET_HEADERS_H)
|
||||||
#include "socket_headers.h"
|
#include "socket_headers.h"
|
||||||
#endif /* SOCKET_SUPPORT && !_SOCKET_HEADERS_H */
|
#endif /* SOCKET_SUPPORT && !_SOCKET_HEADERS_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: timeb_ftime.c,v 1.1 2006-07-28 13:19:11 obarthel Exp $
|
* $Id: timeb_ftime.c,v 1.2 2006-07-28 14:37:27 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -42,6 +42,10 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
ftime(struct timeb *tb)
|
ftime(struct timeb *tb)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: ulimit_ulimit.c,v 1.1 2006-07-28 14:02:31 obarthel Exp $
|
* $Id: ulimit_ulimit.c,v 1.2 2006-07-28 14:37:27 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -41,6 +41,10 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
long
|
long
|
||||||
ulimit(int cmd,long newlim)
|
ulimit(int cmd,long newlim)
|
||||||
{
|
{
|
||||||
|
|||||||
265
library/unistd_common_pathconf.c
Normal file
265
library/unistd_common_pathconf.c
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
/*
|
||||||
|
* $Id: unistd_common_pathconf.c,v 1.1 2006-07-28 14:37:27 obarthel Exp $
|
||||||
|
*
|
||||||
|
* :ts=4
|
||||||
|
*
|
||||||
|
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||||
|
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STDLIB_NULL_POINTER_CHECK_H
|
||||||
|
#include "stdlib_null_pointer_check.h"
|
||||||
|
#endif /* _STDLIB_NULL_POINTER_CHECK_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _UNISTD_HEADERS_H
|
||||||
|
#include "unistd_headers.h"
|
||||||
|
#endif /* _UNISTD_HEADERS_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ID_CON
|
||||||
|
#define ID_CON (0x434F4E00L) /* 'CON\0' */
|
||||||
|
#endif /* ID_CON */
|
||||||
|
|
||||||
|
#ifndef ID_RAWCON
|
||||||
|
#define ID_RAWCON (0x52415700L) /* 'RAW\0' */
|
||||||
|
#endif /* ID_RAWCON */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
struct fs_info
|
||||||
|
{
|
||||||
|
ULONG dos_type;
|
||||||
|
int name_max,path_max;
|
||||||
|
int link_max,symlink_max;
|
||||||
|
int file_size_bits;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
static const struct fs_info fs_info[] =
|
||||||
|
{
|
||||||
|
{ID_NO_DISK_PRESENT, 0, 0, 0, 0, 0}, /* No disk */
|
||||||
|
{ID_UNREADABLE_DISK, 0, 0, 0, 0, 0}, /* BAD\0 */
|
||||||
|
{ID_BUSY_DISK, 0, 0, 0, 0, 0}, /* BUSY - Diskchange in progress? */
|
||||||
|
{ID_CON, 0, 0, 0, 0, 0}, /* CON\0 - Not really a disk. */
|
||||||
|
{ID_RAWCON, 0, 0, 0, 0, 0}, /* RAW\0 - Not really a disk. */
|
||||||
|
{ID_NOT_REALLY_DOS, 0, 0, 0, 0, 0}, /* Unreadable disk. */
|
||||||
|
{ID_KICKSTART_DISK, 0, 0, 0, 0, 0}, /* Kickstart disk. */
|
||||||
|
{ID_MSDOS_DISK, 8, 31, 0, 0, 30}, /* MSDOS - TODO: Check what the limits really are. */
|
||||||
|
{ID_DOS_DISK, 30, 254, -1, -1, 31}, /* DOS\0 = OFS */
|
||||||
|
{ID_FFS_DISK, 30, 254, -1, -1, 31}, /* DOS\1 = FFS */
|
||||||
|
{ID_INTER_DOS_DISK, 30, 254, -1, -1, 31}, /* DOS\2 = OFS INTL */
|
||||||
|
{ID_INTER_FFS_DISK, 30, 254, -1, -1, 31}, /* DOS\3 = FFS INTL */
|
||||||
|
{ID_FASTDIR_DOS_DISK, 30, 254, -1, -1, 31}, /* DOS\4 = OFS DC */
|
||||||
|
{ID_FASTDIR_FFS_DISK, 30, 254, -1, -1, 31}, /* DOS\5 = FFS DC */
|
||||||
|
{ID_LONGNAME_DOS_DISK, 107, 8192, -1, -1, 31}, /* DOS\6 = OFS LONGNAMES */
|
||||||
|
{ID_LONGNAME_FFS_DISK, 107, 8192, -1, -1, 63}, /* DOS\7 = FFS LONGNAMES */
|
||||||
|
{0x53465300, 107, 8192, 0, -1, 31}, /* SFS\0 = Smartfilesystem */
|
||||||
|
{0x53465302, 107, 8192, 0, -1, 63}, /* SFS\2 = Smartfilesystem2 */
|
||||||
|
{0x50465300, 30, 254, 0, 0, 31}, /* PFS\0 = Professional File System */
|
||||||
|
{0x46545854, 0, 0, 0, 0, 0}, /* FTXT - Textclip device */
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
long
|
||||||
|
__pathconf(struct MsgPort *port,int name)
|
||||||
|
{
|
||||||
|
ULONG dos_type = 0;
|
||||||
|
size_t fs_index = 0;
|
||||||
|
long ret = -1;
|
||||||
|
|
||||||
|
if(port != NULL)
|
||||||
|
{
|
||||||
|
D_S(struct InfoData,id);
|
||||||
|
|
||||||
|
if(DoPkt(port,ACTION_IS_FILESYSTEM,0,0,0,0,0) == DOSFALSE) /* Not a filesystem */
|
||||||
|
{
|
||||||
|
SHOWMSG("Not a filesystem.");
|
||||||
|
|
||||||
|
__set_errno(ENODEV);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DoPkt(port,ACTION_DISK_INFO,MKBADDR(id),0,0,0,0)) /* Managed to obtain disk info. */
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
switch(id->id_DiskState)
|
||||||
|
{
|
||||||
|
case ID_VALIDATING: /* Consider this an error condition? */
|
||||||
|
case ID_WRITE_PROTECTED:
|
||||||
|
case ID_VALIDATED:
|
||||||
|
|
||||||
|
dos_type = id->id_DiskType;
|
||||||
|
|
||||||
|
/* See if we know anything about this file-system */
|
||||||
|
for(i = 0 ; i < NUM_ENTRIES(fs_info) ; i++)
|
||||||
|
{
|
||||||
|
if(dos_type == fs_info[i].dos_type)
|
||||||
|
{
|
||||||
|
fs_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
SHOWMSG("Invalid disk state.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Treat error as no disk present by having default fs_index=0 */
|
||||||
|
SHOWMSG("Unable to query DISK_INFO");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(name)
|
||||||
|
{
|
||||||
|
case _PC_FILESIZEBITS:
|
||||||
|
|
||||||
|
ret = fs_info[fs_index].file_size_bits;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_LINK_MAX:
|
||||||
|
|
||||||
|
ret = fs_info[fs_index].link_max;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_MAX_CANON:
|
||||||
|
|
||||||
|
ret = 510; /* I could not find any documentation regarding this. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_MAX_INPUT:
|
||||||
|
|
||||||
|
#if defined(__amigaos4__)
|
||||||
|
{
|
||||||
|
struct TagItem TagList[2]=
|
||||||
|
{
|
||||||
|
{DC_FHBufferR, 0},
|
||||||
|
{TAG_DONE, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
DosControl(TagList);
|
||||||
|
ret = TagList[0].ti_Data; /* Default is 2048 bytes. */
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
ret = 204;
|
||||||
|
}
|
||||||
|
#endif /* __amigaos4__ */
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_NAME_MAX:
|
||||||
|
|
||||||
|
ret = fs_info[fs_index].name_max;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_PATH_MAX:
|
||||||
|
|
||||||
|
ret = fs_info[fs_index].path_max;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_PIPE_BUF:
|
||||||
|
|
||||||
|
ret = 512; /* One buffer. The PIPE: device usually has 8 of these. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_XATTR_ENABLED:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_XATTR_EXISTS:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_CHOWN_RESTRICTED:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_NO_TRUNC:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_VDISABLE:
|
||||||
|
|
||||||
|
ret = 0; /* TODO: Implement this in the termios emulation. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_ASYNC_IO:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_PRIO_IO:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_SYNC_IO:
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_SYMLINK_MAX:
|
||||||
|
|
||||||
|
ret = fs_info[fs_index].symlink_max;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case _PC_DOSTYPE: /* Amiga-specific extension. */
|
||||||
|
|
||||||
|
ret = dos_type;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
SHOWMSG("Invalid option name");
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
74
library/unistd_fpathconf.c
Normal file
74
library/unistd_fpathconf.c
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* $Id: unistd_fpathconf.c,v 1.1 2006-07-28 14:37:28 obarthel Exp $
|
||||||
|
*
|
||||||
|
* :ts=4
|
||||||
|
*
|
||||||
|
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||||
|
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STDLIB_NULL_POINTER_CHECK_H
|
||||||
|
#include "stdlib_null_pointer_check.h"
|
||||||
|
#endif /* _STDLIB_NULL_POINTER_CHECK_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _UNISTD_HEADERS_H
|
||||||
|
#include "unistd_headers.h"
|
||||||
|
#endif /* _UNISTD_HEADERS_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
long
|
||||||
|
fpathconf(int file_descriptor,int name)
|
||||||
|
{
|
||||||
|
struct FileHandle *fh;
|
||||||
|
long ret = -1;
|
||||||
|
struct fd *fd;
|
||||||
|
|
||||||
|
ENTER();
|
||||||
|
|
||||||
|
fd = __get_file_descriptor(file_descriptor);
|
||||||
|
if(fd == NULL)
|
||||||
|
{
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
fh = BADDR(fd->fd_DefaultFile);
|
||||||
|
|
||||||
|
ret = __pathconf(fh->fh_Type,name); /* Ok if fh->fh_Type==NULL */
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
RETURN(ret);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: unistd_headers.h,v 1.10 2006-04-05 06:43:56 obarthel Exp $
|
* $Id: unistd_headers.h,v 1.11 2006-07-28 14:37:28 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -112,4 +112,8 @@ extern unsigned int __time_delay(unsigned long seconds,unsigned long microsecond
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
extern long __pathconf(struct MsgPort *port,int name);
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
#endif /* _UNISTD_HEADERS_H */
|
#endif /* _UNISTD_HEADERS_H */
|
||||||
|
|||||||
121
library/unistd_pathconf.c
Normal file
121
library/unistd_pathconf.c
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* $Id: unistd_pathconf.c,v 1.1 2006-07-28 14:37:28 obarthel Exp $
|
||||||
|
*
|
||||||
|
* :ts=4
|
||||||
|
*
|
||||||
|
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||||
|
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STDLIB_NULL_POINTER_CHECK_H
|
||||||
|
#include "stdlib_null_pointer_check.h"
|
||||||
|
#endif /* _STDLIB_NULL_POINTER_CHECK_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _UNISTD_HEADERS_H
|
||||||
|
#include "unistd_headers.h"
|
||||||
|
#endif /* _UNISTD_HEADERS_H */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||||
|
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
long
|
||||||
|
pathconf(const char *path,int name)
|
||||||
|
{
|
||||||
|
struct name_translation_info path_name_nti;
|
||||||
|
struct DevProc * dvp = NULL;
|
||||||
|
BOOL ignore_port = FALSE;
|
||||||
|
long ret = -1;
|
||||||
|
|
||||||
|
ENTER();
|
||||||
|
|
||||||
|
SHOWSTRING(path);
|
||||||
|
SHOWVALUE(name);
|
||||||
|
|
||||||
|
#if defined(CHECK_FOR_NULL_POINTERS)
|
||||||
|
{
|
||||||
|
if(path == NULL)
|
||||||
|
{
|
||||||
|
SHOWMSG("invalid path name");
|
||||||
|
|
||||||
|
__set_errno(EFAULT);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CHECK_FOR_NULL_POINTERS */
|
||||||
|
|
||||||
|
#if defined(UNIX_PATH_SEMANTICS)
|
||||||
|
{
|
||||||
|
if(__unix_path_semantics)
|
||||||
|
{
|
||||||
|
if(path[0] == '\0')
|
||||||
|
{
|
||||||
|
SHOWMSG("Empty name");
|
||||||
|
|
||||||
|
__set_errno(ENOENT);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(__translate_unix_to_amiga_path_name(&path,&path_name_nti) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if(path_name_nti.is_root)
|
||||||
|
{
|
||||||
|
/* Should we disallow / or use OFS as the lowest common denominator? */
|
||||||
|
ignore_port = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* UNIX_PATH_SEMANTICS */
|
||||||
|
|
||||||
|
if(!ignore_port)
|
||||||
|
{
|
||||||
|
dvp = GetDeviceProc((STRPTR)path,NULL);
|
||||||
|
if(dvp == NULL)
|
||||||
|
{
|
||||||
|
__set_errno(__translate_access_io_error_to_errno(IoErr()));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = __pathconf((dvp != NULL) ? dvp->dvp_Port : NULL,name);
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
if(dvp != NULL)
|
||||||
|
{
|
||||||
|
FreeDeviceProc(dvp);
|
||||||
|
dvp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN(ret);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user