Changeset 1519


Ignore:
Timestamp:
Sep 27, 2004, 4:15:07 AM (21 years ago)
Author:
bird
Message:

Big path handling change. Fixed wrong file headers. A new api or two. A bit of restructuring. And hopefully no new bug :-)

Location:
trunk/src/emx
Files:
29 added
8 deleted
112 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/CompileOne.sh

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    11#!sh
    22ROOTDIR=`dirname $0`
    3 OUTDIR=$ROOTDIR/../../out/OS2/DEBUG/emx
     3OUTDIR=$ROOTDIR/../../obj/OS2/DEBUG
    44SRCDIR=`dirname $1`
    55cd $ROOTDIR
  • trunk/src/emx/include/InnoTekLIBC/backend.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    3030#include <sys/cdefs.h>
    3131#include <sys/types.h>
     32#include <emx/io.h>
    3233
    3334__BEGIN_DECLS
     
    3839#endif
    3940struct statfs;
     41struct stat;
    4042
    4143
     
    8284
    8385
    84 /** @defgroup __libc_Back_fh   LIBC Backend - File Handles.
    85  * @{ */
     86/** @defgroup __libc_Back_fs   LIBC Backend - File System
     87 * @{ */
     88
     89/**
     90 * Get the statistics for the filesystem which pszPath is located on.
     91 *
     92 * @returns 0 on success.
     93 * @returns Negative error code (errno.h) on failure.
     94 * @param   pszPath     The path to somewhere in the filesystem.
     95 * @param   pStatFs     Where to store the obtained information.
     96 */
     97int __libc_Back_fsStat(const char *pszPath, struct statfs *pStatFs);
     98
     99/**
     100 * Get file system statistics
     101 *
     102 * @returns 0 on success.
     103 * @returns Negative error code (errno.h) on failure.
     104 * @param   fh          The filehandle of any file within the mounted file system.
     105 * @param   pStatFs     Where to store the statistics.
     106 */
     107int __libc_Back_fsStatFH(int fh, struct statfs *pStatFs);
     108
     109/**
     110 * Get the statistics for all the mounted filesystems.
     111 *
     112 * @returns Number of returned statfs structs on success.
     113 * @returns Number of mounted filesystems on success if paStatFS is NULL
     114 * @returns Negative error code (errno.h) on failure.
     115 * @param   paStatFs    Where to to store the statistics.
     116 * @param   cStatFS     Number of structures the array pointed to by paStatFs can hold.
     117 * @param   fFlags      Flags, currently ignored.
     118 */
     119int __libc_Back_fsStats(struct statfs *paStatFs, unsigned cStatFs, unsigned fFlags);
     120
     121/**
     122 * Schedules all file system buffers for writing.
     123 *
     124 * See sync() for OS/2 limitations.
     125 */
     126void __libc_Back_fsSync(void);
     127
     128/**
     129 * Resolves the path into an canonicalized absolute path.
     130 *
     131 * @returns 0 on success.
     132 * @returns Negative error code (errno.h) on failure.
     133 * @param   pszPath     The path to resolve.
     134 * @param   pszBuf      Where to store the resolved path.
     135 * @param   cchBuf      Size of the buffer.
     136 * @param   fFlags      At the moment 0. Which means the entire path must exist.
     137 */
     138int __libc_Back_fsPathResolve(const char *pszPath, char *pszBuf, size_t cchBuf, unsigned fFlags);
     139
     140/**
     141 * Changes the default drive of the process.
     142 *
     143 * @returns 0 on success.
     144 * @returns Negative error code (errno.h) on failure.
     145 * @param   chDrive     New default drive.
     146 */
     147int __libc_Back_fsDriveDefaultSet(char chDrive);
     148
     149/**
     150 * Gets the default drive of the process.
     151 *
     152 * @returns 0 on success.
     153 * @returns Negative error code (errno.h) on failure.
     154 * @param   pchDrive    Where to store the default drive.
     155 */
     156int __libc_Back_fsDriveDefaultGet(char *pchDrive);
     157
     158/**
     159 * Sets or change the unixroot of the current process.
     160 *
     161 * @returns 0 on success.
     162 * @returns Negative error code (errno.h) on failure.
     163 * @param   pszNewRoot  The new root.
     164 */
     165int __libc_Back_fsDirChangeRoot(const char *pszNewRoot);
     166
     167/**
     168 * Gets the current directory of the process on a
     169 * specific drive or on the current one.
     170 *
     171 * @returns 0 on success.
     172 * @returns Negative error code (errno.h) on failure.
     173 * @param   pszPath     Where to store the path to the current directory.
     174 *                      This will be prefixed with a drive letter if we're
     175 *                      not in the unix tree.
     176 * @param   cchPath     The size of the path buffer.
     177 * @param   chDrive     The drive letter of the drive to get it for.
     178 *                      If '\0' the current dir for the current drive is returned.
     179 * @param   fFlags      Flags for skipping drive letter and slash.
     180 */
     181int __libc_Back_fsDirCurrentGet(char *pszPath, size_t cchPath, char chDrive, int fFlags);
     182
     183/** Flags for __libc_Back_fsDirCurrentGet().
     184 * @{ */
     185#define __LIBC_BACK_FSCWD_NO_DRIVE          1
     186#define __LIBC_BACK_FSCWD_NO_ROOT_SLASH     2
     187/** @} */
     188
     189/**
     190 * Changes the current directory of the process.
     191 *
     192 * @returns 0 on success.
     193 * @returns Negative error code (errno.h) on failure.
     194 * @param   pszPath     Path to the new current directory of the process.
     195 */
     196int __libc_Back_fsDirCurrentSet(const char *pszPath);
     197
     198/**
     199 * Creates a new directory.
     200 *
     201 * @returns 0 on success.
     202 * @returns Negative error code (errno.h) on failure.
     203 * @param   pszPath     Path of the new directory.
     204 * @param   Mode        Permissions on the created directory.
     205 */
     206int __libc_Back_fsDirCreate(const char *pszPath, mode_t Mode);
     207
     208/**
     209 * Removes a new directory.
     210 *
     211 * @returns 0 on success.
     212 * @returns Negative error code (errno.h) on failure.
     213 * @param   pszPath     Path to the directory which is to be removed.
     214 */
     215int __libc_Back_fsDirRemove(const char *pszPath);
     216
     217/**
     218 * Creates a symbolic link.
     219 *
     220 * @returns 0 on success.
     221 * @returns Negative error code (errno.h) on failure.
     222 * @param   pszTarget   The target of the symlink link.
     223 * @param   pszSymlink  The path to the symbolic link to create.
     224 */
     225int __libc_Back_fsSymlinkCreate(const char *pszTarget, const char *pszSymlink);
     226
     227/**
     228 * Reads the content of a symbolic link.
     229 *
     230 * This is weird interface as it will return a truncated result if not
     231 * enough buffer space. It is also weird in that there is no string
     232 * terminator.
     233 *
     234 * @returns Number of bytes returned in pachBuf.
     235 * @returns Negative error code (errno.h) on failure.
     236 * @param   pszPath     The path to the symlink directory.
     237 * @param   pachBuf     Where to store the symlink value.
     238 * @param   cchBuf      Size of buffer.
     239 */
     240int __libc_Back_fsSymlinkRead(const char *pszPath, char *pachBuf, size_t cchBuf);
     241
     242/**
     243 * Stats a symbolic link.
     244 *
     245 * @returns 0 on success.
     246 * @returns Negative error code (errno.h) on failure.
     247 * @param   pszPath     Path to the file to stat. If this is a symbolic link
     248 *                      the link it self will be stat'ed.
     249 * @param   pStat       Where to store the file stats.
     250 */
     251int __libc_Back_fsSymlinkStat(const char *pszPath, struct stat *pStat);
     252
     253/**
     254 * Stats a file.
     255 *
     256 * @returns 0 on success.
     257 * @returns Negative error code (errno.h) on failure.
     258 * @param   pszPath     Path to the file to stat.
     259 * @param   pStat       Where to store the file stats.
     260 */
     261int __libc_Back_fsFileStat(const char *pszPath, struct stat *pStat);
     262
     263/**
     264 * Gets the file stats for a file by filehandle.
     265 *
     266 * @returns 0 on success.
     267 * @returns Negative error code (errno.h) on failure. The content
     268 *          of *pStat is undefined.
     269 * @param   fh      Handle to file.
     270 * @param   pStat   Where to store the stats.
     271 */
     272int __libc_Back_fsFileStatFH(int fh, struct stat *pStat);
     273
     274
     275/** @defgroup __libc_Back_io   LIBC Backend - I/O and File Management.
     276 * @{ */
     277
     278/**
     279 * Opens a file.
     280 *
     281 * @returns Filehandle to the opened file on success.
     282 * @returns Negative error code (errno.h) on failure.
     283 * @param   pszFile     Path to the file.
     284 * @param   fFlags      Open flags.
     285 * @param   cbInitial   Initial filesize.
     286 * @param   Mode        The specified permission mask.
     287 * @param   fLibc       LIBC filehandle flags.
     288 * @param   ppFH        Where to store the LIBC filehandle structure which was created
     289 *                      for the opened file.
     290 */
     291int __libc_Back_ioFileOpen(const char *pszFile, int fFlags, off_t cbInitial, mode_t Mode, unsigned fLibc, PLIBCFH *ppFH);
     292
     293/**
     294 * Change the current position of a file stream and get the new position.
     295 *
     296 * @returns new file offset on success.
     297 * @returns Negative error code (errno) on failure.
     298 * @param   hFile       File handle to preform seek operation on.
     299 * @param   off         Offset to seek to.
     300 * @param   iMethod     The seek method. SEEK_CUR, SEEK_SET or SEEK_END.
     301 */
     302off_t __libc_Back_ioSeek(int hFile, off_t off, int iMethod);
     303
     304/**
     305 * Sets the size of an open file.
     306 *
     307 * When expanding a file the contents of the allocated
     308 * space is undefined.
     309 *
     310 * @returns 0 on success.
     311 * @returns Negative error code (errno.h) on failure.
     312 * @param   fh      Handle to the file which size should be changed.
     313 * @param   cbFile  The new filesize.
     314 * @param   fZero   If set any new allocated file space will be
     315 *                  initialized to zero.
     316 */
     317int __libc_Back_ioFileSizeSet(int fh, __off_t cbFile, int fZero);
    86318
    87319/**
     
    89321 *
    90322 * @returns 0 on success.
    91  * @returns -1 and errno on failure.
     323 * @returns Negative error code (errno.h) on failure.
    92324 * @param   fh          The file handle.
    93325 * @param   pszPath     Where to store the path.
    94326 * @param   cchPath     The size of he buffer pointed to by pszPath.
    95327 */
    96 int __libc_Back_fhToPath(int fh, char *pszPath, size_t cchPath);
    97 
    98 /** @} */
    99 
    100 
    101 /** @defgroup __libc_Back_fs   LIBC Backend - File System
    102  * @{ */
    103 
    104 /**
    105  * Get the statistics for the filesystem which pszPath is located on.
    106  *
    107  * @returns 0 on success.
    108  * @returns -1 and errno on failure.
    109  * @param   pszPath     The path to somewhere in the filesystem.
    110  * @param   pStatFs     Where to store the obtained information.
    111  */
    112 int __libc_Back_fsStat(const char *pszPath, struct statfs *pStatFs);
    113 
    114 /**
    115  * Get file system statistics
    116  *
    117  * @returns 0 on success.
    118  * @returns -1 and errno on failure.
    119  * @param   fh          The filehandle of any file within the mounted file system.
    120  * @param   pStatFs     Where to store the statistics.
    121  */
    122 int __libc_Back_fsStatFH(int fh, struct statfs *pStatFs);
    123 
    124 /**
    125  * Get the statistics for all the mounted filesystems.
    126  *
    127  * @returns Number of returned statfs structs on success.
    128  * @returns Number of mounted filesystems on success if paStatFS is NULL
    129  * @returns -1 and errno on failure.
    130  * @param   paStatFs    Where to to store the statistics.
    131  * @param   cStatFS     Number of structures the array pointed to by paStatFs can hold.
    132  * @param   fFlags      Flags, currently ignored.
    133  */
    134 int __libc_Back_fsStats(struct statfs *paStatFs, unsigned cStatFs, unsigned fFlags);
    135 
    136 /**
    137  * Schedules all file system buffers for writing.
    138  *
    139  * See sync() for OS/2 limitations.
    140  */
    141 void __libc_Back_fsSync(void);
    142 
    143 /**
    144  * Sets or change the unixroot of the current process.
    145  *
    146  * @returns 0 on success.
    147  * @returns -1 and errno on failure.
    148  * @param   pszNewRoot  The new root.
    149  */
    150 int __libc_Back_fsChRoot(const char *pszNewRoot);
     328int __libc_Back_ioFHToPath(int fh, char *pszPath, size_t cchPath);
     329
     330/** @} */
    151331
    152332/** @} */
     
    163343 *
    164344 * @returns 0 on success.
    165  * @returns -1 and errno on failure.
     345 * @returns Negative error code (errno.h) on failure.
    166346 * @param   pardAvgs    Where to store the samples.
    167347 * @param   cAvgs       Number of samples to get. Max is 3.
  • trunk/src/emx/include/InnoTekLIBC/logstrict.h

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    182182#define __LIBC_LOG_GRP_ENV          15
    183183
     184/** Backend FS APIs. */
     185#define __LIBC_LOG_GRP_BACK_FS      23
    184186/** Shared Process Database and LIBC Shared Memory APIs. */
    185187#define __LIBC_LOG_GRP_SPM          24
  • trunk/src/emx/include/InnoTekLIBC/sharedpm.h

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    178178typedef __LIBC_SPMINHFHBSOCK *__LIBC_PSPMINHFHBSOCK;
    179179
     180/**
     181 * SPM fs inherit data.
     182 */
     183typedef struct __libc_SPMInhFS
     184{
     185    /** In Unix Tree global. */
     186    int         fInUnixTree;
     187    /** Size of the unix root. Only set if there's an official root. */
     188    size_t      cchUnixRoot;
     189    /** The current unix root if cchUnixRoot is non-zero. */
     190    char        szUnixRoot[1];
     191} __LIBC_SPMINHFS;
     192/** Pointer to FS inherit data. */
     193typedef __LIBC_SPMINHFS *__LIBC_PSPMINHFS;
     194
     195
    180196
    181197/**
     
    191207     * This is a succession of bundles terminating with a _END one. */
    192208    __LIBC_PSPMINHFHBHDR    pFHBundles;
     209    /** Pointer to the file system part. If NULL default values are assumed. */
     210    __LIBC_PSPMINHFS        pFS;
    193211
    194212    /** @todo Add signals and the other properties which are inherited. */
     
    559577 *
    560578 * @returns 0 on success.
    561  * @returns -1 and errno on failure.
     579 * @returns Negative error code (errno.h) on failure.
    562580 * @param   pLoadAvg    Where to store the load average samples.
    563581 * @param   puTimestamp Where to store the current timestamp.
     
    569587 *
    570588 * @returns 0 on success.
    571  * @returns -1 and errno on failure.
     589 * @returns Negative error code (errno.h) on failure.
    572590 * @param   pLoadAvg    Where to store the load average samples.
    573591 */
  • trunk/src/emx/include/direct.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    5959char _getdrive(void);
    6060
     61/* Special LIBC addition. */
     62#ifdef __BSD_VISIBLE
     63char *_getcwdux(char *, size_t);
     64#endif
     65
    6166__END_DECLS
    6267
  • trunk/src/emx/include/emx/io.h

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    384384int     __libc_FHClose(int fh);
    385385PLIBCFH __libc_FH(int fh);
     386int     __libc_FHEx(int fh, __LIBC_PFH *ppFH);
    386387
    387388
  • trunk/src/emx/include/emx/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    120120
    121121
    122 int __accept (int handle, struct sockaddr *addr, int *paddrlen);
     122//dead int __accept (int handle, struct sockaddr *addr, int *paddrlen);
    123123unsigned __alarm (unsigned sec);
    124 int __bind (int handle, __const__ struct sockaddr *addr, int addrlen);
     124//dead int __bind (int handle, __const__ struct sockaddr *addr, int addrlen);
    125125void *__brk (void *addr);
    126126void __cgets (char *buffer);
    127 int __chdir (__const__ char *name);
     127//dead int __chdir (__const__ char *name);
    128128int __chmod (__const__ char *name, int flag, int attr);
    129129int __chdrive (char drive);
    130 int __chsize (int handle, off_t length);
     130//dead int __chsize (int handle, off_t length);
    131131long long __clock (void);
    132132int __close (int handle);
    133 int __connect (int handle, __const__ struct sockaddr *addr, int addrlen);
     133//dead int __connect (int handle, __const__ struct sockaddr *addr, int addrlen);
    134134int __core (int handle);
    135135int __dup (int handle);
     
    142142int __findfirst (__const__ char *name, int attr, struct _find *fp);
    143143int __findnext (struct _find *fp);
    144 int __fork (void);
    145 int __fstat (int handle, struct stat *buffer);
     144//dead int __fork (void);
     145//dead int __fstat (int handle, struct stat *buffer);
    146146int __fsync (int handle);
    147147void __ftime (struct timeb *ptr);
    148 int __ftruncate (int handle, off_t length);
    149 int __getcwd (char *buffer, char drive);
     148//dead int __ftruncate (int handle, off_t length);
     149//dead int __getcwd (char *buffer, char drive);
    150150char __getdrive (void);
    151 int __gethostbyaddr (__const__ char *addr, int len, int type,
    152     struct hostent **dst);
    153 int __gethostbyname (__const__ char *name, struct hostent **dst);
    154 int __gethostid (int *dst);
    155 int __gethostname (char *name, int len);
    156 int __getnetbyname (__const__ char *name, struct netent **dst);
    157 int __getnetbyaddr (long net, struct netent **dst);
    158 int __getpeername (int handle, struct sockaddr *name, int *pnamelen);
     151//dead int __gethostbyaddr (__const__ char *addr, int len, int type,
     152//dead     struct hostent **dst);
     153//dead int __gethostbyname (__const__ char *name, struct hostent **dst);
     154//dead int __gethostid (int *dst);
     155//dead int __gethostname (char *name, int len);
     156//dead int __getnetbyname (__const__ char *name, struct netent **dst);
     157//dead int __getnetbyaddr (long net, struct netent **dst);
     158//dead int __getpeername (int handle, struct sockaddr *name, int *pnamelen);
    159159int __getpid (void);
    160160int __getppid (void);
    161 int __getprotobyname (__const__ char *name, struct protoent **dst);
    162 int __getprotobynumber (int prot, struct protoent **dst);
    163 int __getservbyname (__const__ char *name, __const__ char *proto,
    164     struct servent **dst);
    165 int __getservbyport (int port, __const__ char *proto, struct servent **dst);
    166 int __getsockhandle (int handle);
    167 int __getsockname (int handle, struct sockaddr *name, int *pnamelen);
    168 int __getsockopt (int handle, int level, int optname, void *optval,
    169     int *poptlen);
    170 int __imphandle (int handle);
    171 int __impsockhandle (int handle, int flags);
     161//dead int __getprotobyname (__const__ char *name, struct protoent **dst);
     162//dead int __getprotobynumber (int prot, struct protoent **dst);
     163//dead int __getservbyname (__const__ char *name, __const__ char *proto,
     164//dead     struct servent **dst);
     165//dead int __getservbyport (int port, __const__ char *proto, struct servent **dst);
     166//dead int __getsockhandle (int handle);
     167//dead int __getsockname (int handle, struct sockaddr *name, int *pnamelen);
     168//dead int __getsockopt (int handle, int level, int optname, void *optval,
     169//dead     int *poptlen);
     170//dead int __imphandle (int handle);
     171//dead int __impsockhandle (int handle, int flags);
    172172int __ioctl1 (int handle, int code);
    173173int __ioctl2 (int handle, unsigned long request, int arg);
    174174int __kill (int pid, int sig);
    175175int __listen (int handle, int backlog);
    176 off_t __lseek (int handle, off_t offset, int origin);
     176//dead off_t __lseek (int handle, off_t offset, int origin);
    177177int __memavail (void);
    178 int __mkdir (__const__ char *name);
     178//dead int __mkdir (__const__ char *name);
    179179int __newthread (int tid);
    180180struct __libc_FileHandle;
    181 int __open (__const__ char *name, int flags, off_t size, unsigned fLibc, struct __libc_FileHandle **pFH);
     181//dead int __open (__const__ char *name, int flags, off_t size, mode_t cmode, unsigned fLibc, struct __libc_FileHandle **pFH);
    182182int __pause (void);
    183183int __pipe(int *two_handles, int pipe_size, struct __libc_FileHandle **ppFHRead, struct __libc_FileHandle **ppFHWrite);
     
    191191int __remove (__const__ char *name);
    192192int __rename (__const__ char *old_name, __const__ char *new_name);
    193 int __rmdir (__const__ char *name);
     193//dead int __rmdir (__const__ char *name);
    194194void *__sbrk (int incr);
    195195void __scrsize (int *dst);
    196 int __select(int nfds, struct fd_set *readfds, struct fd_set *writefds,
    197              struct fd_set *exceptfds, struct timeval *tv);
    198 int __send (int handle, __const__ void *buf, int len, unsigned flags);
    199 int __sendto (__const__ struct _sendto *args);
    200 int __setsockopt (int handle, int level, int optname, __const__ void *optval,
    201     int optlen);
     196//dead int __select(int nfds, struct fd_set *readfds, struct fd_set *writefds,
     197//dead              struct fd_set *exceptfds, struct timeval *tv);
     198//dead int __send (int handle, __const__ void *buf, int len, unsigned flags);
     199//dead int __sendto (__const__ struct _sendto *args);
     200//dead int __setsockopt (int handle, int level, int optname, __const__ void *optval,
     201//dead     int optlen);
    202202int __settime (const struct timeval *tp);
    203 int __shutdown (int handle, int how);
     203//dead int __shutdown (int handle, int how);
    204204int __sigaction (int _sig, __const__ struct sigaction *_iact,
    205205    struct sigaction *_oact);
     
    210210unsigned __sleep (unsigned sec);
    211211unsigned __sleep2 (unsigned millisec);
    212 int __socket (int domain, int type, int protocol);
     212//dead int __socket (int domain, int type, int protocol);
    213213int __spawnve (struct _new_proc *np);
    214 int __stat (__const__ char *name, struct stat *buffer);
     214//dead int __stat (__const__ char *name, struct stat *buffer);
    215215int __swchar (int flag, int new_char);
    216216int __uflags (int mask, int new_flags);
    217217long __ulimit (int cmd, long new_limit);
    218 int __umask (int pmode);
     218//dead int __umask (int pmode);
    219219void __unwind2 (void *xcpt_reg_ptr);
    220220int __utimes (__const__ char *name, __const__ struct timeval *tvp);
  • trunk/src/emx/include/io.h

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    8585int      truncate(const char *, off_t);
    8686#endif
    87 int umask (int);
     87mode_t  umask(mode_t);
    8888int unlink (__const__ char *);
    8989int write (int, __const__ void *, size_t);
  • trunk/src/emx/include/stdlib.h

    • Property cvs2svn:cvs-rev changed from 1.24 to 1.25
    r1518 r1519  
    287287#endif /* __BSD_VISIBLE */
    288288
     289
     290
     291/* bird: LIBC stuff - start  */
     292#ifdef __BSD_VISIBLE
     293char    *_getcwdux(char *, size_t);
     294#endif
     295#ifdef  __USE_GNU
     296char    *canonicalize_file_name(const char *);
     297#endif
     298/* bird: LIBC stuff - end  */
    289299
    290300
  • trunk/src/emx/include/unistd.h

    • Property cvs2svn:cvs-rev changed from 1.19 to 1.20
    r1518 r1519  
    408408
    409409
    410 #if !defined(_POSIX_SOURCE)
    411 
    412 
    413 #endif
    414 
    415 
     410/*
     411 * LIBC additions.
     412 */
     413#ifdef __BSD_VISIBLE
     414char    *_getcwdux(char *, size_t);
     415#endif
     416
     417
     418/*
     419 * EMX stuff.
     420 */
    416421#if !defined(_POSIX_SOURCE) || defined(_WITH_UNDERSCORE)
    417422/** @todo update this section to match the one without underscores as far as needed! */
  • trunk/src/emx/src/lib/io/_vsopen.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1010#include <emx/io.h>
    1111#include <emx/syscalls.h>
     12#include <InnoTekLIBC/backend.h>
    1213
    1314/* Bugs: O_TRUNC|O_RDONLY not implemented */
     
    4445    int         fCtrlZKludge = 0;
    4546    off_t       cbInitial;
     47    mode_t      cmode = 0;
    4648    PLIBCFH     pFH;
    4749
     
    7577        fFlags = (fOpen & O_ACCMODE) | (fShare & SH_MASK);
    7678
    77     /* pmode(=attr) - attr is 2nd byte of flags. */
     79    /* cmode(=attr) - attr is 2nd byte of flags. */
    7880    if (fOpen & O_CREAT)
    7981    {
    80         int attr, pmode;
     82        int attr;
    8183
    8284        attr = 0;
    83         pmode = va_arg(va, int);
    84         if (!(pmode & S_IWRITE))
     85        cmode = va_arg(va, mode_t);
     86        if (!(cmode & S_IWRITE))
    8587            attr |= _A_RDONLY;
    8688        fFlags |= (attr << 8) | _SO_CREAT;
     
    110112     */
    111113    saved_errno = errno;
    112     hFile = __open(pszName, fFlags, cbInitial, fLibc, &pFH);
     114    hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc, &pFH);
    113115    if (hFile < 0 && fCtrlZKludge && errno == EACCES)
    114116    {
    115117        /* Perhaps read access is denied. Try again. */
    116         errno = saved_errno;
    117118        fCtrlZKludge = 0;
    118119        fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE);
    119         hFile = __open(pszName, fFlags, cbInitial, fLibc, &pFH);
     120        hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc, &pFH);
    120121    }
    121122    if (hFile < 0)
     123    {
     124        errno = -hFile;
    122125        return -1;
     126    }
    123127    fLibc = pFH->fFlags;                /* get the updated flags. */
    124128
     
    142146           should be harmless. */
    143147
    144         cbSize = __lseek(hFile, -1, SEEK_END);
     148        cbSize = __libc_Back_ioSeek(hFile, -1, SEEK_END);
    145149        if (cbSize >= 0)
    146150        {
    147151            if (__read(hFile, &chDummy, 1) == 1 && chDummy == 0x1a)
    148                 __ftruncate(hFile, cbSize); /* Remove Ctrl-Z */
    149             __lseek(hFile, 0L, SEEK_SET);
     152                __libc_Back_ioFileSizeSet(hFile, cbSize, 0); /* Remove Ctrl-Z */
     153            __libc_Back_ioSeek(hFile, 0, SEEK_SET);
    150154        }
    151155    }
     
    159163        fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE);
    160164        fFlags &= ~_SO_EXCL;       /* Ignore O_EXCL */
    161         hFile = __open(pszName, fFlags, cbInitial, fLibc & ~__LIBC_FH_TYPEMASK, &pFH);
     165        hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc & ~__LIBC_FH_TYPEMASK, &pFH);
    162166        if (hFile < 0)
     167        {
     168            errno = -hFile;
    163169            return -1;
     170        }
    164171    }
    165172
     
    170177    if (    (fLibc & __LIBC_FH_TYPEMASK) == F_FILE
    171178        &&  (fLibc & O_APPEND))
    172         __lseek(hFile, 0L, SEEK_END);
     179        __libc_Back_ioSeek(hFile, 0, SEEK_END);
    173180    errno = saved_errno;
    174181
  • trunk/src/emx/src/lib/io/chsize.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1 /* chsize.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * chsize.
     5 *
     6 * Copyright (c) 2004 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*   Header Files                                                               *
     29*******************************************************************************/
    330#include "libc-alias.h"
    431#include <string.h>
    532#include <io.h>
    633#include <errno.h>
    7 #include <emx/io.h>
    8 #include <emx/syscalls.h>
     34#include <InnoTekLIBC/backend.h>
     35#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_IO
     36#include <InnoTekLIBC/logstrict.h>
    937
    10 int _STD(chsize) (int handle, off_t length)
     38
     39/**
     40 * Change file size.
     41 *
     42 * @returns 0 on success.
     43 * @returns -1 and errno on failure.
     44 * @param   fh      Handle to the file.
     45 * @param   length  New file size.
     46 */
     47int _STD(chsize)(int fh, off_t length)
    1148{
    12   PLIBCFH   pFH;
    13   off_t n;
    14 
    15   pFH = __libc_FH(handle);
    16   if (   !pFH
    17       || (pFH->fFlags & F_DEV)
    18       || pFH->pOps)
    19     {
    20       errno = EBADF;
    21       return -1;
    22     }
    23   n = __lseek (handle, 0, SEEK_END);
    24   if (n == -1)
    25     return -1;
    26   if (__chsize (handle, length) != 0)
    27     return -1;
    28   if (n < length)
    29     {
    30       off_t i;
    31       int   j;
    32       char  zeros[4096];
    33       bzero (zeros, sizeof (zeros));
    34       if (__lseek (handle, n, SEEK_SET) == -1)
    35         return -1;
    36       while (n < length)
    37         {
    38           i = length - n;
    39           if (i > sizeof (zeros))
    40             i = sizeof (zeros);
    41           j = __write (handle, zeros, i);
    42           if (j == -1)
    43             return -1;
    44           if (j == 0)
    45             {
    46               errno = ENOSPC;
    47               return -1;
    48             }
    49           n += j;
    50         }
    51     }
    52   return 0;
     49    LIBCLOG_ENTER("fh=%d length=%lld\n", fh, length);
     50    int rc = __libc_Back_ioFileSizeSet(fh, length, 1);
     51    if (!rc)
     52        LIBCLOG_RETURN_INT(0);
     53    errno = -rc;
     54    LIBCLOG_RETURN_INT(-1);
    5355}
  • trunk/src/emx/src/lib/io/eaccess.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/io/fchown.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/io/fileleng.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    33#include "libc-alias.h"
    44#include <io.h>
    5 #include <emx/syscalls.h>
     5#include <errno.h>
     6#include <InnoTekLIBC/backend.h>
    67
    7 off_t _STD(filelength) (int handle)
     8off_t _STD(filelength)(int handle)
    89{
    9   off_t offcur, offend;
    10 
    11   offcur = __lseek (handle, 0L, SEEK_CUR);
    12   if (offcur == -1)
     10    off_t offcur = __libc_Back_ioSeek(handle, 0L, SEEK_CUR);
     11    if (offcur >= 0)
     12    {
     13        off_t offend = __libc_Back_ioSeek(handle, 0L, SEEK_END);
     14        __libc_Back_ioSeek(handle, offcur, SEEK_SET);
     15        if (offend >= 0)
     16            return offend;
     17    }
     18    errno = -offcur;
    1319    return -1;
    14   offend = __lseek (handle, 0L, SEEK_END);
    15   __lseek (handle, offcur, SEEK_SET);
    16   return offend;
    1720}
  • trunk/src/emx/src/lib/io/fstat.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    44#include <time.h>
    55#include <io.h>
     6#include <errno.h>
    67#include <sys/types.h>
    78#include <sys/stat.h>
    89#include <emx/time.h>
    910#include <emx/syscalls.h>
     11#include <InnoTekLIBC/backend.h>
    1012
    1113int _STD(fstat) (int handle, struct stat *buffer)
    1214{
    13   int rc;
    14 
    15   rc = __fstat (handle, buffer);
     15  int rc = __libc_Back_fsFileStatFH (handle, buffer);
    1616  if (rc == 0)
    1717    {
    18       if (!_tzset_flag) tzset ();
     18      if (!_tzset_flag)
     19        tzset ();
    1920      _loc2gmt (&buffer->st_atime, -1);
    2021      _loc2gmt (&buffer->st_mtime, -1);
    2122      _loc2gmt (&buffer->st_ctime, -1);
    2223    }
     24  else
     25    {
     26      errno = -rc;
     27      rc = -1;
     28    }
    2329  return rc;
    2430}
  • trunk/src/emx/src/lib/io/ftruncat.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1 /* ftruncat.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes
    2                         -- Copyright (c) 2003 by Knut St. Osmunden */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * ftruncate().
     5 *
     6 * Copyright (c) 2004 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 */
    326
     27/*******************************************************************************
     28*   Header Files                                                               *
     29*******************************************************************************/
    430#include "libc-alias.h"
    5 #include <io.h>
    631#include <errno.h>
    7 #include <emx/io.h>
    8 #include <emx/syscalls.h>
     32#include <unistd.h>
     33#include <InnoTekLIBC/backend.h>
     34#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_IO
     35#include <InnoTekLIBC/logstrict.h>
    936
    10 int _STD(ftruncate) (int handle, off_t length)
     37int _STD(ftruncate)(int fh, off_t length)
    1138{
    12     PLIBCFH pFH;
     39    LIBCLOG_ENTER("fh=%d length=%lld\n", fh, length);
     40    int rc = __libc_Back_ioFileSizeSet(fh, length, 1);
     41    if (!rc)
     42        LIBCLOG_RETURN_INT(0);
     43    errno = -rc;
     44    LIBCLOG_RETURN_INT(-1);
     45}
    1346
    14     /*
    15      * Get filehandle.
    16      */
    17     pFH = __libc_FH(handle);
    18     if (!pFH)
    19     {
    20         errno = EBADF;
    21         return -1;
    22     }
    23 /** @todo check this api with latest specs - there is a zero fill extension now IIRC. */
    24     if ((pFH->fFlags & __LIBC_FH_TYPEMASK) != F_FILE)
    25     {
    26         errno = EBADF;
    27         return -1;
    28     }
    29     return __ftruncate (handle, length);
    30 }
  • trunk/src/emx/src/lib/io/lchown.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/io/link.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/io/lseek.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    55#include <errno.h>
    66#include <emx/io.h>
    7 #include <emx/syscalls.h>
     7#include <InnoTekLIBC/backend.h>
    88
    99off_t _STD(lseek) (int handle, off_t offset, int origin)
     
    1717    pFH = __libc_FH(handle);
    1818    if (!pFH)
    19     {
    20         errno = EBADF;
    21         return -1;
    22     }
     19      return -1;
    2320
    2421    if (    origin == SEEK_CUR
     
    2623            || (pFH->fFlags & F_EOF)) )
    2724        --offset;
    28 #if 0 /* not needed on OS/2 I think... */
    29     if (offset < 0)
    30     {
    31         off_t   cur;
    32         /* DOS doesn't return an error for seek before beginning of file */
    33         if (origin == SEEK_SET)
    34         {
    35             errno = EINVAL;
    36             return -1;
    37         }
    38         cur = __lseek(handle, 0, SEEK_CUR);
    39         if (cur == -1L)
    40             return -1;
    41         n = __lseek(handle, 0, origin);
    42         if (n + offset < 0)
    43         {
    44             __lseek(handle, cur, SEEK_SET);
    45             errno = EINVAL;
    46             return -1;
    47         }
    48         offset += n;
    49         origin = SEEK_SET;
    50     }
    51 #endif
    52     n = __lseek(handle, offset, origin);
    53     if (n == -1)
    54         return -1;
    55     else
     25    n = __libc_Back_ioSeek(handle, offset, origin);
     26    if (n >= 0)
    5627    {
    5728        pFH->fFlags &= ~F_EOF;          /* Clear Ctrl-Z flag */
     
    5930        return n;
    6031    }
     32    errno = -n;
     33    return -1;
    6134}
  • trunk/src/emx/src/lib/io/stat.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1212#include <emx/time.h>
    1313#include <emx/syscalls.h>
     14#include <InnoTekLIBC/backend.h>
    1415
    1516int _STD(stat) (const char *name, struct stat *buffer)
    1617{
    17   int rc, slash;
    18   size_t len;
    19   char *tmp;
    20 
    21   /* If there is a trailing slash or backslash, remove it and set
    22      `slash' to true.  Make a local copy of the string to remove the
    23      slash or backslash. */
    24 
    25   len = strlen (name);
    26   slash = _trslash (name, len, 1);
    27   if (slash)
    28     {
    29       tmp = alloca (len);
    30       memcpy (tmp, name, len - 1);
    31       tmp[len-1] = 0;
    32       name = tmp;
    33     }
    34   rc = __stat (name, buffer);
     18  int rc = __libc_Back_fsFileStat (name, buffer);
    3519  if (rc == 0)
    3620    {
    37       if (slash && ((buffer->st_mode & S_IFMT) != S_IFDIR))
    38         {
    39           errno = ENOTDIR;
    40           return -1;
    41         }
    42       if (!_tzset_flag) tzset ();
     21      if (!_tzset_flag)
     22        tzset ();
    4323      _loc2gmt (&buffer->st_atime, -1);
    4424      _loc2gmt (&buffer->st_mtime, -1);
    4525      _loc2gmt (&buffer->st_ctime, -1);
    46       if ((buffer->st_mode & S_IFMT) == S_IFREG)
     26      if ((buffer->st_mode & (S_IFMT | ((S_IEXEC >> 6) * 0111))) == S_IFREG)
    4727        {
    48           tmp = _getext (name);
     28          const char *tmp = _getext (name);
    4929          if (tmp != NULL &&
    5030              (stricmp (tmp, ".exe") == 0 ||
     
    5535        }
    5636    }
     37  else
     38    {
     39      errno = -rc;
     40      rc = -1;
     41    }
    5742  return rc;
    5843}
  • trunk/src/emx/src/lib/io/sync.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/io/tell.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    55#include <errno.h>
    66#include <emx/io.h>
    7 #include <emx/syscalls.h>
     7#include <InnoTekLIBC/backend.h>
    88
    99off_t _STD(tell)(int handle)
     
    1414    pFH = __libc_FH(handle);
    1515    if (!pFH)
     16        return -1;
     17    n = __libc_Back_ioSeek(handle, 0L, SEEK_CUR);
     18    if (n >= 0)
    1619    {
    17         errno = EBADF;
    18         return -1;
     20        if (pFH->iLookAhead >= 0 || (pFH->fFlags & F_EOF))
     21            --n;
     22        return n;
    1923    }
    20     n = __lseek(handle, 0L, SEEK_CUR);
    21     if (n == -1)
    22         return n;
    23     if (pFH->iLookAhead >= 0 || (pFH->fFlags & F_EOF))
    24         --n;
    25     return n;
     24    errno = -n;
     25    return -1;
    2626}
  • trunk/src/emx/src/lib/io/write.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    99#include <emx/io.h>
    1010#include <emx/syscalls.h>
     11#include <InnoTekLIBC/backend.h>
    1112
    1213#define CTRL_Z 0x1a
     
    122123      else
    123124        {
    124           off_t pos;
    125           int saved_errno;
    126 
    127           saved_errno = errno;
    128           pos = __lseek (handle, -1, SEEK_CUR);
    129           if (pos != -1)
    130             __ftruncate (handle, pos);
    131           errno = saved_errno;
     125          off_t pos = __libc_Back_ioSeek (handle, -1, SEEK_CUR);
     126          if (pos >= 0)
     127            __libc_Back_ioFileSizeSet (handle, pos, 0);
    132128        }
    133129    }
     
    149145  pFH = __libc_FH(handle);
    150146  if (!pFH)
    151   {
    152       errno = EBADF;
    153147      return -1;
    154   }
    155148
    156149  if ((pFH->fFlags & (__LIBC_FH_TYPEMASK | O_APPEND)) == (O_APPEND | F_FILE))
    157     __lseek (handle, 0, SEEK_END);
     150    __libc_Back_ioSeek (handle, 0, SEEK_END);
    158151  if (nbyte == 0)                 /* Avoid truncation of file */
    159152    return 0;
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.64 to 1.65
    r1518 r1519  
    204204    "___buf_init" @226
    205205    "___call_hash" @227
    206     "___chdir" @228
     206    "___libc_Back_fsDirCurrentSet" @228
    207207    "___chmod" @229
    208     "___chsize" @230
     208    "___libc_Back_ioFileSizeSet" @230
    209209    "___close" @231
    210210    "___collate_range_cmp" @232
     
    232232    "___fpclassifyl" @254
    233233    "___free_ovflpage" @255
    234     "___fstat" @256
     234    "___libc_FHEx" @256
    235235    "___ftime" @257
    236     "___ftruncate" @258
     236    "___libc_Back_fsSymlinkStat" @258
    237237    "___get_buf" @259
    238238    "___get_page" @260
    239     "___getcwd" @261
     239    "___libc_Back_fsDirCurrentGet" @261
    240240    "__std_chroot" @262
    241241    "___hash_open" @263
     
    304304    "___libc_TranslateCodepage" @326
    305305    "___log2" @327
    306     "___lseek" @328
     306    "___libc_Back_ioSeek" @328
    307307    "___mempcpy" @329
    308     "___mkdir" @330
    309     "___open" @331
     308    "___libc_Back_fsDirCreate" @330
     309    "___libc_Back_ioFileOpen" @331
    310310    "___ovfl_delete" @332
    311311    "___ovfl_get" @333
     
    334334    "___reclaim_buf" @356
    335335    "___remove_zeros" @357
    336     "___rmdir" @358
     336    "___libc_Back_fsDirRemove" @358
    337337    "___select" @359
    338338    "___settime" @360
     
    346346    "___spawnve" @368
    347347    "___split_page" @369
    348     "___stat" @370
     348    "___libc_Back_fsFileStat" @370
    349349    "___strndup" @371
    350350    "___strnlen" @372
     
    593593    "__std_cfsetspeed" @615
    594594    "__std_chdir" @616
    595     "__std_chdrive" @617
     595    "__chdrive" @617
    596596    "__std_chmod" @618
    597597    "__std_chsize" @619
     
    11201120    "___libc_SpmCheck" @1140
    11211121    "___libc_Back_miscLoadAvg" @1141
    1122     "___libc_Back_fhToPath" @1142
     1122    "___libc_Back_fsFileStatFH" @1142
    11231123    "___libc_Back_fsStat" @1143
    11241124    "___libc_Back_fsStatFH" @1144
     
    11771177    "___libc_OS2ErrorSet" @1197
    11781178    "__getdcwd" @1198
    1179     "___libc_Back_fsChRoot" @1202
     1179    "___libc_Back_fsDirChangeRoot" @1199
     1180    "___libc_Back_fsSymlinkCreate" @1200
     1181    "___libc_Back_fsSymlinkRead" @1201
     1182    "___libc_Back_ioFHToPath" @1202
    11801183    "__std_getdtablesize" @1203
    11811184    "_strmode" @1204
    11821185    "___strverscmp" @1205
    1183     "___libc_timebomb" @1206
     1186    "__getcwdux" @1206
     1187    "___libc_Back_fsPathResolve" @1207
     1188    "__std_canonicalize_file_name" @1208
     1189    "___libc_Back_fsChRoot" @1209
     1190    "___libc_Back_fsDriveDefaultGet" @1210
     1191    "___libc_Back_fsDriveDefaultSet" @1211
  • trunk/src/emx/src/lib/locale/__convcp.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/__do_uni.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/__from_ucs.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/__to_ucs.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/isxxx.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1515 *
    1616 * InnoTek LIBC is free software; you can redistribute it and/or modify
    17  * it under the terms of the GNU General Public License as published by
    18  * the Free Software Foundation; either version 2 of the License, or
     17 * it under the terms of the GNU Lesser General Public License as published
     18 * by the Free Software Foundation; either version 2 of the License, or
    1919 * (at your option) any later version.
    2020 *
     
    2222 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2323 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    24  * GNU General Public License for more details.
     24 * GNU Lesser General Public License for more details.
    2525 *
    26  * You should have received a copy of the GNU General Public License
     26 * You should have received a copy of the GNU Lesser General Public License
    2727 * along with InnoTek LIBC; if not, write to the Free Software
    2828 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/locale_collate.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/locale_ctype.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1518 r1519  
    1111 *
    1212 * InnoTek LIBC is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
    1515 * (at your option) any later version.
    1616 *
     
    1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
    21  *
    22  * You should have received a copy of the GNU General Public License
     20 * GNU Lesser General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU Lesser General Public License
    2323 * along with InnoTek LIBC; if not, write to the Free Software
    2424 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/locale_ctype_default.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/locale_lconv.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/locale_time.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/localeconv.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/locale/setlocale.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1414 *
    1515 * InnoTek LIBC is free software; you can redistribute it and/or modify
    16  * it under the terms of the GNU General Public License as published by
    17  * the Free Software Foundation; either version 2 of the License, or
     16 * it under the terms of the GNU Lesser General Public License as published
     17 * by the Free Software Foundation; either version 2 of the License, or
    1818 * (at your option) any later version.
    1919 *
     
    2121 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2222 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  * GNU General Public License for more details.
    24  *
    25  * You should have received a copy of the GNU General Public License
     23 * GNU Lesser General Public License for more details.
     24 *
     25 * You should have received a copy of the GNU Lesser General Public License
    2626 * along with InnoTek LIBC; if not, write to the Free Software
    2727 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/malloc/_heapvoting.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    44 * Voting on default heap in High or Low memory.
    55 *
    6  *
    76 * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
    87 *
    98 *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License as published by
    12  * the Free Software Foundation; either version 2 of the License, or
     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
    1314 * (at your option) any later version.
    1415 *
    15  * This program is distributed in the hope that it will be useful,
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
    1617 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1718 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    1920 *
    20  * You should have received a copy of the GNU General Public License
    21  * along with This program; if not, write to the Free Software
     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
    2223 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2324 *
  • trunk/src/emx/src/lib/malloc/_hinitheap.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    77 *
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
     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
    1214 * (at your option) any later version.
    1315 *
    14  * This program is distributed in the hope that it will be useful,
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
    1517 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    1820 *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program; if not, write to the Free Software
     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
    2123 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2224 *
    23 
    2425 */
    2526
  • trunk/src/emx/src/lib/malloc/_linitheap.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    77 *
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
     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
    1214 * (at your option) any later version.
    1315 *
    14  * This program is distributed in the hope that it will be useful,
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
    1517 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    1820 *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program; if not, write to the Free Software
     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
    2123 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2224 *
    23 
    2425 */
    2526
  • trunk/src/emx/src/lib/malloc/posix_memalign.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    77 *
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
     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
    1214 * (at your option) any later version.
    1315 *
    14  * This program is distributed in the hope that it will be useful,
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
    1517 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    1820 *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program; if not, write to the Free Software
     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
    2123 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2224 *
  • trunk/src/emx/src/lib/misc/_getdcwd.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3535#include <sys/param.h>
    3636#include <emx/syscalls.h>
    37 #include <InnoTekLIBC/libc.h>
     37#include <InnoTekLIBC/backend.h>
    3838#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
    3939#include <InnoTekLIBC/logstrict.h>
    4040
    4141
    42 char * _getdcwd(int chDrive, char *pszBuffer, int cchBuffer)
     42/**
     43 * Gets the full path of the current directory of a specific drive.
     44 *
     45 * @returns pszBuffer or pointer to an malloc'ed buffer containing the requested path.
     46 * @returns NULL and errno on failure.
     47 * @param   iDrive      Which drive to get the current directory of. This is 1-based,
     48 *                      meaning that A is 1, B is 2, and so on. 0 will return the
     49 *                      current directory of the current drive (which can be the unix root!).
     50 * @param   pszBuffer   Where to store the current directory of the drive.
     51 *                      If NULL a buffer will be malloc'ed. The size of the malloc'ed
     52 *                      buffer will be cchBuffer and if cchBuffer is 0 it will be
     53 *                      as big as necessary.
     54 * @param   cchBuffer   Size of the buffer.
     55 */
     56char *_getdcwd(int iDrive, char *pszBuffer, int cchBuffer)
    4357{
    44     LIBCLOG_ENTER("chDrive=%d pszBuffer=%p cchBuffer=%d\n", chDrive, (void *)pszBuffer, cchBuffer);
    45     char szTmp[MAXPATHLEN+1];
    46     int len;
     58    LIBCLOG_ENTER("iDrive=%d pszBuffer=%p cchBuffer=%d\n", iDrive, (void *)pszBuffer, cchBuffer);
     59    char chDrive = iDrive ? iDrive + 'A' - 1 : 0;
    4760
    48     if (pszBuffer != NULL && cchBuffer <= 0)
     61    int rc;
     62    if (!pszBuffer)
    4963    {
    50         errno = EINVAL;
    51         LIBCLOG_RETURN_P(NULL);
    52     }
    53     if (__getcwd(szTmp, chDrive + 'A' - 1) < 0)
    54         return NULL;
    55     len = strlen(szTmp) + 4;
    56     if (pszBuffer != NULL)
    57     {
    58         if (len > cchBuffer)
     64        LIBCLOG_MSG("Allocating buffer, %d bytes.\n", cchBuffer ? cchBuffer : PATH_MAX);
     65        size_t cch = cchBuffer ? cchBuffer : PATH_MAX;
     66        pszBuffer = malloc(cch);
     67        if (pszBuffer)
    5968        {
    60             errno = ERANGE;
    61             LIBCLOG_RETURN_P(NULL);
     69            rc = __libc_Back_fsDirCurrentGet(pszBuffer, cchBuffer, chDrive, 0);
     70            if (!rc)
     71            {
     72                /*
     73                 * Reallocate a PATH_MAX buffer before we return.
     74                 */
     75                if (!cchBuffer)
     76                {
     77                    char *pvOld = pszBuffer;
     78                    cch = strlen(pszBuffer) + 1;
     79                    pszBuffer = realloc(pszBuffer, cch > cchBuffer ? cch : cchBuffer);
     80                    if (!pszBuffer)
     81                        pszBuffer = pvOld;
     82                }
     83                LIBCLOG_RETURN_MSG(pszBuffer, "ret %p:{%s}\n", (void *)pszBuffer, pszBuffer);
     84            }
     85            free(pszBuffer);
    6286        }
     87        else
     88            rc = -ENOMEM;
    6389    }
    6490    else
    6591    {
    66         if (len > cchBuffer)
    67             cchBuffer = len;
    68         pszBuffer = malloc(cchBuffer);
    69         if (pszBuffer == NULL)
    70         {
    71             errno = ENOMEM;
    72             LIBCLOG_RETURN_P(NULL);
    73         }
     92        rc = __libc_Back_fsDirCurrentGet(pszBuffer, cchBuffer, chDrive, 0);
     93        if (!rc)
     94            LIBCLOG_RETURN_MSG(pszBuffer, "ret %p:{%s}\n", (void *)pszBuffer, pszBuffer);
    7495    }
    75     if (!__libc_gfNoUnix)
    76     {
    77         _fnslashify(szTmp);
    78         pszBuffer[0] = chDrive ? chDrive + 'A' - 1: _getdrive();
    79         pszBuffer[1] = ':';
    80         pszBuffer[2] = '/';
    81         memcpy(pszBuffer+3, szTmp, len - 3);
    82     }
    83     else
    84     {
    85         pszBuffer[0] = chDrive ? chDrive + 'A' - 1: _getdrive();
    86         pszBuffer[1] = ':';
    87         pszBuffer[2] = '\\';
    88         memcpy(pszBuffer+3, szTmp, len - 3);
    89     }
    90     LIBCLOG_RETURN_MSG(pszBuffer, "ret %p:{%s}\n", (void *)pszBuffer, pszBuffer);
     96
     97    errno = -rc;
     98    LIBCLOG_RETURN_P(NULL);
    9199}
    92100
  • trunk/src/emx/src/lib/misc/abspath.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1010#include <InnoTekLIBC/libc.h>
    1111#include <InnoTekLIBC/locale.h>
     12#include <InnoTekLIBC/backend.h>
    1213
    1314#define FALSE   0
     
    4041        }
    4142    }
    42   else if (__getcwd (dir, drive) == 0)
     43  else if (__libc_Back_fsDirCurrentGet (dir, sizeof(dir), src_drive, __LIBC_BACK_FSCWD_NO_DRIVE | __LIBC_BACK_FSCWD_NO_ROOT_SLASH) == 0)
    4344    {
    4445      if (!__libc_gfNoUnix)
  • trunk/src/emx/src/lib/misc/chdir.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1 /* chdir.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * chdir.
     5 *
     6 * Copyright (c) 2004 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*   Header Files                                                               *
     29*******************************************************************************/
    330#include "libc-alias.h"
    4 #include <stdlib.h>
    5 #include <string.h>
    6 #include <emx/io.h>
    7 #include <emx/syscalls.h>
     31#include <errno.h>
     32#include <InnoTekLIBC/backend.h>
     33#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     34#include <InnoTekLIBC/logstrict.h>
    835
    9 int _STD(chdir) (const char *name)
     36/**
     37 * Changes the current directory.
     38 *
     39 * @returns 0 on success.
     40 * @returns -1 and errno on failure.
     41 * @param   path    Path to the new current directory.
     42 */
     43int _STD(chdir)(const char *path)
    1044{
    11   size_t len;
    12   char *tmp;
    13 
    14   len = strlen (name);
    15   if (_trslash (name, len, 1))
    16     {
    17       tmp = alloca (len);
    18       memcpy (tmp, name, len - 1);
    19       tmp[len-1] = 0;
    20       name = tmp;
    21     }
    22   return __chdir (name);
     45    LIBCLOG_ENTER("path=%p:{%s}\n", (void *)path, path);
     46    int rc = __libc_Back_fsDirCurrentSet(path);
     47    if (!rc)
     48        LIBCLOG_RETURN_INT(0);
     49    errno = -rc;
     50    LIBCLOG_RETURN_INT(-1);
    2351}
  • trunk/src/emx/src/lib/misc/chdir2.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1518 r1519  
    66#include <emx/io.h>
    77#include <emx/syscalls.h>
     8#include <InnoTekLIBC/backend.h>
    89
    910int _chdir2 (const char *name)
    1011{
    11   char old_drive, new_drive, *tmp;
    12   size_t len;
    13   int saved_errno;
     12  char old_drive, new_drive;
    1413
    15   len = strlen (name);
    16   if (_trslash (name, len, 1))
    17     {
    18       tmp = alloca (len);
    19       memcpy (tmp, name, len - 1);
    20       tmp[len-1] = 0;
    21       name = tmp;
    22     }
    2314  old_drive = _getdrive ();
    2415  new_drive = _fngetdrive (name);
     
    3021        return 0;
    3122    }
    32   if (__chdir (name) == 0)
     23  int rc = __libc_Back_fsDirCurrentSet (name);
     24  if (rc == 0)
    3325    return 0;
    3426  else
    3527    {
    36       saved_errno = errno;
    3728      _chdrive (old_drive);
    38       errno = saved_errno;
     29      errno = -rc;
    3930      return -1;
    4031    }
  • trunk/src/emx/src/lib/misc/chroot.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3131#include "libc-alias.h"
    3232#include <unistd.h>
     33#include <errno.h>
    3334#include <InnoTekLIBC/backend.h>
    3435#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     
    5859{
    5960    LIBCLOG_ENTER("pszNewRoot=%p:{%s}\n", (void *)pszNewRoot, pszNewRoot);
    60     int rc = __libc_Back_fsChRoot(pszNewRoot);
    61     LIBCLOG_RETURN_INT(rc);
     61    int rc = __libc_Back_fsDirChangeRoot(pszNewRoot);
     62    if (!rc)
     63        LIBCLOG_RETURN_INT(0);
     64    errno = -rc;
     65    LIBCLOG_RETURN_INT(-1);
    6266}
  • trunk/src/emx/src/lib/misc/fstatfs.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3030*******************************************************************************/
    3131#include "libc-alias.h"
     32#include <errno.h>
    3233#include <sys/types.h>
    3334#include <sys/mount.h>
     
    5152    LIBCLOG_ENTER("fh=%d buf=%p\n", fh, (void *)buf);
    5253    int rc = __libc_Back_fsStatFH(fh, buf);
    53     LIBCLOG_RETURN_INT(rc);
     54    if (!rc)
     55        LIBCLOG_RETURN_INT(0);
     56    errno = -rc;
     57    LIBCLOG_RETURN_INT(-1);
    5458}
    5559
  • trunk/src/emx/src/lib/misc/fullpath.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    22
    33#include "libc-alias.h"
     4#include <direct.h>
    45#include <stdio.h>
    56#include <stdlib.h>
     
    1415{
    1516  char drive, cwd1[MAXPATHLEN+1], cwd2[MAXPATHLEN+1];
    16   char *temp, c;
    17   int i, j, k, add_file;
     17  char *temp = NULL, c, *r;
     18  int j, k, add_file;
    1819
     20  /* drive stuff. */
    1921  drive = _fngetdrive (src);
    2022  if (drive == 0)
     
    2224  else
    2325    src += 2;
    24   i = strlen (src);
    25   temp = (char *)alloca (i+2+1);
    26   temp[0] = drive; temp[1] = ':';
    27   strcpy (temp+2, src);
    28   cwd1[0] = cwd2[0] = drive;
    29   cwd1[1] = cwd2[1] = ':';
    30   cwd1[2] = cwd2[2] = !__libc_gfNoUnix ? '/' : '\\';
    31   if (__getcwd (cwd1+3, drive) != 0)
    32     goto failure;
     26
     27  /* save the cwd of the drive */
     28  if (!_getdcwd(drive - 'A' + 1, cwd1, sizeof(cwd1)))
     29    goto failure2;
     30
     31  /* try change to the specified path. */
    3332  add_file = 0; k = 0;
    34   if (_chdir (temp) != 0)
     33  if (chdir (src) != 0)
    3534    {
     35      int i = strlen (src);
     36      temp = (char *)alloca (i+2+1);
     37      temp[0] = drive; temp[1] = ':';
     38      strcpy (temp+2, src);
     39
    3640      k = _getname (temp) - temp;
    3741      if (k == 3)
    3842        {
    39           c = temp[k]; temp[k] = 0;
    40           if (_chdir (temp) != 0)
     43          c = temp[k];
     44          temp[k] = '\0';
     45          if (chdir (temp) != 0)
    4146            goto failure;
    4247          temp[k] = c;
     
    4449      else if (k > 3)
    4550        {
    46           temp[k-1] = 0;
    47           if (_chdir (temp) != 0)
     51          temp[k-1] = '\0';
     52          if (chdir (temp) != 0)
    4853            goto failure;
    4954        }
    5055      add_file = 1;
    5156    }
    52   j = __getcwd (cwd2+3, drive);
    53   if (_chdir (cwd1) != 0 || j != 0)
     57
     58  /* get the changed path. */
     59  r = _getdcwd(drive - 'A' + 1, cwd2, sizeof(cwd2));
     60  if (_chdir (cwd1) != 0 || r == NULL)
    5461    goto failure;
     62
    5563  if (strlen (cwd2)+1 > size)
    56     {
    57       errno = ERANGE;
     64  {
     65      errno = -ERANGE;
    5866      goto failure;
    59     }
     67  }
    6068  strcpy (dst, cwd2);
    6169  if (add_file && temp[k] != 0)
     
    6371      j = strlen (dst);
    6472      if (j+1+strlen (temp+k)+1 > size)
    65         {
    66           errno = ERANGE;
     73      {
     74          errno = -ERANGE;
    6775          goto failure;
    68         }
     76      }
    6977      if (!_trslash (dst, j, 0))
    7078        dst[j++] = !__libc_gfNoUnix ? '/' : '\\';
    7179      strcpy (dst+j, temp+k);
    7280    }
     81
    7382  if (!__libc_gfNoUnix)
    7483    _fnslashify (dst);
     
    7685
    7786failure:
    78   dst[0] = 0;
     87  chdir(cwd1);
     88failure2:
     89  dst[0] = '\0';
    7990  return -1;
    8091}
  • trunk/src/emx/src/lib/misc/getcwd.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1 /* getcwd.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * getcwd().
     5 *
     6 * Copyright (c) 2004 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*   Header Files                                                               *
     29*******************************************************************************/
    330#include "libc-alias.h"
     31#include <unistd.h>
    432#include <stdlib.h>
     33#include <errno.h>
    534#include <string.h>
    6 #include <errno.h>
    7 #include <sys/param.h>
    8 #include <emx/syscalls.h>
    9 #include <InnoTekLIBC/libc.h>
     35#include <InnoTekLIBC/backend.h>
    1036#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
    1137#include <InnoTekLIBC/logstrict.h>
    1238
    13 char *_STD(getcwd)(char *buffer, size_t size)
     39
     40/**
     41 * Gets the current directory of the process.
     42 *
     43 * What getcwd() returns depends on the mode of the process. It will always be an
     44 * absolute path as the specs says. Which means that it (now) includes a drive letter
     45 * unless we're inside the unix compartment. Slashes are leaning the DOS way if the
     46 * application was linked with the -Zno-unix option, else UNIX slashes are used.
     47 *
     48 * @returns buf on success.
     49 * @returns NULL and errno on failure.
     50 * @param   buf     Where to store the current directory.
     51 *                  If NULL a buffer is malloc'ed. The size of a malloc'ed buffer is
     52 *                  bufsize unless that is 0 when it'll be allocated as big as necessary.
     53 * @param   bufsize Size of the buffer.
     54 * @remark  The EMX implementation of this interface did not return a driveletter.
     55 */
     56char *_STD(getcwd)(char *buf, size_t bufsize)
    1457{
    15     LIBCLOG_ENTER("buffer=%p size=%d\n", buffer, size);
    16     if (!__libc_gfNoUnix)
     58    LIBCLOG_ENTER("buf=%p bufsize=%d\n", (void *)buf, bufsize);
     59
     60    /*
     61     * For compatability with the GNU C library we must
     62     * handle buf == NULL.
     63     */
     64    int rc;
     65    if (!buf)
    1766    {
    18         char tmp[MAXPATHLEN+1];
    19         size_t len;
    20 
    21         if (buffer != NULL && size == 0)
     67        LIBCLOG_MSG("Allocating buffer, %d bytes.\n", bufsize ? bufsize : PATH_MAX);
     68        size_t cch = bufsize ? bufsize : PATH_MAX;
     69        buf = malloc(cch);
     70        if (buf)
    2271        {
    23             errno = EINVAL;
    24             LIBCLOG_RETURN_P(NULL);
    25         }
    26         if (__getcwd(tmp, 0) < 0)
    27             return NULL;
    28         len = strlen(tmp) + 2;
    29         if (buffer != NULL)
    30         {
    31             if (len > size)
     72            rc = __libc_Back_fsDirCurrentGet(buf, cch, 0, 0);
     73            if (!rc)
    3274            {
    33                 errno = ERANGE;
    34                 LIBCLOG_RETURN_P(NULL);
     75                /*
     76                 * Reallocate a PATH_MAX buffer before we return.
     77                 */
     78                if (!bufsize)
     79                {
     80                    char *pvOld = buf;
     81                    cch = strlen(buf) + 1;
     82                    buf = realloc(buf, cch > bufsize ? cch : bufsize);
     83                    if (!buf)
     84                        buf = pvOld;
     85                }
     86                LIBCLOG_RETURN_MSG(buf, "ret %p:{%s}\n", (void *)buf, buf);
    3587            }
     88            free(buf);
    3689        }
    3790        else
    38         {
    39             if (len > size)
    40                 size = len;
    41             buffer = malloc(size);
    42             if (buffer == NULL)
    43             {
    44                 errno = ENOMEM;
    45                 LIBCLOG_RETURN_P(NULL);
    46             }
    47         }
    48         _fnslashify(tmp);
    49         buffer[0] = '/';
    50         memcpy(buffer + 1, tmp, len - 1);
    51         LIBCLOG_RETURN_MSG(buffer, "ret %p:{%s}\n", (void *)buffer, buffer);
     91            rc = -ENOMEM;
    5292    }
    5393    else
    5494    {
    55         char *pszRet = _getcwd2(buffer, size);
    56         LIBCLOG_RETURN_P(pszRet);
     95        rc = __libc_Back_fsDirCurrentGet(buf, bufsize, 0, 0);
     96        if (!rc)
     97            LIBCLOG_RETURN_MSG(buf, "ret %p:{%s}\n", (void *)buf, buf);
    5798    }
     99
     100    errno = -rc;
     101    LIBCLOG_RETURN_INT(NULL);
    58102}
     103
  • trunk/src/emx/src/lib/misc/getcwd1.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    33#include "libc-alias.h"
    44#include <stdlib.h>
     5#include <string.h>
    56#include <emx/syscalls.h>
    6 #include <InnoTekLIBC/libc.h>
     7#include <InnoTekLIBC/backend.h>
    78#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
    89#include <InnoTekLIBC/logstrict.h>
    910
    10 int _getcwd1 (char *buffer, char drive)
     11int _getcwd1(char *buffer, char drive)
    1112{
    1213    LIBCLOG_ENTER("buffer=%p drive=%c\n", (void *)buffer, drive);
    13     if (__getcwd (buffer+1, drive) < 0)
    14         LIBCLOG_RETURN_INT(-1);
    15     if (!__libc_gfNoUnix)
    16     {
    17         _fnslashify(buffer+1);
    18         buffer[0] = '/';
    19     }
    20     else
    21         buffer[1] = '\\';
    22     LIBCLOG_RETURN_MSG(0, "ret 0 buffer=:{%s}\n", buffer);
     14
     15    int rc = __libc_Back_fsDirCurrentGet(buffer, PATH_MAX, drive, __LIBC_BACK_FSCWD_NO_DRIVE);
     16    if (!rc)
     17        LIBCLOG_RETURN_MSG(0, "ret 0 buffer=:{%s}\n", buffer);
     18
     19    errno = -rc;
     20    LIBCLOG_RETURN_INT(-1);
    2321}
  • trunk/src/emx/src/lib/misc/getcwd2.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    22
    33#include "libc-alias.h"
     4#include <unistd.h>
    45#include <stdlib.h>
    5 #include <string.h>
    6 #include <errno.h>
    7 #include <sys/param.h>
    8 #include <emx/syscalls.h>
    9 #include <InnoTekLIBC/libc.h>
    10 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
    11 #include <InnoTekLIBC/logstrict.h>
    126
     7/**
     8 * Obsolete.
     9 */
    1310char *_getcwd2 (char *buffer, int size)
    1411{
    15     LIBCLOG_ENTER("buffer=%p size=%d\n", (void *)buffer, size);
    16     char tmp[MAXPATHLEN+1];
    17     int len;
    18 
    19     if (buffer != NULL && size <= 0)
    20     {
    21         errno = EINVAL;
    22         LIBCLOG_RETURN_P(NULL);
    23     }
    24     if (__getcwd (tmp, 0) < 0)
    25         return NULL;
    26     len = strlen (tmp) + 4;
    27     if (buffer != NULL)
    28     {
    29         if (len > size)
    30         {
    31             errno = ERANGE;
    32             LIBCLOG_RETURN_P(NULL);
    33         }
    34     }
    35     else
    36     {
    37         if (len > size)
    38             size = len;
    39         buffer = malloc(size);
    40         if (buffer == NULL)
    41         {
    42             errno = ENOMEM;
    43             LIBCLOG_RETURN_P(NULL);
    44         }
    45     }
    46     if (!__libc_gfNoUnix)
    47     {
    48         _fnslashify(tmp);
    49         buffer[0] = _getdrive();
    50         buffer[1] = ':';
    51         buffer[2] = '/';
    52         memcpy(buffer+3, tmp, len - 3);
    53     }
    54     else
    55     {
    56         buffer[0] = _getdrive();
    57         buffer[1] = ':';
    58         buffer[2] = '\\';
    59         memcpy(buffer+3, tmp, len - 3);
    60     }
    61     LIBCLOG_RETURN_MSG(buffer, "ret %p:{%s}\n", (void *)buffer, buffer);
     12    return getcwd(buffer, size);
    6213}
  • trunk/src/emx/src/lib/misc/getdtablesize.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/misc/getfsstat.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    2929*******************************************************************************/
    3030#include "libc-alias.h"
     31#include <errno.h>
    3132#include <sys/types.h>
    3233#include <sys/mount.h>
     
    5253{
    5354    LIBCLOG_ENTER("buf=%p bufsize=%ld flags=%#x\n", (void *)buf, bufsize, flags);
    54 
    5555    int rc = __libc_Back_fsStats(buf, bufsize / sizeof(struct statfs), flags);
    56 
    57     LIBCLOG_RETURN_INT(rc);
     56    if (!rc)
     57        LIBCLOG_RETURN_INT(0);
     58    errno = -rc;
     59    LIBCLOG_RETURN_INT(-1);
    5860}
    5961
  • trunk/src/emx/src/lib/misc/getloadavg.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    6262    LIBCLOG_ENTER("loadavg=%p nelem=%d\n", (void *)loadavg, nelem);
    6363    int rc = __libc_Back_miscLoadAvg(loadavg, nelem);
    64     LIBCLOG_RETURN_INT(rc);
     64    if (!rc)
     65        LIBCLOG_RETURN_INT(0);
     66    errno = -rc;
     67    LIBCLOG_RETURN_INT(-1);
    6568}
    6669
  • trunk/src/emx/src/lib/misc/getwd.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    77#include <sys/param.h>
    88#include <emx/syscalls.h>
    9 #include <InnoTekLIBC/libc.h>
     9#include <InnoTekLIBC/backend.h>
    1010
    1111char *_STD(getwd) (char *buffer)
    1212{
    13   if (buffer == NULL)
     13  if (!buffer)
    1414    {
    1515      errno = EINVAL;
    1616      return NULL;
    1717    }
    18   if (__getcwd (buffer+1, 0) < 0)
     18  int rc = __libc_Back_fsDirCurrentGet(buffer, MAXPATHLEN, 0, 0);
     19  if (rc)
    1920    {
    20       _strncpy (buffer, strerror (errno), MAXPATHLEN);
     21      _strncpy (buffer, strerror (-rc), MAXPATHLEN);
     22      errno = -rc;
    2123      return NULL;
    2224    }
    23   if (!__libc_gfNoUnix)
    24     {
    25       _fnslashify (buffer+1);
    26       buffer[0] = '/';
    27     }
    28   else
    29     buffer[0] = '\\';
    30 
    3125  return buffer;
    3226}
  • trunk/src/emx/src/lib/misc/mkdir.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1 /* mkdir.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
    21
     2/*******************************************************************************
     3*   Header Files                                                               *
     4*******************************************************************************/
    35#include "libc-alias.h"
    46#include <stdlib.h>
    57#include <errno.h>
    68#include <emx/syscalls.h>
     9#include <InnoTekLIBC/backend.h>
     10#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     11#include <InnoTekLIBC/logstrict.h>
    712
    8 int _STD(mkdir) (const char *name, mode_t mode)
     13
     14/**
     15 * Creates a directory.
     16 *
     17 * @returns 0 on success.
     18 * @returns -1 and errno on failure.
     19 * @param   path    Path to the new directory.
     20 * @param   mode    Permissions.
     21 */
     22int _STD(mkdir)(const char *path, mode_t mode)
    923{
    10   mode = 0;                     /* Keep the compiler happy */
    11   if (__mkdir (name) == 0)
    12     return 0;
    13   else
    14     {
    15       if (errno == EACCES)
    16         errno = EEXIST;
    17       return -1;
    18     }
     24    LIBCLOG_ENTER("path=%p:{%s} mode=o%o\n", (void *)path, path, mode);
     25    int rc = __libc_Back_fsDirCreate(path, mode);
     26    if (!rc)
     27        LIBCLOG_RETURN_INT(0);
     28    errno = -rc;
     29    LIBCLOG_RETURN_INT(-1);
    1930}
     31
  • trunk/src/emx/src/lib/misc/realpath.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    3131#include "libc-alias.h"
    3232#include <stdlib.h>
     33#include <string.h>
     34#include <errno.h>
    3335#include <sys/syslimits.h>
     36#include <InnoTekLIBC/backend.h>
     37#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     38#include <InnoTekLIBC/logstrict.h>
    3439
     40
     41/**
     42 * Gets the absolute path.
     43 * The returned path contains no symlinks, '.', '..' or extra slashes.
     44 *
     45 * @returns Pointer to the resolved path.
     46 * @returns NULL and errno on failure.
     47 * @param   path            The path to resolve
     48 * @param   resolved_path   Where to put the resolved path.
     49 *                          If NULL a fitting buffer is malloc'ed.
     50 */
    3551char    *_STD(realpath)(const char *path, char resolved_path[])
    3652{
    37     /* _abspath should do a good enough job I hope... */
    38     if (_abspath(resolved_path, path, PATH_MAX))
    39         return NULL;
    40     return resolved_path;
     53    LIBCLOG_ENTER("path=%p:{%s} resolved_path=%p\n", (void *)path, path, resolved_path);
     54
     55    int rc;
     56    if (!resolved_path)
     57    {
     58        char *psz = malloc(PATH_MAX);
     59        if (psz)
     60        {
     61            rc = __libc_Back_fsPathResolve(path, psz, PATH_MAX, 0);
     62            if (!rc)
     63            {
     64                int cch = strlen(psz) + 1;
     65                char *pszOld = psz;
     66                psz = realloc(psz, cch);
     67                if (!psz)
     68                    psz = pszOld;
     69                LIBCLOG_RETURN_MSG(psz, "ret %p:{%s}\n", psz, psz);
     70            }
     71        }
     72        else
     73            rc = -ENOMEM;
     74        free(psz);
     75    }
     76    else
     77    {
     78        rc = __libc_Back_fsPathResolve(path, resolved_path, PATH_MAX, 0);
     79        if (!rc)
     80            LIBCLOG_RETURN_MSG(resolved_path, "ret %p:{%s}\n", resolved_path, resolved_path);
     81    }
     82
     83    errno = -rc;
     84    LIBCLOG_RETURN_P(NULL);
    4185}
    4286
  • trunk/src/emx/src/lib/misc/rmdir.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1 /* rmdir.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * rmdir.
     5 *
     6 * Copyright (c) 2004 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*   Header Files                                                               *
     29*******************************************************************************/
    330#include "libc-alias.h"
    4 #include <stdlib.h>
    531#include <errno.h>
    6 #include <emx/syscalls.h>
     32#include <InnoTekLIBC/backend.h>
     33#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MISC
     34#include <InnoTekLIBC/logstrict.h>
    735
    8 int _STD(rmdir) (const char *name)
     36
     37int _STD(rmdir)(const char *path)
    938{
    10   if (__rmdir (name) == 0)
    11     return 0;
    12   if (errno == EACCES)
    13     errno = ENOTEMPTY;
    14   return -1;
     39    LIBCLOG_ENTER("path=%p:{%s}\n", (void *)path, path);
     40    int rc = __libc_Back_fsDirRemove(path);
     41    if (!rc)
     42        LIBCLOG_RETURN_INT(0);
     43    errno = -rc;
     44    LIBCLOG_RETURN_INT(-1);
    1545}
  • trunk/src/emx/src/lib/misc/statfs.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3030*******************************************************************************/
    3131#include "libc-alias.h"
     32#include <errno.h>
    3233#include <sys/types.h>
    3334#include <sys/mount.h>
     
    5051    LIBCLOG_ENTER("path=%p:{%s} buf=%p\n", (void *)path, path, (void *)buf);
    5152    int rc = __libc_Back_fsStat(path, buf);
    52     LIBCLOG_RETURN_INT(rc);
     53    if (!rc)
     54        LIBCLOG_RETURN_INT(0);
     55    errno = -rc;
     56    LIBCLOG_RETURN_INT(-1);
    5357}
    5458
  • trunk/src/emx/src/lib/process/_atfork_callback.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    22/** @file
    33 *
    4  *
     4 * _atfork_callback().
    55 *
    66 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/process/thread_internals.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/process/tls.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    270270 *
    271271 * This is registered by the first call to __libc_TLSDestructor() and will
    272  * be called back on normal thread terminations. It's function is to iterate 
    273  * the registered TLS destructors and calling back the registered TLS 
     272 * be called back on normal thread terminations. It's function is to iterate
     273 * the registered TLS destructors and calling back the registered TLS
    274274 * destructors so they can perform proper per thread cleanups.
    275275 */
     
    299299                {
    300300                    /* iterate byte entry by entry. */
    301                     int k = i * sizeof(unsigned) * 8 + j * 8;   
    302                     int kEnd = k + 8;   
     301                    int k = i * sizeof(unsigned) * 8 + j * 8;
     302                    int kEnd = k + 8;
    303303                    while (k < kEnd)
    304304                    {
    305305                        void (*pfnDestructor)(void *, int, unsigned);
    306306                        void  *pvValue;
    307                         if (    __atomic_test_bit(&gauBitmap[0], k)   
     307                        if (    __atomic_test_bit(&gauBitmap[0], k)
    308308                            &&  k < __LIBC_TLS_MAX
    309309                            &&  (pvValue = pThrd->apvTLS[k]) != NULL
  • trunk/src/emx/src/lib/sys/386/__fork.s

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1111 *
    1212 * InnoTek LIBC is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
    1515 * (at your option) any later version.
    1616 *
     
    1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
     20 * GNU Lesser General Public License for more details.
    2121 *
    22  * You should have received a copy of the GNU General Public License
     22 * You should have received a copy of the GNU Lesser General Public License
    2323 * along with InnoTek LIBC; if not, write to the Free Software
    2424 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosAllocMemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1111 *
    1212 * InnoTek LIBC is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
    1515 * (at your option) any later version.
    1616 *
     
    1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
    21  *
    22  * You should have received a copy of the GNU General Public License
     20 * GNU Lesser General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU Lesser General Public License
    2323 * along with InnoTek LIBC; if not, write to the Free Software
    2424 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosAllocSharedMemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosCloseEventSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosCloseMutexSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosCreateEventSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosCreateMutexSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosEx.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosEx.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosFreeMemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosGetNamedSharedMemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosGetSharedMemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosOpenEventSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/DosOpenMutexSemEx.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/__chdir.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1 /* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2                          -- Copyright (c) 2003-2004 by knut st. osmundsen */
    3 
    4 #include "libc-alias.h"
    5 #define INCL_FSMACROS
    6 #include <os2emx.h>
    7 #include <stdlib.h>
    8 #include <errno.h>
    9 #include <emx/syscalls.h>
    10 #include "syscalls.h"
    11 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    12 #include <InnoTekLIBC/logstrict.h>
    13 #include <InnoTekLIBC/pathrewrite.h>
    14 
    15 
    16 int __chdir (const char *pszPath)
    17 {
    18     LIBCLOG_ENTER("pszPath=%s\n", pszPath);
    19     ULONG   rc;
    20     int     cch;
    21     FS_VAR();
    22 
    23     /*
    24      * Rewrite the specified file path.
    25      */
    26     cch = __libc_PathRewrite(pszPath, NULL, 0);
    27     if (cch > 0)
    28     {
    29         char *pszRewritten = alloca(cch);
    30         if (!pszRewritten)
    31         {
    32             errno = ENOMEM;
    33             LIBCLOG_RETURN_INT(-1);
    34         }
    35         cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
    36         if (cch > 0)
    37             pszPath = pszRewritten;
    38         /* else happens when someone changes the rules between the two calls. */
    39         else if (cch < 0)
    40         {
    41             errno = EAGAIN;             /* non-standard, I'm sure. */
    42             LIBCLOG_RETURN_INT(-1);
    43         }
    44     }
    45 
    46     /*
    47      * Change the current directory.
    48      */
    49     FS_SAVE_LOAD();
    50     rc = DosSetCurrentDir((PCSZ)pszPath);
    51     FS_RESTORE();
    52     if (rc != 0)
    53     {
    54         _sys_set_errno(rc);
    55         LIBCLOG_RETURN_INT(-1);
    56 
    57     }
    58     LIBCLOG_RETURN_INT(0);
    59 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__chsize.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1 /* sys/chsize.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    Copyright (c) 2003 Dimitry Froloff
    3    Copyright (c) 2003 knut st. osmundsen
    4  */
    5 
    6 #include "libc-alias.h"
    7 #define INCL_FSMACROS
    8 #define INCL_ERRORS
    9 #include <os2emx.h>
    10 #include <emx/syscalls.h>
    11 #include <emx/io.h>
    12 #include <limits.h>
    13 #include <errno.h>
    14 #include "syscalls.h"
    15 
    16 
    17 int __chsize(int fh, __off_t cbFile)
    18 {
    19     PLIBCFH     pFH;
    20     ULONG       rc;
    21 
    22     /*
    23      * Get filehandle.
    24      */
    25     pFH = __libc_FH(fh);
    26     if (!pFH)
    27     {
    28         errno = EBADF;
    29         return -1;
    30     }
    31 
    32     /*
    33      * Do the stuff.
    34      */
    35     if (!pFH->pOps)
    36     {
    37         FS_VAR();
    38         FS_SAVE_LOAD();
    39 #if OFF_MAX > LONG_MAX
    40         if (__pfnDosSetFileSizeL)
    41             rc = __pfnDosSetFileSizeL(fh, cbFile);
    42         else
    43         {
    44             if (cbFile > LONG_MAX)
    45             {
    46                 FS_RESTORE();
    47                 errno = EOVERFLOW;
    48                 return -1;
    49             }
    50             rc = DosSetFileSize(fh, cbFile);
    51         }
    52 #else
    53         rc = DosSetFileSize(fh, cbFile);
    54 #endif
    55         FS_RESTORE();
    56     }
    57     else
    58     {
    59         /** not supported for non native filehandles. */
    60         rc = ERROR_INVALID_FUNCTION;
    61     }
    62 
    63     /*
    64      * Done.
    65      */
    66     if (rc)
    67     {
    68         _sys_set_errno(rc);
    69         return -1;
    70     }
    71     return 0;
    72 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__fcntl.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    1111#define INCL_FSMACROS
    1212#include <os2emx.h>
     13#include "fs.h"
    1314#include <386/builtin.h>
    1415#include <emx/io.h>
     
    267268    FS_SAVE_LOAD();
    268269#if OFF_MAX > LONG_MAX
    269     if (__pfnDosOpenL)
     270    if (__libc_gpfnDosOpenL)
    270271    {
    271272        rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L));
     
    339340#if OFF_MAX > LONG_MAX
    340341        rc = ERROR_INVALID_PARAMETER;
    341         if (__pfnDosSetFileLocksL)
     342        if (__libc_gpfnDosSetFileLocksL)
    342343        {
    343344            FILELOCKL   aflock[2];
     
    346347            aflock[fLock].lRange  = cbRange;
    347348            FS_SAVE_LOAD();
    348             rc = __pfnDosSetFileLocksL(hFile, &aflock[0], &aflock[1], ulTimeout, fAccess);
     349            rc = __libc_gpfnDosSetFileLocksL(hFile, &aflock[0], &aflock[1], ulTimeout, fAccess);
    349350            FS_RESTORE();
    350351        }
  • trunk/src/emx/src/lib/sys/__fstat.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    1 /* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2  * sys/__fstat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
    3  */
    4 
    5 /*******************************************************************************
    6 *   Header Files                                                               *
    7 *******************************************************************************/
    8 #include "libc-alias.h"
    9 #define INCL_FSMACROS
    10 #include <os2emx.h>
    11 #include <string.h>
    12 #include <errno.h>
    13 #include <sys/types.h>
    14 #include <sys/stat.h>
    15 #include <emx/io.h>
    16 #include <emx/syscalls.h>
    17 #include <limits.h>
    18 #include "syscalls.h"
    19 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    20 #include <InnoTekLIBC/logstrict.h>
    21 
    22 int __fstat(int hFile, struct stat *pStat)
    23 {
    24     LIBCLOG_ENTER("hFile=%d pStat=%p\n", hFile, (void *)pStat);
    25     ULONG   rc;
    26     ULONG   ulType;
    27     ULONG   flFlags;
    28     PLIBCFH pFH;
    29     FS_VAR();
    30 
    31     /*
    32      * Get filehandle.
    33      */
    34     pFH = __libc_FH(hFile);
    35     if (!pFH)
    36     {
    37         errno = EBADF;
    38         LIBCLOG_RETURN_INT(-1);
    39     }
    40 
    41     if (!pFH->pOps)
    42     {
    43         /*
    44          * Use query handle type to figure out the file type.
    45          */
    46         bzero(pStat, sizeof(*pStat));
    47         rc = DosQueryHType(hFile, &ulType, &flFlags);
    48         if (rc)
    49         {
    50             FS_RESTORE();
    51             _sys_set_errno(rc);
    52             LIBCLOG_RETURN_INT(-1);
    53         }
    54         switch (pFH->fFlags & __LIBC_FH_TYPEMASK)
    55         {
    56             case F_DEV:     pStat->st_mode = S_IFCHR; break;
    57             case F_SOCKET:  pStat->st_mode = S_IFSOCK; break;
    58             case F_PIPE:    pStat->st_mode = S_IFSOCK/*??*/; break;
    59             default:
    60             case F_FILE:    pStat->st_mode = S_IFREG; break;
    61         }
    62 
    63         FS_SAVE_LOAD();
    64         if (pStat->st_mode == S_IFREG)
    65         {
    66             union
    67             {
    68                 FILESTATUS3     fsts3;
    69                 FILESTATUS3L    fsts3L;
    70             } info;
    71         #if OFF_MAX > LONG_MAX
    72             int     fLarge = 0;
    73         #endif
    74 
    75             /*
    76              * Get file info.
    77              */
    78 #if OFF_MAX > LONG_MAX
    79             if (__pfnDosOpenL)
    80             {
    81                 rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L));
    82                 fLarge = 1;
    83             }
    84             else
    85 #endif
    86                 rc = DosQueryFileInfo(hFile, FIL_STANDARD, &info, sizeof(info.fsts3));
    87             if (rc)
    88             {
    89                 FS_RESTORE();
    90                 _sys_set_errno (rc);
    91                 LIBCLOG_RETURN_INT(-1);
    92             }
    93 
    94             /*
    95              * Format stats struct.
    96              *      We know the info struct layouts!
    97              *      Only cbFile, cbFileAlloc and attrFile need be accessed
    98              *      using the specific structure.
    99              */
    100             /* Times: FAT might not return create and access time. */
    101             pStat->st_mtime = _sys_p2t(info.fsts3.ftimeLastWrite, info.fsts3.fdateLastWrite);
    102             if (    FTIMEZEROP(info.fsts3.ftimeCreation)
    103                 &&  FDATEZEROP(info.fsts3.fdateCreation))
    104                 pStat->st_ctime = pStat->st_mtime;
    105             else
    106                 pStat->st_ctime = _sys_p2t(info.fsts3.ftimeCreation, info.fsts3.fdateCreation);
    107             if (    FTIMEZEROP(info.fsts3.ftimeLastAccess)
    108                 &&  FDATEZEROP(info.fsts3.fdateLastAccess))
    109                 pStat->st_atime = pStat->st_mtime;
    110             else
    111                 pStat->st_atime = _sys_p2t(info.fsts3.ftimeLastAccess, info.fsts3.fdateLastAccess);
    112 
    113 #if OFF_MAX > LONG_MAX
    114             if (fLarge)
    115             {
    116                 pStat->st_size = info.fsts3L.cbFile;
    117                 pStat->st_blocks = info.fsts3L.cbFileAlloc / S_BLKSIZE;
    118                 rc = info.fsts3L.attrFile;
    119             }
    120             else
    121 #endif
    122             {
    123                 pStat->st_size = info.fsts3.cbFile;
    124                 pStat->st_blocks = info.fsts3.cbFileAlloc / S_BLKSIZE;
    125                 rc = info.fsts3.attrFile;
    126             }
    127             pStat->st_attr = rc;
    128             if (rc & FILE_READONLY)
    129                 pStat->st_mode |= (S_IREAD >> 6) * 0111;
    130             else
    131                 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111;
    132         }
    133         else
    134         {
    135             pStat->st_size = 0;
    136             rc = DosQueryFHState(hFile, &flFlags);
    137             if (rc)
    138             {
    139                 FS_RESTORE();
    140                 _sys_set_errno (rc);
    141                 LIBCLOG_RETURN_INT(-1);
    142             }
    143             if ((flFlags & 7) == OPEN_ACCESS_READONLY)
    144                 pStat->st_mode |= (S_IREAD >> 6) * 0111;
    145             else
    146                 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111;
    147         }
    148 
    149         /* default fake stuff */
    150         pStat->st_uid = 0;
    151         pStat->st_gid = 0;
    152         pStat->st_ino = _sys_ino++;
    153         if (_sys_ino == 0)
    154             _sys_ino = 1;
    155         pStat->st_dev = 0;
    156         pStat->st_rdev = 0;
    157         pStat->st_nlink = 1;
    158         pStat->st_blksize = 4096*48;
    159         FS_RESTORE();
    160     }
    161     else
    162     {
    163         /*
    164          * Non-standard handle - fail.
    165          */
    166         errno = EPERM;
    167         LIBCLOG_RETURN_INT(-1);
    168     }
    169 
    170     LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
    171     LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
    172     LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
    173     LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
    174     LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
    175     LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
    176     LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
    177     LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
    178     LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
    179     LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
    180     LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
    181     LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
    182     LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
    183     LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
    184     LIBCLOG_RETURN_INT(0);
    185 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__ftruncate.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1 /* sys/ftruncat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    Copyright (c) 2003 Dimitry Froloff
    3    Copyright (c) 2003 knut st. osmundsen
    4  */
    5 
    6 #include "libc-alias.h"
    7 #define INCL_FSMACROS
    8 #include <os2emx.h>
    9 #include <limits.h>
    10 #include <errno.h>
    11 #include <emx/io.h>
    12 #include <emx/syscalls.h>
    13 #include "syscalls.h"
    14 
    15 int __ftruncate(int hFile, off_t cbFile)
    16 {
    17     ULONG       rc;
    18     PLIBCFH     pFH;
    19 
    20     /*
    21      * Get filehandle.
    22      */
    23     pFH = __libc_FH(hFile);
    24     if (!pFH)
    25     {
    26         errno = EBADF;
    27         return -1;
    28     }
    29 
    30     if (!pFH->pOps)
    31     {
    32         /*
    33          * Standard OS/2 file handle.
    34          */
    35         off_t       cbCur;
    36         union
    37         {
    38             FILESTATUS3     fsts3;
    39             FILESTATUS3L    fsts3L;
    40         } info;
    41         FS_VAR();
    42 
    43         /*
    44          * First step, figure out the current size.
    45          */
    46         FS_SAVE_LOAD();
    47 #if OFF_MAX > LONG_MAX
    48         if (__pfnDosOpenL)
    49         {
    50             rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &info, sizeof(info.fsts3L));
    51             cbCur = info.fsts3L.cbFile;
    52         }
    53         else
    54 #endif
    55         {
    56             rc = DosQueryFileInfo(hFile, FIL_STANDARD, &info, sizeof(info.fsts3));
    57             cbCur = info.fsts3.cbFile;
    58         }
    59         FS_RESTORE();
    60         if (rc)
    61         {
    62             _sys_set_errno(rc);
    63             return -1;
    64         }
    65 
    66 
    67         /*
    68          * Is the file larger than the truncation size?
    69          * Then set the desired file size.
    70          */
    71         if (cbCur > cbFile)
    72         {
    73             FS_SAVE_LOAD();
    74 #if OFF_MAX > LONG_MAX
    75             if (__pfnDosSetFileSizeL)
    76                 rc = __pfnDosSetFileSizeL(hFile, cbFile);
    77             else
    78             {
    79                 if (cbFile > __LONG_MAX)
    80                 {
    81                     FS_RESTORE();
    82                     errno = EOVERFLOW;
    83                     return -1;
    84                 }
    85                 rc = DosSetFileSize(hFile, cbFile);
    86             }
    87 #else
    88             rc = DosSetFileSize(hFile, cbFile);
    89 #endif
    90             FS_RESTORE();
    91             if (rc != 0)
    92             {
    93                 _sys_set_errno(rc);
    94                 return -1;
    95             }
    96         }
    97     }
    98     else
    99     {
    100         /*
    101          * Non-standard file handle - fail.
    102          */
    103         errno = EPERM;
    104         return -1;
    105     }
    106     return 0;
    107 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__getcwd.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1 /* sys/getcwd.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
    2 
    3 #include "libc-alias.h"
    4 #define INCL_FSMACROS
    5 #include <os2emx.h>
    6 #include <emx/syscalls.h>
    7 #include "syscalls.h"
    8 
    9 int __getcwd (char *buffer, char drive)
    10 {
    11   ULONG rc;
    12   ULONG size;
    13   FS_VAR();
    14 
    15   if (drive != 0)
    16     drive -= 'A' - 1;
    17   size = CCHMAXPATH;
    18   FS_SAVE_LOAD();
    19   rc = DosQueryCurrentDir (drive, buffer, &size);
    20   FS_RESTORE();
    21   if (rc != 0)
    22     {
    23       _sys_set_errno (rc);
    24       return -1;
    25     }
    26   return 0;
    27 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__initdll.c

    • Property cvs2svn:cvs-rev changed from 1.14 to 1.15
    r1518 r1519  
    3434#include <InnoTekLIBC/fork.h>
    3535#include "syscalls.h"
     36#include "fs.h"
    3637#include <InnoTekLIBC/thread.h>
    3738#include <InnoTekLIBC/libc.h>
     
    181182
    182183    /*
    183      * Init long file I/O functions.
    184      * This is weak, so that it's only linked in when we're building with
    185      * large file support enabled.
    186      */
    187     if (_sys_init_largefileio)
    188         _sys_init_largefileio();
     184     * Init the file system departement.
     185     */
     186    if (__libc_back_fsInit())
     187    {
     188        LIBC_ASSERTM_FAILED("__libc_back_fsInit() failed\n");
     189        return -1;
     190    }
    189191
    190192    /*
  • trunk/src/emx/src/lib/sys/__lseek.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1518 r1519  
    1 /* sys/lseek.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    Copyright (c) 2003 Dimitry Froloff
    3    Copyright (c) 2003 knut st. osmundsen
    4  */
    5 
    6 #include "libc-alias.h"
    7 #define INCL_FSMACROS
    8 #include <os2emx.h>
    9 #include <limits.h>
    10 #include <errno.h>
    11 #include <emx/io.h>
    12 #include <emx/syscalls.h>
    13 #include "syscalls.h"
    14 
    15 off_t __lseek(int hFile, off_t off, int origin)
    16 {
    17     ULONG   rc;
    18     PLIBCFH pFH;
    19     off_t   cbNew;
    20     FS_VAR();
    21 
    22     /*
    23      * Get filehandle / validate input.
    24      */
    25     pFH = __libc_FH(hFile);
    26     if (!pFH)
    27     {
    28         errno = EBADF;
    29         return -1;
    30     }
    31     if (origin == FILE_SECTOR)
    32     {
    33         errno = EINVAL;
    34         return -1;
    35     }
    36 
    37     if (!pFH->pOps)
    38     {
    39         /*
    40          * Standard OS/2 filehandle.
    41          */
    42         FS_SAVE_LOAD();
    43 #if OFF_MAX > LONG_MAX
    44         if (__pfnDosSetFilePtrL)
    45         {
    46             LONGLONG cbNewTmp;
    47             rc = __pfnDosSetFilePtrL(hFile, off, origin, &cbNewTmp);
    48             cbNew = cbNewTmp;
    49         }
    50         else
    51         {
    52             ULONG cbNewTmp;
    53             if (off > LONG_MAX || off < LONG_MIN)
    54             {
    55                 FS_RESTORE();
    56                 errno = EOVERFLOW;
    57                 return -1;
    58             }
    59             rc = DosSetFilePtr(hFile, off, origin, &cbNewTmp);
    60             cbNew = cbNewTmp;
    61         }
    62 #else
    63         {
    64             ULONG cbNewTmp;
    65             rc = DosSetFilePtr(hFile, off, origin, &cbNewTmp);
    66             cbNew = cbNewTmp;
    67         }
    68 #endif
    69         FS_RESTORE();
    70 
    71         if (rc)
    72         {
    73             _sys_set_errno (rc);
    74             return -1;
    75         }
    76     }
    77     else
    78     {
    79         /*
    80          * Non-standard filehandle - fail.
    81          */
    82         errno = EOPNOTSUPP;
    83         return -1;
    84     }
    85 
    86     return cbNew;
    87 }
    88 
     1/* dead */
  • trunk/src/emx/src/lib/sys/__mkdir.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1 /* sys/mkdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2                          -- Copyright (c) 2003-2004 by knut st. osmundsen */
    3 
    4 #include "libc-alias.h"
    5 #define INCL_FSMACROS
    6 #include <os2emx.h>
    7 #include <stdlib.h>
    8 #include <string.h>
    9 #include <errno.h>
    10 #include <emx/syscalls.h>
    11 #include "syscalls.h"
    12 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    13 #include <InnoTekLIBC/logstrict.h>
    14 #include <InnoTekLIBC/pathrewrite.h>
    15 
    16 
    17 int __mkdir(const char *pszPath)
    18 {
    19     LIBCLOG_ENTER("pszPath=%s\n", pszPath);
    20     ULONG   rc;
    21     int     cch;
    22     char    ch;
    23     FS_VAR();
    24 
    25     /*
    26      * Rewrite the specified file path.
    27      */
    28     cch = __libc_PathRewrite(pszPath, NULL, 0);
    29     if (cch > 0)
    30     {
    31         char *pszRewritten = alloca(cch);
    32         if (!pszRewritten)
    33         {
    34             errno = ENOMEM;
    35             LIBCLOG_RETURN_INT(-1);
    36         }
    37         cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
    38         if (cch > 0)
    39             pszPath = pszRewritten;
    40         /* else happens when someone changes the rules between the two calls. */
    41         else if (cch < 0)
    42         {
    43             errno = EAGAIN;             /* non-standard, I'm sure. */
    44             LIBCLOG_RETURN_INT(-1);
    45         }
    46     }
    47 
    48     /*
    49      * Strip off any trailing slashes.
    50      * (Linux and FreeBSD accept this.)
    51      */
    52     if (cch <= 0)
    53     {
    54         cch = strlen(pszPath);
    55         if (    cch > 2
    56             && ((ch = pszPath[cch - 1]) == '/' || ch == '\\')
    57             && pszPath[cch - 2] != ':')
    58         {
    59             char *psz = alloca(cch);
    60             if (!psz)
    61             {
    62                 errno = ENOMEM;
    63                 LIBCLOG_RETURN_INT(-1);
    64             }
    65             pszPath = (const char *)memcpy(psz, pszPath, cch);
    66             psz[cch - 1] = '\0';
    67         }
    68     }
    69     else if (    cch > 3                /* includes terminator */
    70              && ((ch = pszPath[cch - 2]) == '/' || ch == '\\')
    71              && pszPath[cch - 3] != ':')
    72         ((char *)pszPath)[cch - 2] = '\0';          /* rewrite temp buffer. */
    73 
    74 
    75 
    76     /*
    77      * Do It.
    78      */
    79     FS_SAVE_LOAD();
    80     rc = DosCreateDir((PCSZ)pszPath, NULL);
    81     FS_RESTORE();
    82     if (rc != 0)
    83     {
    84         _sys_set_errno(rc);
    85         LIBCLOG_RETURN_INT(-1);
    86     }
    87     LIBCLOG_RETURN_INT(0);
    88 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__open.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    1 /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2    Copyright (c) 2003 Dimitry Froloff
    3    Copyright (c) 2003-2004 knut st. osmundsen
    4  */
    5 
    6 /*******************************************************************************
    7 *   Header Files                                                               *
    8 *******************************************************************************/
    9 #include "libc-alias.h"
    10 #define INCL_DOSERRORS
    11 #define INCL_FSMACROS
    12 #include <os2emx.h>
    13 #include <string.h>
    14 #include <errno.h>
    15 #include <limits.h>
    16 #include <emx/syscalls.h>
    17 #include <emx/io.h>
    18 #include <alloca.h>
    19 #include "syscalls.h"
    20 #include <InnoTekLIBC/pathrewrite.h>
    21 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    22 #include <InnoTekLIBC/logstrict.h>
    23 
    24 
    25 int __open(const char *pszFile, int flags, off_t cbInitial, unsigned fLibc, PLIBCFH *ppFH)
    26 {
    27     LIBCLOG_ENTER("pszFile=%s flags=%#x cbInitial=%lld fLibc=%#x ppFH=%p\n",
    28                   pszFile, flags, cbInitial, fLibc, (void*)ppFH);
    29     ULONG   rc;
    30     ULONG   flOpenMode;
    31     ULONG   flOpenFlags;
    32     ULONG   flAttr;
    33     ULONG   ulAction;
    34     HFILE   hFile;
    35     int     cch;
    36     int     cExpandRetries;
    37     int     failed_open_errno;
    38     FS_VAR();
    39 
    40 
    41     /*
    42      * Rewrite the specified file path.
    43      */
    44     cch = __libc_PathRewrite(pszFile, NULL, 0);
    45     if (cch > 0)
    46     {
    47         char *pszRewritten = alloca(cch);
    48         if (!pszRewritten)
    49         {
    50             errno = ENOMEM;
    51             LIBCLOG_RETURN_INT(-1);
    52         }
    53         cch = __libc_PathRewrite(pszFile, pszRewritten, cch);
    54         if (cch > 0)
    55             pszFile = pszRewritten;
    56         /* else happens when someone changes the rules between the two calls. */
    57         else if (cch < 0)
    58         {
    59             errno = EAGAIN;             /* non-standard, I'm sure. */
    60             LIBCLOG_RETURN_INT(-1);
    61         }
    62     }
    63 
    64     /*
    65      * Extract the access mode and sharing mode bits.
    66      */
    67     flOpenMode = flags & 0x77;
    68 
    69     /*
    70      * File O_NOINHERIT and O_SYNC.
    71      */
    72     if (flags & _SO_NOINHERIT)
    73         flOpenMode |= OPEN_FLAGS_NOINHERIT;
    74     if (flags & _SO_SYNC)
    75         flOpenMode |= OPEN_FLAGS_WRITE_THROUGH;
    76 
    77     /*
    78      * Extract the file flAttribute bits.
    79      */
    80     flAttr = (flags >> 8) & 0xff;
    81     if (_sys_umask & 0200)
    82         flAttr |= FILE_READONLY;
    83 
    84     /*
    85      * Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see below).
    86      */
    87     failed_open_errno = ENOENT;
    88 
    89     /*
    90      * Compute `flOpenFlags' depending on `flags'.  Note that _SO_CREAT is
    91      * set for O_CREAT.
    92      */
    93     if (flags & _SO_CREAT)
    94     {
    95         if (flags & _SO_EXCL)
    96         {
    97             flOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
    98             failed_open_errno = EEXIST;
    99         }
    100         else if (flags & _SO_TRUNC)
    101             flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
    102         else
    103             flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
    104     }
    105     else if (flags & _SO_TRUNC)
    106         flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
    107     else
    108         flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
    109 
    110     if (!(flags & _SO_SIZE))
    111         cbInitial = 0;
    112 
    113     /*
    114      * Try to open the file.
    115      */
    116     FS_SAVE_LOAD();
    117     for (cExpandRetries = 0;;)
    118     {
    119 #if OFF_MAX > LONG_MAX
    120         if (__pfnDosOpenL)
    121         {
    122             LONGLONG cbInitialTmp = cbInitial;
    123             int     cch = strlen(pszFile);
    124             char *  pszFile_safe = alloca(cch + 1);
    125             if (pszFile_safe)
    126             {
    127                 strcpy(pszFile_safe, pszFile);
    128                 rc = __pfnDosOpenL((PCSZ)pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    129             }
    130             else
    131                 rc = ERROR_NOT_ENOUGH_MEMORY;
    132         }
    133         else
    134         {
    135             ULONG cbInitialTmp = (ULONG)cbInitial;
    136             if (cbInitial > LONG_MAX)
    137             {
    138                 FS_RESTORE();
    139                 errno = EOVERFLOW;
    140                 LIBCLOG_RETURN_INT(-1);
    141             }
    142             rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    143         }
    144 #else
    145         {
    146             ULONG cbInitialTmp = cbInitial;
    147             rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    148         }
    149 #endif
    150         /* Check if we're out of handles. */
    151         if (rc != ERROR_TOO_MANY_OPEN_FILES)
    152             break;
    153         if (cExpandRetries++ >= 3)
    154             break;
    155         __libc_FHMoreHandles();
    156     }   /* ... retry 3 times ... */
    157 
    158     if (!rc)
    159     {
    160         ULONG   fulType;
    161         ULONG   fulDevFlags;
    162 
    163         /*
    164          * Figure the handle type.
    165          */
    166         rc = DosQueryHType(hFile, &fulType, &fulDevFlags);
    167         if (!rc)
    168         {
    169             switch (fulType & 0xff)
    170             {
    171                 default: /* paranoia */
    172                 case HANDTYPE_FILE:
    173                     fLibc |= F_FILE;
    174                     break;
    175                 case HANDTYPE_DEVICE:
    176                     fLibc |= F_DEV;
    177                     break;
    178                 case HANDTYPE_PIPE:
    179                     fLibc |= F_PIPE;
    180                     break;
    181             }
    182 
    183             /*
    184              * Register the handle.
    185              */
    186             rc = __libc_FHAllocate(hFile, fLibc, sizeof(LIBCFH), NULL, ppFH, NULL);
    187             LIBCLOG_MSG("hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu\n",
    188                         hFile, fLibc, fulType, ulAction);
    189         }
    190 
    191         if (rc)
    192             DosClose(hFile);
    193     }
    194     FS_RESTORE();
    195 
    196     /*
    197      * Handle any errors.
    198      */
    199     if (rc)
    200     {
    201         if (rc == ERROR_OPEN_FAILED)
    202             errno = failed_open_errno;
    203         else
    204             _sys_set_errno(rc);
    205         LIBCLOG_RETURN_INT(-1);
    206     }
    207     return hFile;
    208 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__rmdir.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1518 r1519  
    1 /* sys/rmdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
    2 
    3 #include "libc-alias.h"
    4 #define INCL_FSMACROS
    5 #include <os2emx.h>
    6 #include <stdlib.h>
    7 #include <string.h>
    8 #include <errno.h>
    9 #include <emx/syscalls.h>
    10 #include "syscalls.h"
    11 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    12 #include <InnoTekLIBC/logstrict.h>
    13 #include <InnoTekLIBC/pathrewrite.h>
    14 
    15 int __rmdir(const char *pszPath)
    16 {
    17     LIBCLOG_ENTER("pszPath=%s\n", pszPath);
    18     ULONG   rc;
    19     int     cch;
    20     char    ch;
    21     FS_VAR();
    22 
    23     /*
    24      * Rewrite the specified file path.
    25      */
    26     cch = __libc_PathRewrite(pszPath, NULL, 0);
    27     if (cch > 0)
    28     {
    29         char *pszRewritten = alloca(cch);
    30         if (!pszRewritten)
    31         {
    32             errno = ENOMEM;
    33             LIBCLOG_RETURN_INT(-1);
    34         }
    35         cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
    36         if (cch > 0)
    37             pszPath = pszRewritten;
    38         /* else happens when someone changes the rules between the two calls. */
    39         else if (cch < 0)
    40         {
    41             errno = EAGAIN;             /* non-standard, I'm sure. */
    42             LIBCLOG_RETURN_INT(-1);
    43         }
    44     }
    45 
    46     /*
    47      * Strip off any trailing slashes.
    48      * (Linux and FreeBSD accept this.)
    49      */
    50     if (cch <= 0)
    51     {
    52         cch = strlen(pszPath);
    53         if (    cch > 2
    54             && ((ch = pszPath[cch - 1]) == '/' || ch == '\\')
    55             && pszPath[cch - 2] != ':')
    56         {
    57             char *psz = alloca(cch);
    58             if (!psz)
    59             {
    60                 errno = ENOMEM;
    61                 LIBCLOG_RETURN_INT(-1);
    62             }
    63             pszPath = (const char *)memcpy(psz, pszPath, cch);
    64             psz[cch - 1] = '\0';
    65         }
    66     }
    67     else if (    cch > 3                /* includes terminator */
    68              && ((ch = pszPath[cch - 2]) == '/' || ch == '\\')
    69              && pszPath[cch - 3] != ':')
    70         ((char *)pszPath)[cch - 2] = '\0';          /* rewrite temp buffer. */
    71 
    72     /*
    73      * Do It.
    74      */
    75     FS_SAVE_LOAD();
    76     rc = DosDeleteDir((PCSZ)pszPath);
    77     FS_RESTORE();
    78     if (rc)
    79     {
    80         _sys_set_errno(rc);
    81         LIBCLOG_RETURN_INT(-1);
    82     }
    83     LIBCLOG_RETURN_INT(0);
    84 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/__spawnve.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    1212#define INCL_FSMACROS
    1313#include <os2emx.h>
     14#include "fs.h"
    1415#include <emx/syscalls.h>
    1516#include <InnoTekLIBC/sharedpm.h>
     
    2728{
    2829    LIBCLOG_ENTER("\n");
     30    __LIBC_PSPMINHERIT      pRet = NULL;
     31
     32    /*
     33     * Get FH stuff.
     34     */
    2935    size_t                  cbFH;
    3036    __LIBC_PSPMINHFHBHDR    pFH;
    31     __LIBC_PSPMINHERIT      pRet = NULL;
    32 
    33     /*
    34      * Get FH stuff.
    35      */
    3637    pFH = __libc_fhInheritPack(&cbFH);
    3738    if (pFH)
    3839    {
    3940        /*
    40          * Allocate shared memory.
     41         * Get FS stuff.
    4142         */
    42         size_t  cb = sizeof(__LIBC_SPMINHERIT) + ((cbFH + 3) & ~3);
    43         pRet = __libc_spmAlloc(cb);
    44         if (pRet)
    45         {
    46             pRet->cb = sizeof(*pRet);
    47             pRet->pFHBundles = (__LIBC_PSPMINHFHBHDR)(pRet + 1);
    48             memcpy(pRet->pFHBundles, pFH, cbFH);
    49             free(pFH);
    50             LIBCLOG_RETURN_P(pRet);
    51         }
     43        size_t              cbFS;
     44        __LIBC_PSPMINHFS    pFS;
     45        if (!__libc_back_fsInheritPack(&pFS, &cbFS))
     46        {
     47            /*
     48             * Allocate shared memory.
     49             */
     50            size_t  cb = sizeof(__LIBC_SPMINHERIT) + ((cbFH + 3) & ~3) + ((cbFS + 3) & ~3);
     51            pRet = __libc_spmAlloc(cb);
     52            if (pRet)
     53            {
     54                pRet->cb = sizeof(*pRet);
     55                pRet->pFHBundles = (__LIBC_PSPMINHFHBHDR)(pRet + 1);
     56                memcpy(pRet->pFHBundles, pFH, cbFH);
     57                if (pFS)
     58                {
     59                    pRet->pFS = (__LIBC_PSPMINHFS)((char *)pRet->pFHBundles + ((cbFH + 3) & ~3));
     60                    memcpy(pRet->pFS, pFS, cbFS);
     61                    free(pFS);
     62                }
     63                else
     64                    pRet->pFS = NULL;
     65                free(pFH);
     66                LIBCLOG_RETURN_P(pRet);
     67            }
     68            free(pFS);
     69        }
     70
    5271        /* cleanup on failure */
    5372        __libc_fhInheritDone();
     
    125144    if (stricmp (base, "cmd.exe") == 0 || stricmp (base, "4os2.exe") == 0)
    126145        method = 1;
     146    char szNativePath[PATH_MAX];
     147    int rc = __libc_back_fsResolve(pgm_name, BACKFS_FLAGS_RESOLVE_FULL, &szNativePath[0], NULL);
     148    if (rc)
     149    {
     150        LIBC_ASSERTM_FAILED("Failed to resolve program name: '%s' rc=%d.\n", pgm_name, rc);
     151        errno = -rc;
     152        LIBCLOG_RETURN_INT(-1);
     153    }
     154    pgm_name = &szNativePath[0];
    127155
    128156    /*
  • trunk/src/emx/src/lib/sys/__stat.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1518 r1519  
    1 /* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    2  * sys/__stat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
    3  */
    4 
    5 /*******************************************************************************
    6 *   Header Files                                                               *
    7 *******************************************************************************/
    8 #include "libc-alias.h"
    9 #define INCL_FSMACROS
    10 #include <os2emx.h>
    11 #include <string.h>
    12 #include <errno.h>
    13 #include <stdlib.h>
    14 #include <sys/types.h>
    15 #include <sys/stat.h>
    16 #include <emx/syscalls.h>
    17 #include <limits.h>
    18 #include "syscalls.h"
    19 #include <InnoTekLIBC/pathrewrite.h>
    20 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
    21 #include <InnoTekLIBC/logstrict.h>
    22 
    23 int __stat(const char *pszPath, struct stat *pStat)
    24 {
    25     LIBCLOG_ENTER("pszPath=%s pStat=%p\n", pszPath, (void *)pStat);
    26     ULONG   rc;
    27     int     cch;
    28     union
    29     {
    30         FILESTATUS3     fsts3;
    31         FILESTATUS3L    fsts3L;
    32     } info;
    33 #if OFF_MAX > LONG_MAX
    34     int     fLarge = 0;
    35 #endif
    36     FS_VAR();
    37 
    38     bzero(pStat, sizeof(*pStat));
    39 
    40     /*
    41      * Rewrite the specified file path.
    42      */
    43     cch = __libc_PathRewrite(pszPath, NULL, 0);
    44     if (cch > 0)
    45     {
    46         char *pszRewritten = alloca(cch);
    47         if (!pszRewritten)
    48         {
    49             errno = ENOMEM;
    50             LIBCLOG_RETURN_INT(-1);
    51         }
    52         cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
    53         if (cch > 0)
    54             pszPath = pszRewritten;
    55         /* else happens when someone changes the rules between the two calls. */
    56         else if (cch < 0)
    57         {
    58             errno = EAGAIN;             /* non-standard, I'm sure. */
    59             LIBCLOG_RETURN_INT(-1);
    60         }
    61     }
    62 
    63     /*
    64      * Validate input, refusing named pipes.
    65      */
    66     if (    (pszPath[0] == '/' || pszPath[0] == '\\')
    67         &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
    68         &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
    69         &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
    70         &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
    71         &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
    72     {
    73         errno = ENOENT;
    74         LIBCLOG_RETURN_INT(-1);
    75     }
    76 
    77     /*
    78      * Get path info.
    79      */
    80     FS_SAVE_LOAD();
    81 #if OFF_MAX > LONG_MAX
    82     if (__pfnDosOpenL)
    83     {
    84         rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));
    85         fLarge = 1;
    86     }
    87     else
    88 #endif
    89         rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));
    90     FS_RESTORE();
    91     if (rc)
    92     {
    93         _sys_set_errno(rc);
    94         LIBCLOG_RETURN_INT(-1);
    95     }
    96 
    97     /*
    98      * Format stats struct.
    99      *      We know the info struct layouts!
    100      *      Only cbFile, cbFileAlloc and attrFile need be accessed
    101      *      using the specific structure.
    102      */
    103     /* Times: FAT might not return create and access time. */
    104     pStat->st_mtime = _sys_p2t(info.fsts3.ftimeLastWrite, info.fsts3.fdateLastWrite);
    105     if (   FTIMEZEROP(info.fsts3.ftimeCreation)
    106         && FDATEZEROP(info.fsts3.fdateCreation))
    107         pStat->st_ctime = pStat->st_mtime;
    108     else
    109         pStat->st_ctime = _sys_p2t(info.fsts3.ftimeCreation, info.fsts3.fdateCreation);
    110     if (   FTIMEZEROP(info.fsts3.ftimeLastAccess)
    111         && FDATEZEROP(info.fsts3.fdateLastAccess))
    112         pStat->st_atime = pStat->st_mtime;
    113     else
    114         pStat->st_atime = _sys_p2t(info.fsts3.ftimeLastAccess, info.fsts3.fdateLastAccess);
    115 
    116 #if OFF_MAX > LONG_MAX
    117     rc = fLarge ? info.fsts3L.attrFile : info.fsts3.attrFile;
    118 #else
    119     rc = info.fsts3.attrFile;
    120 #endif
    121     pStat->st_attr = rc;
    122     if (rc & FILE_DIRECTORY)
    123     {
    124         /* directory */
    125         pStat->st_mode = S_IFDIR;
    126         pStat->st_mode |= ((S_IREAD|S_IWRITE|S_IEXEC) >> 6) * 0111;
    127         pStat->st_size = 0;
    128     }
    129     else
    130     {
    131 #if OFF_MAX > LONG_MAX
    132         if (fLarge)
    133         {
    134             pStat->st_size = info.fsts3L.cbFile;
    135             pStat->st_blocks = info.fsts3L.cbFileAlloc / S_BLKSIZE;
    136         }
    137         else
    138 #endif
    139         {
    140             pStat->st_size = info.fsts3.cbFile;
    141             pStat->st_blocks = info.fsts3.cbFileAlloc / S_BLKSIZE;
    142         }
    143         pStat->st_mode = S_IFREG;
    144         if (rc & FILE_READONLY)
    145             pStat->st_mode |= (S_IREAD >> 6) * 0111;
    146         else
    147             pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111;
    148     }
    149     /* default fake stuff */
    150     pStat->st_uid = 0;
    151     pStat->st_gid = 0;
    152     pStat->st_ino = _sys_ino++;
    153     if (_sys_ino == 0)
    154         _sys_ino = 1;
    155     pStat->st_dev = 0;
    156     pStat->st_rdev = 0;
    157     pStat->st_nlink = 1;
    158     pStat->st_blksize = 4096*48;
    159 
    160     LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
    161     LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
    162     LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
    163     LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
    164     LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
    165     LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
    166     LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
    167     LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
    168     LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
    169     LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
    170     LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
    171     LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
    172     LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
    173     LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
    174     LIBCLOG_RETURN_INT(0);
    175 }
     1/* dead */
  • trunk/src/emx/src/lib/sys/b_fsStat.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3030*******************************************************************************/
    3131#include "libc-alias.h"
     32#include "fs.h"
    3233#include <stdlib.h>
    3334#include <string.h>
     
    3738#include <sys/syslimits.h>
    3839#include <InnoTekLIBC/backend.h>
    39 #define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_BACKEND
     40#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_BACK_FS
    4041#include <InnoTekLIBC/logstrict.h>
    4142
     
    5556 *
    5657 * @returns 0 on success.
    57  * @returns -1 and errno on failure.
     58 * @returns Negative error code (errno.h) on failure.
    5859 * @param   pszPath     The path to somewhere in the filesystem.
    5960 * @param   pStatFs     Where to store the obtained information.
     
    6768     */
    6869    if (!pStatFs)
    69     {
    70         errno = EFAULT;
    71         LIBCLOG_RETURN_INT(-1);
    72     }
     70        LIBCLOG_RETURN_INT(-EFAULT);
    7371
    7472    /*
    7573     * Make absolute path (but no symlink resolving I think).
    7674     */
    77     char szPath[PATH_MAX];
    78     if (_abspath(szPath, pszPath, sizeof(szPath)))
    79         LIBCLOG_RETURN_INT(-1);
     75    /** @todo Check if fsstat() can work on a non-existing path spec. */
     76    char szNativePath[PATH_MAX];
     77    int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_FULL, &szNativePath[0], NULL);
     78    if (rc)
     79        LIBCLOG_RETURN_INT(rc);
    8080
    8181    /*
    8282     * Do the query.
    8383     */
    84     szPath[2] = '\0';
    85     int rc = fsStatInternal(szPath, pStatFs);
     84    szNativePath[2] = '\0';
     85    rc = fsStatInternal(&szNativePath[0], pStatFs);
    8686
    8787    LIBCLOG_RETURN_INT(rc);
     
    9494 *
    9595 * @returns 0 on success.
    96  * @returns -1 and errno on failure.
     96 * @returns Negative error code (errno.h) on failure.
    9797 * @param   fh          The filehandle of any file within the mounted file system.
    9898 * @param   pStatFs     Where to store the statistics.
     
    106106     */
    107107    if (!pStatFs)
    108     {
    109         errno = EFAULT;
    110         LIBCLOG_RETURN_INT(-1);
    111     }
     108        LIBCLOG_RETURN_INT(-EFAULT);
    112109
    113110    /*
     
    116113     */
    117114    char    szFilename[PATH_MAX];
    118     int rc = __libc_Back_fhToPath(fh, szFilename, sizeof(szFilename));
     115    int rc = __libc_Back_ioFHToPath(fh, szFilename, sizeof(szFilename));
    119116    if (!rc)
    120117    {
     
    133130 * @returns Number of returned statfs structs on success.
    134131 * @returns Number of mounted filesystems on success if paStatFS is NULL
    135  * @returns -1 and errno on failure.
     132 * @returns Negative error code (errno.h) on failure.
    136133 * @param   paStatFs    Where to to store the statistics.
    137134 * @parma   cStatFS     Number of structures the array pointed to by paStatFs can hold.
     
    178175 *
    179176 * @returns 0 on success.
    180  * @returns -1 and errno on failure.
     177 * @returns Negative error code (errno.h) on failure.
    181178 * @param   pszMountPoint   Path to the filesystem mount point.
    182179 * @param   pStatFs         Where to store the statistics.
  • trunk/src/emx/src/lib/sys/b_fsSync.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3131#include "libc-alias.h"
    3232#include <InnoTekLIBC/backend.h>
    33 #define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_BACKEND
     33#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_BACK_FS
    3434#include <InnoTekLIBC/logstrict.h>
    3535
  • trunk/src/emx/src/lib/sys/b_miscLoadAvg.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    177177    {
    178178        LIBC_ASSERTM_FAILED("Invalid address!\n");
    179         errno = EFAULT;
    180         LIBCLOG_RETURN_INT(-1);
     179        LIBCLOG_RETURN_INT(-EFAULT);
    181180    }
    182181
     
    186185    rc = __libc_spmGetLoadAvg(&LoadAvg, &uTimestamp);
    187186    if (rc)
    188         LIBCLOG_RETURN_INT(-1);
     187        LIBCLOG_RETURN_INT(rc);
    189188    if (uTimestamp - LoadAvg.uTimestamp > 5000 /* 5sec */)
    190189    {
    191190        rc = miscUpdateLoadAvg(&LoadAvg, uTimestamp);
    192191        if (rc)
    193             LIBCLOG_RETURN_INT(-1);
     192            LIBCLOG_RETURN_INT(rc);
    194193    }
    195194
  • trunk/src/emx/src/lib/sys/b_threadCleanup.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/b_threadEnd.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/b_threadInit.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/b_threadStartup.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/filefind.c

    • Property cvs2svn:cvs-rev changed from 1.9 to 1.10
    r1518 r1519  
    77*******************************************************************************/
    88#include "libc-alias.h"
     9#define INCL_BASE
     10#define INCL_FSMACROS
     11#include <os2emx.h>
     12#include "fs.h"
    913#include <stdlib.h>
    1014#include <string.h>
    1115#include <errno.h>
    1216#include <limits.h>
    13 #define INCL_BASE
    14 #define INCL_FSMACROS
    15 #include <os2emx.h>
    1617#include <emx/syscalls.h>
    1718#include "syscalls.h"
     
    170171    pFD->cFiles = sizeof(pFD->achBuffer) / 40;
    171172#if OFF_MAX > LONG_MAX
    172     pFD->fType = __pfnDosOpenL ? FIL_STANDARDL : FIL_STANDARD;
     173    pFD->fType = __libc_gpfnDosOpenL ? FIL_STANDARDL : FIL_STANDARD;
    173174    if (pFD->fType == FIL_STANDARDL)  /* the L version is buggy!! Make sure there is enough space. */
    174175        pFD->cFiles = sizeof(pFD->achBuffer) / sizeof(FILEFINDBUF3L);
  • trunk/src/emx/src/lib/sys/filehandles.c

    • Property cvs2svn:cvs-rev changed from 1.13 to 1.14
    r1518 r1519  
    77 *
    88 *
    9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
     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
    1214 * (at your option) any later version.
    1315 *
    14  * This program is distributed in the hope that it will be useful,
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
    1517 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU General Public License
    20  * along with This program; if not, write to the Free Software
     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
    2123 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2224 *
     
    10501052 * @returns NULL on failure.
    10511053 * @param   fh  Handle to lookup.
     1054 * @deprecated
    10521055 */
    10531056__LIBC_PFH __libc_FH(int fh)
     
    10651068}
    10661069
     1070
     1071/**
     1072 * Get the LIBC handle structure corresponding to a filehandle.
     1073 *
     1074 * @returns Pointer to handle structure on success.
     1075 * @returns Negative error code (errno.h) on failure.
     1076 * @param   fh      Handle to lookup.
     1077 * @param   ppFH    Where to store the filehandle pointer
     1078 */
     1079int __libc_FHEx(int fh, __LIBC_PFH *ppFH)
     1080{
     1081    __LIBC_PFH pFH;
     1082
     1083    /** @todo shared access */
     1084    int rc = _fmutex_request(&gmtx, 0);
     1085    if (rc)
     1086        return -__libc_native2errno(rc);
     1087
     1088    /** @todo rewrite fhGet() to avoid this errno saving and restoring. */
     1089    int errno_saved = errno;
     1090    pFH = fhGet(fh);
     1091    rc = -errno;
     1092    errno = errno_saved;
     1093
     1094    _fmutex_release(&gmtx);
     1095    if (pFH)
     1096    {
     1097        *ppFH = pFH;
     1098        return 0;
     1099    }
     1100    return rc;
     1101}
    10671102
    10681103
  • trunk/src/emx/src/lib/sys/fs.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3030*******************************************************************************/
    3131#include "libc-alias.h"
    32 #include "fs.h"
    3332#define INCL_FSMACROS
    3433#define INCL_BASE
    3534#define INCL_ERRORS
    3635#include <os2emx.h>
     36#include "fs.h"
    3737#define __USE_GNU
     38#include <stddef.h>
    3839#include <string.h>
    3940#include <errno.h>
     
    4546#include <InnoTekLIBC/pathrewrite.h>
    4647#include <InnoTekLIBC/libc.h>
    47 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     48#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS
    4849#include <InnoTekLIBC/logstrict.h>
     50
     51
     52/*******************************************************************************
     53*   Defined Constants And Macros                                               *
     54*******************************************************************************/
     55#define ORD_DOS32OPENL              981
     56#define ORD_DOS32SETFILEPTRL        988
     57#define ORD_DOS32SETFILESIZEL       989
     58#define ORD_DOS32SETFILELOCKSL      986
     59
     60#define SIZEOF_ACHBUFFER    (sizeof(FILEFINDBUF4) + 32)
    4961
    5062
     
    5264*   Global Variables                                                           *
    5365*******************************************************************************/
    54 /** Mutex protecting all the FS globals. */
     66/** Mutex protecting all the FS globals.
     67 * __libc_gfsUMask and the API pointers are not protected by this semaphore. */
    5568static _fmutex __libc_gmtxFS;
    5669
    5770/** Indicator whether or not we're in the unix tree. */
    58 int  __libc_gfInUnixTree = 0;
     71int     __libc_gfInUnixTree = 0;
    5972/** Length of the unix root if the unix root is official. */
    60 int  __libc_gcchUnixRoot = 0;
     73int     __libc_gcchUnixRoot = 0;
    6174/** The current unix root. */
    62 char __libc_gszUnixRoot[PATH_MAX];
    63 
    64 
     75char    __libc_gszUnixRoot[PATH_MAX];
     76/** The umask of the process. */
     77mode_t  __libc_gfsUMask = 022;
     78
     79
     80ULONG (* _System __libc_gpfnDosOpenL)(PCSZ pszFileName, PHFILE phFile, PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags, ULONG ulOpenMode, PEAOP2 pEABuf) = NULL;
     81ULONG (* _System __libc_gpfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset, ULONG ulOrigin, PLONGLONG pllPos) = NULL;
     82ULONG (* _System __libc_gpfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize) = NULL;
     83ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags) = NULL;
     84
     85/** Symlink EA name. */
    6586#define EA_SYMLINK  "LIBC.SYMLINK"
     87
    6688/** Symlink ea name. */
    6789const char __libc_gszSymlinkEA[] = EA_SYMLINK;
     
    91113
    92114
    93 
    94115/*******************************************************************************
    95116*   Internal Functions                                                         *
    96117*******************************************************************************/
    97 static int fsInit(void);
    98 static int fsResolveUnix(const char *pszUserPath, int fVerifyLast, char *pszNativePath, size_t cchNativePath, int *pfInUnixTree);
    99 
    100 
    101 
    102 _CRT_INIT1(fsInit)
     118static int fsResolveUnix(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree);
     119
     120
    103121
    104122/**
     
    108126 * @returns -1 on failure.
    109127 */
    110 static int fsInit(void)
     128int __libc_back_fsInit(void)
    111129{
    112130    LIBCLOG_ENTER("\n");
     
    115133     * Only once.
    116134     */
    117     static void *pvCalled = (void *)fsInit;
    118     if (!pvCalled)
     135    static int  fInited;
     136    if (fInited)
    119137        LIBCLOG_RETURN_INT(0);
    120     pvCalled = NULL;
    121 
     138    fInited = 1;
    122139
    123140    /*
     
    126143    int rc = _fmutex_create(&__libc_gmtxFS, 0);
    127144    if (rc)
    128         abort();
    129 
    130     /*
    131      * Inherit stuff.
     145        LIBCLOG_RETURN_INT(-1);
     146
     147    /*
     148     * Inherit File System Data from parent.
    132149     */
    133150    __LIBC_PSPMINHERIT  pInherit = __libc_spmInheritRequest();
    134151    __LIBC_PSPMINHFS    pFS;
    135     if (pInherit && (pFS = pInherit->pFS) != NULL && pFS->cchUnixRoot)
    136     {
    137         LIBCLOG_MSG("Inherited unixroot=%s\n", pFS->szUnixRoot);
    138         __libc_gfInUnixTree = pFS->fInUnix;
     152    if (    pInherit
     153        &&  pInherit->cb > offsetof(__LIBC_SPMINHERIT, pFS)
     154        &&  (pFS = pInherit->pFS) != NULL
     155        &&  pFS->cchUnixRoot)
     156    {
     157        LIBCLOG_MSG("Inherited unixroot=%s fInUnixTree=%d cchUnixRoot=%d\n", pFS->szUnixRoot, pFS->fInUnixTree, pFS->cchUnixRoot);
     158        __libc_gfNoUnix     = 0;
     159        __libc_gfInUnixTree = pFS->fInUnixTree;
    139160        __libc_gcchUnixRoot = pFS->cchUnixRoot;
    140161        memcpy(&__libc_gszUnixRoot[0], &pFS->szUnixRoot[0], pFS->cchUnixRoot + 1);
     
    146167        gaRewriteRule.cchTo = 1;
    147168        if (__libc_PathRewriteAdd(&gaRewriteRule, 1))
    148         {
    149             abort();
    150169            LIBCLOG_RETURN_INT(-1);
    151         }
    152170    }
    153171    else
     
    171189                {
    172190                    LIBC_ASSERTM_FAILED("The UNIXROOT environment variable is too long! cch=%d maxlength=%d\n", cch, PATH_MAX - 32);
    173                     abort();
    174191                    LIBCLOG_RETURN_INT(-1);
    175192                }
     
    179196                gaRewriteRule.cchTo = cch;
    180197                if (__libc_PathRewriteAdd(&gaRewriteRule, 1))
    181                 {
    182                     abort();
    183198                    LIBCLOG_RETURN_INT(-1);
    184                 }
    185             }
    186         }
    187     }
     199            }
     200        }
     201    }
     202
     203
     204    /*
     205     * Try resolve large file APIs.
     206     *
     207     * First, get a handle to DOSCALLS/DOSCALL1 which  is suitable
     208     * for DosQueryProcAddr.
     209     * Second, query the procedure addresses.
     210     * Third, free DOSCALLS since there's no point messing up any
     211     * reference counters for that module.
     212     */
     213    HMODULE     hmod = NULLHANDLE;
     214    if (DosLoadModule(NULL, 0, (PCSZ)"DOSCALLS", &hmod))
     215    {
     216        LIBC_ASSERTM_FAILED("DosLoadModule failed on doscalls!\n");
     217        abort();
     218        LIBCLOG_RETURN_INT(-1);
     219    }
     220    if (    DosQueryProcAddr(hmod, ORD_DOS32OPENL,          NULL, (PFN*)(void *)&__libc_gpfnDosOpenL)
     221        ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILEPTRL,    NULL, (PFN*)(void *)&__libc_gpfnDosSetFilePtrL)
     222        ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILESIZEL,   NULL, (PFN*)(void *)&__libc_gpfnDosSetFileSizeL)
     223        ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILELOCKSL,  NULL, (PFN*)(void *)&__libc_gpfnDosSetFileLocksL)
     224          )
     225    {
     226        __libc_gpfnDosOpenL         = NULL;
     227        __libc_gpfnDosSetFilePtrL   = NULL;
     228        __libc_gpfnDosSetFileSizeL  = NULL;
     229        __libc_gpfnDosSetFileLocksL = NULL;
     230    }
     231    DosFreeModule(hmod);
    188232
    189233    LIBCLOG_RETURN_INT(0);
     234}
     235
     236/**
     237 * Pack inherit data.
     238 * @returns 0 on success.
     239 * @returns -1 on failure.
     240 * @param   ppFS    Where to store the pointer to the inherit data.
     241 * @param   pcbFS   Where to store the size of the inherit data.
     242 */
     243int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS)
     244{
     245    LIBCLOG_ENTER("ppFS=%p pcbFS=%p\n", (void *)ppFS, (void *)pcbFS);
     246
     247    *ppFS = NULL;
     248    *pcbFS = 0;
     249
     250    if (__libc_back_fsMutexRequest())
     251        return -1;
     252
     253    int rc = 0;
     254    if (__libc_gcchUnixRoot)
     255    {
     256        size_t cb = sizeof(__LIBC_SPMINHFS) + __libc_gcchUnixRoot;
     257        __LIBC_PSPMINHFS pFS = (__LIBC_PSPMINHFS)malloc(cb);
     258        if (pFS)
     259        {
     260            pFS->fInUnixTree = __libc_gfInUnixTree;
     261            pFS->cchUnixRoot = __libc_gcchUnixRoot;
     262            memcpy(pFS->szUnixRoot, __libc_gszUnixRoot, pFS->cchUnixRoot + 1);
     263            LIBCLOG_MSG("unixroot=%s fInUnixTree=%d cchUnixRoot=%d\n", pFS->szUnixRoot, pFS->fInUnixTree, pFS->cchUnixRoot);
     264
     265            *pcbFS = cb;
     266            *ppFS = pFS;
     267        }
     268        else
     269            rc = -1;
     270    }
     271
     272    __libc_back_fsMutexRelease();
     273    LIBCLOG_RETURN_INT(rc);
    190274}
    191275
     
    196280    if (!rc)
    197281        return 0;
    198     _sys_set_errno(rc);
    199     return -1;
     282    return -__libc_native2errno(rc);
    200283}
    201284
     
    211294
    212295/**
    213  * Reads a symbolic link.
    214  *
    215  * @returns 0 on success.
     296 * Reads the content of a symbolic link.
     297 *
     298 * This is weird interface as it will return a truncated result if not
     299 * enough buffer space. It is also weird in that there is no string
     300 * terminator.
     301 *
     302 * @returns Number of bytes returned in pachBuf.
    216303 * @returns -1 and errno on failure.
    217  * @param   pszPath     The symlink to read.
    218  * @param   pszBuf      Where to read to.
    219  * @param   cchBuf      Size of the buffer.
     304 * @param   pszNativePath   The path to the symlink to read.
     305 * @param   pachBuf         Where to store the symlink value.
     306 * @param   cchBuf          Size of buffer.
    220307 */
    221 int __libc_Back_fsSymlinkRead(const char *pszPath, char *pszBuf, size_t cchBuf)
    222 {
    223     LIBCLOG_ENTER("pszPath=%p:{%s} pszBuf=%p cchBuf=%d\n", (void *)pszPath, pszPath, (void *)pszBuf, cchBuf);
     308int __libc_back_fsNativeSymlinkRead(const char *pszNativePath, char *pachBuf, size_t cchBuf)
     309{
     310    LIBCLOG_ENTER("pszNativePath=%p:{%s} pachBuf=%p cchBuf=%d\n", (void *)pszNativePath, pszNativePath, (void *)pachBuf, cchBuf);
    224311
    225312    /*
    226313     * Query the symlink EA value.
    227314     */
    228     char    achBuffer[PATH_MAX + 97];
     315    char    _achBuffer[SIZEOF_ACHBUFFER + 4];
     316    char   *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3);
    229317    EAOP2   EaOp;
    230318    EaOp.fpGEA2List = (PGEA2LIST)&gSymlinkGEA2List;
    231     EaOp.fpFEA2List = (PFEA2LIST)achBuffer;
     319    EaOp.fpFEA2List = (PFEA2LIST)pachBuffer;
    232320    EaOp.oError     = 0;
    233     EaOp.fpFEA2List->cbList = sizeof(achBuffer) - 1;
    234     LIBC_ASSERT(!((uintptr_t)&achBuffer[0] & 4));
    235     int rc = DosQueryPathInfo((PCSZ)pszPath, FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
     321    EaOp.fpFEA2List->cbList = SIZEOF_ACHBUFFER;
     322    int rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
    236323    if (!rc)
    237324    {
    238         /*
    239          * Validate the EA.
    240          */
    241         PUSHORT pusType = (PUSHORT)((char *)&EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);
    242         char   *pszSymlink = (char *)&pusType[2];
    243         if (    pusType[0] == EAT_ASCII
    244             &&  pusType[1] < EaOp.fpFEA2List->list[0].cbValue
    245             &&  pusType[1]
    246             &&  *pszSymlink)
     325        if (    EaOp.fpFEA2List->cbList > sizeof(EaOp.fpFEA2List->list[0])
     326            &&  EaOp.fpFEA2List->list[0].cbValue)
    247327        {
    248328            /*
    249              * Check the length, copy it to the buffer and return.
     329             * Validate the EA.
    250330             */
    251             int cchSymlink = strnlen(pszSymlink, pusType[1]);
    252             pszSymlink[cchSymlink] = '\0';
    253             if (cchSymlink < cchBuf)
    254             {
    255                 memcpy(pszBuf, pszSymlink, cchSymlink + 1);
    256                 LIBCLOG_RETURN_INT(0);
     331            PUSHORT pusType = (PUSHORT)((char *)&EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);
     332            int     cchSymlink = pusType[1];
     333            char   *pszSymlink = (char *)&pusType[2];
     334            if (    pusType[0] == EAT_ASCII
     335                &&  cchSymlink < EaOp.fpFEA2List->list[0].cbValue
     336                &&  cchSymlink > 0
     337                &&  *pszSymlink)
     338            {
     339                /*
     340                 * Copy it to the buffer and return.
     341                 */
     342                if (cchSymlink > cchBuf)
     343                {
     344                    LIBC_ASSERTM_FAILED("Buffer to small. %d bytes required, %d bytes available. pszSymlink='%.*s' pszNativePath='%s'\n",
     345                                        cchSymlink, cchBuf, cchSymlink, pszSymlink, pszNativePath);
     346                    cchSymlink = cchBuf;
     347                }
     348                memcpy(pachBuf, pszSymlink, cchSymlink);
     349                LIBCLOG_RETURN_INT(cchSymlink);
    257350            }
    258351            else
    259352            {
    260                 LIBC_ASSERTM_FAILED("Buffer to small. %d bytes required, %d bytes available. pszSymlink='%s' pszPath='%s'\n",
    261                                     cchSymlink + 1, cchBuf, pszSymlink, pszPath);
    262                 errno = ENAMETOOLONG;
    263                 LIBCLOG_RETURN_INT(-1);
     353                LIBC_ASSERTM_FAILED("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c pszNativePath='%s'\n",
     354                                    pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink, pszNativePath);
     355                LIBCLOG_RETURN_INT(-EFTYPE);
    264356            }
    265357        }
    266358        else
    267359        {
    268             LIBC_ASSERTM_FAILED("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c pszPath='%s'\n",
    269                                 pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink, pszPath);
    270             errno = EFTYPE;
    271             LIBCLOG_RETURN_INT(-1);
    272         }
    273     }
     360            LIBC_ASSERTM_FAILED("%s is not a symlink!\n", pszNativePath);
     361            LIBCLOG_RETURN_INT(-EINVAL);
     362        }
     363    }
     364    else
     365        LIBC_ASSERTM_FAILED("DosQueryPathInfo(%s) -> %d!\n", pszNativePath, rc);
    274366
    275367    /* failure */
    276     _sys_set_errno(rc);
    277     LIBCLOG_RETURN_INT(-1);
     368    rc = -__libc_native2errno(rc);
     369    LIBCLOG_RETURN_INT(rc);
    278370}
    279371
     
    310402    if (!EaOp.fpFEA2List)
    311403    {
    312         errno = ENOMEM;
    313404        LIBC_ASSERTM_FAILED("Out of stack! alloca(%d) failed\n", cb);
    314         LIBCLOG_RETURN_INT(-1);
     405        LIBCLOG_RETURN_INT(-ENOMEM);
    315406    }
    316407
     
    333424        LIBCLOG_RETURN_INT(0);
    334425
    335     _sys_set_errno(rc);
    336     LIBCLOG_RETURN_INT(-1);
     426    rc = -__libc_native2errno(rc);
     427    LIBCLOG_RETURN_INT(rc);
    337428}
    338429#endif
     
    343434 *
    344435 * @returns 0 on success.
    345  * @returns -1 and errno on failure.
     436 * @returns Negative error code (errno.h) on failure.
    346437 * @param   pszTarget       The symlink target.
    347438 * @param   pszSymlink      The symlink, the one to be updated.
    348439 */
    349 int __libc_Back_fsSymlinkCreate(const char *pszTarget, const char *pszSymlink)
    350 {
    351     LIBCLOG_ENTER("pszTarget=%s pszSymlink=%s\n", pszTarget, pszSymlink);
     440int __libc_back_fsNativeSymlinkCreate(const char *pszTarget, const char *pszNativePath)
     441{
     442    LIBCLOG_ENTER("pszTarget=%s pszNativePath=%s\n", pszTarget, pszNativePath);
    352443
    353444    /*
     
    357448    if (cchTarget >= PATH_MAX)
    358449    {
    359         errno = ENAMETOOLONG;
    360450        LIBC_ASSERTM_FAILED("Target is too long, %d bytes. (%s)\n", cchTarget, pszTarget);
    361         LIBCLOG_RETURN_INT(-1);
     451        LIBCLOG_RETURN_INT(-ENAMETOOLONG);
    362452    }
    363453
     
    370460    if (!EaOp.fpFEA2List)
    371461    {
    372         errno = ENOMEM;
    373462        LIBC_ASSERTM_FAILED("Out of stack! alloca(%d) failed\n", cb);
    374         LIBCLOG_RETURN_INT(-1);
     463        LIBCLOG_RETURN_INT(-ENOMEM);
    375464    }
    376465
     
    391480    HFILE   hf = -1;
    392481    ULONG   ul = 0;
    393     int rc = DosOpen((PCSZ)pszSymlink, &hf, &ul, cchTarget + 1, FILE_NORMAL,
     482    int rc = DosOpen((PCSZ)pszNativePath, &hf, &ul, cchTarget + 1, FILE_NORMAL,
    394483                     OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS,
    395484                     OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
     
    397486    if (!rc)
    398487    {
    399         DosWrite(hf, EA_SYMLINK "=", sizeof(EA_SYMLINK "=") - 1, &ul);
    400         DosWrite(hf, pszTarget, cchTarget + 1, &ul);
     488        char *psz = (char *)&pus[2] - (sizeof(EA_SYMLINK "=") - 1);
     489        memcpy(psz, EA_SYMLINK "=", sizeof(EA_SYMLINK "=") - 1);
     490        DosWrite(hf, psz, cchTarget + sizeof(EA_SYMLINK "=") - 1, &ul);
    401491        DosClose(hf);
    402492        LIBCLOG_RETURN_INT(0);
    403493    }
    404494
    405     _sys_set_errno(rc);
    406     LIBCLOG_RETURN_INT(-1);
     495    rc = -__libc_native2errno(rc);
     496    LIBCLOG_RETURN_INT(rc);
    407497}
    408498
     
    489579 * @returns -1 and errno on failure.
    490580 * @param   pszUserPath     The user path.
    491  * @param   pszNativePath   Where to store the native path.
    492  * @param   cchNativePath   Size of the buffer for the native path.
    493  * @param   fVerifyLast     Whether or not to verify the last component of the path.
    494  * @param   pfInUnixTree    Whether or not the path is in the unix tree. Optional.
    495  *
    496  * @remark  For correct operation the caller must lock the FS stuff.
     581 * @parm    fFlags          Flags controlling the operation of the function.
     582 *                          See the BACKFS_FLAGS_* defines.
     583 * @param   pszNativePath   Where to store the native path. This buffer is at
     584 *                          least PATH_MAX bytes big.
     585 * @param   pfInUnixTree    Where to store the result-in-unix-tree indicator. Optional.
    497586 */
    498 int __libc_back_fsResolve(const char *pszUserPath, int fVerifyLast, char *pszNativePath, size_t cchNativePath, int *pfInUnixTree)
     587int __libc_back_fsResolve(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree)
    499588{
    500589    if (!__libc_gfNoUnix)
    501         return fsResolveUnix(pszUserPath, fVerifyLast, pszNativePath, cchNativePath, pfInUnixTree);
     590        return fsResolveUnix(pszUserPath, fFlags, pszNativePath, pfInUnixTree);
    502591
    503592    /* __libc_back_fsResolveOS2(): */
    504593
    505     LIBCLOG_ENTER("pszUserPath=%p:{%s} fVerifyLast=%d pszNativePath=%p cchNativePath=%d pfInUnixTree=%p\n",
    506                   (void *)pszUserPath, pszUserPath, fVerifyLast, (void *)pszNativePath, cchNativePath, (void *)pfInUnixTree);
     594    LIBCLOG_ENTER("pszUserPath=%p:{%s} fFlags=%x pszNativePath=%p pfInUnixTree=%p\n",
     595                  (void *)pszUserPath, pszUserPath, fFlags, (void *)pszNativePath, (void *)pfInUnixTree);
    507596
    508597    /*
     
    511600    int cch = __libc_PathRewrite(pszUserPath, pszNativePath, sizeof(pszNativePath));
    512601    if (cch < 0)
    513     {
    514         errno = EINVAL;
    515         LIBCLOG_RETURN_INT(-1);
    516     }
     602        LIBCLOG_RETURN_INT(-EINVAL);
    517603    if (cch == 0)
    518604    {
    519605        cch = strlen(pszUserPath);
    520         if (cch >= cchNativePath)
    521         {
    522             errno = EINVAL;
    523             LIBCLOG_RETURN_INT(-1);
    524         }
     606        if (cch >= PATH_MAX)
     607            LIBCLOG_RETURN_INT(-ENAMETOOLONG);
    525608        memcpy(pszNativePath, pszUserPath, cch + 1);
    526609    }
     
    551634 * @returns -1 and errno on failure.
    552635 * @param   pszUserPath     The user path.
    553  * @param   pszNativePath   Where to store the native path.
    554  * @param   cchNativePath   Size of the buffer for the native path.
    555  * @param   fVerifyLast     Whether or not to verify the last component of the path.
    556  * @param   pfInUnixTree    Whether or not the path is in the unix tree. Optional.
    557  *
    558  * @remark  For correct operation the caller must lock the FS stuff.
     636 * @parm    fFlags          Flags controlling the operation of the function.
     637 *                          See the BACKFS_FLAGS_* defines.
     638 * @param   pszNativePath   Where to store the native path. This buffer is at
     639 *                          least PATH_MAX bytes big.
     640 * @param   pfInUnixTree    Where to store the result-in-unix-tree indicator. Optional.
    559641 */
    560 static int fsResolveUnix(const char *pszUserPath, int fVerifyLast, char *pszNativePath, size_t cchNativePath, int *pfInUnixTree)
    561 {
    562     LIBCLOG_ENTER("pszUserPath=%p:{%s} fVerifyLast=%d pszNativePath=%p cchNativePath=%d *pfInUnixTree=%p\n",
    563                   (void *)pszUserPath, pszUserPath, fVerifyLast, (void *)pszNativePath, cchNativePath, (void *)pfInUnixTree);
     642int fsResolveUnix(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree)
     643{
     644    LIBCLOG_ENTER("pszUserPath=%p:{%s} pszNativePath=%p *pfInUnixTree=%p\n",
     645                  (void *)pszUserPath, pszUserPath, (void *)pszNativePath, (void *)pfInUnixTree);
    564646    const char *pszUserPathIn = pszUserPath;
    565647    char        szTmp[PATH_MAX];
    566     char        achBuffer[PATH_MAX + 96]; /* Assumes 4 bytes aligned on stack! */
     648    char        _achBuffer[SIZEOF_ACHBUFFER + 4];
     649    char       *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3);
    567650    unsigned    cLoopsLeft = 8;
    568651    int         fInUnixTree = __libc_gfInUnixTree;
    569     int         rcRet = ENAMETOOLONG;
     652    int         rcRet = -ENAMETOOLONG;
     653    HDIR        hDir = HDIR_CREATE;
    570654    FS_VAR()
    571655    FS_SAVE_LOAD();
     
    624708            if (rc)
    625709            {
    626                 rcRet = __libc_native2errno(rc);
     710                rcRet = -__libc_native2errno(rc);
    627711                break;
    628712            }
     
    639723                break;
    640724            memcpy(&szTmp[cch], pszUserPath, cchUserPath);
    641             pszUserPath = memcpy(achBuffer, szTmp, cch + cchUserPath);
     725            pszUserPath = memcpy(pachBuffer, szTmp, cch + cchUserPath);
    642726        }
    643727
     
    645729         * Verify any drive specifier.
    646730         */
    647         if (    pszUserPath[1] == ':'
    648             &&  !(  (*pszUserPath >= 'A' && *pszUserPath <= 'Z')
    649                   ||(*pszUserPath >= 'a' && *pszUserPath <= 'z')) )
    650         {
    651             rcRet = ENOENT;
    652             break;
     731        if (pszUserPath[1] == ':')
     732        {
     733            if (*pszUserPath >= 'a' && *pszUserPath <= 'z')
     734            {
     735                if ((uintptr_t)(pszUserPath - pachBuffer) > SIZEOF_ACHBUFFER)
     736                    pszUserPath = strcpy(pachBuffer, pszUserPath);
     737                *(char *)(void *)pszUserPath += 'A' - 'a';
     738            }
     739            else if (!(*pszUserPath >= 'A' && *pszUserPath <= 'Z'))
     740            {
     741                rcRet = -ENOENT;
     742                break;
     743            }
    653744        }
    654745
     
    675766        else
    676767        {
    677             rcRet = EINVAL;
     768            rcRet = -EINVAL;
    678769            break;
    679770        }
     
    729820            if (cchTmp + iRoot >= PATH_MAX)
    730821                break;
    731             memcpy(achBuffer, szTmp, cchTmp + 1);
     822            memcpy(pachBuffer, szTmp, cchTmp + 1);
    732823            memcpy(szTmp, __libc_gszUnixRoot, iRoot);
    733             memcpy(&szTmp[iRoot], szTmp, cchTmp + 1);
     824            if (cchTmp != 1 || iRoot <= 2)
     825                memcpy(&szTmp[iRoot], pachBuffer, cchTmp + 1);
     826            else
     827                szTmp[iRoot] = '\0';
     828            cchTmp += iRoot;
     829
    734830            fInUnixTree = 1;
    735831        }
     
    758854            if (!psz)
    759855            {
    760                 rcRet = ENOENT;
     856                rcRet = -ENOENT;
    761857                break;
    762858            }
     
    767863        else
    768864        {
    769             if (szTmp[0] == '/')
    770                 pszPrev = &szTmp[1];
    771             else
    772             {
    773                 pszPrev = &szTmp[3];
    774                 LIBC_ASSERT(szTmp[1] == ':' && szTmp[2] == '/');
    775             }
     865            pszPrev = &szTmp[iRoot + 1];
    776866            psz = strchr(pszPrev, '/');
    777867        }
    778         LIBC_ASSERT(iRoot >= pszPrev - &szTmp[0]);
     868        LIBC_ASSERTM(pszPrev - &szTmp[0] >= iRoot, "iRoot=%d  pszPrev offset %d  szTmp=%s\n", iRoot, pszPrev - &szTmp[0], szTmp);
    779869        /* If only one component, we'll check if the fVerifyLast was requested. */
    780         if (!psz && fVerifyLast)
     870        if (    !psz
     871            &&  (fFlags == BACKFS_FLAGS_RESOLVE_FULL || fFlags == BACKFS_FLAGS_RESOLVE_FULL_MAYBE))
    781872            psz = strchr(szTmp, '\0');
    782873
     
    813904                if (!chSlash)
    814905                {
    815                     rcRet = 0;
     906                    rcRet = -0;
    816907                    break;
    817908                }
     
    821912                    if (!*psz)
    822913                    {
    823                         if (!fVerifyLast)
     914                        if (    fFlags != BACKFS_FLAGS_RESOLVE_FULL
     915                            &&  fFlags != BACKFS_FLAGS_RESOLVE_FULL_MAYBE)
    824916                        {
    825                             rcRet = 0;
     917                            rcRet = -0;
    826918                            psz = NULL;
    827919                        }
     
    834926
    835927            /*
    836              * Query the symlink EA value and at the same time verifying the path
    837              * component.
     928             * Check for obviously illegal characters in this path component
     929             * saving us from having DosFindFirst getting '*' and '?'.
    838930             */
    839             EAOP2   EaOp;
    840             EaOp.fpGEA2List = (PGEA2LIST)&gSymlinkGEA2List;
    841             EaOp.fpFEA2List = (PFEA2LIST)achBuffer;
    842             EaOp.oError     = 0;
    843             EaOp.fpFEA2List->cbList = sizeof(achBuffer);
    844             LIBC_ASSERT(!((uintptr_t)&achBuffer[0] & 4));
    845             int rc = DosQueryPathInfo((PCSZ)&szTmp[0], FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
    846             if (rc)
    847             {
    848                 LIBCLOG_MSG("DosQueryPathInfo(%s,,,) -> %d resolving %s\n", szTmp, rc, pszUserPathIn);
    849                 rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? ENOTDIR : __libc_native2errno(rc);
     931            if (strpbrk(pszPrev, "*?"))
     932            {
     933                rcRet = -ENOENT;        /* hmm. will this be correct for all situation? */
    850934                break;
    851935            }
    852936
    853937            /*
    854              * Did we find any symlink EA?
     938             * Find the correct name and to check if it is a directory or not.
     939             * This'll of course also provide proper verification of the path too. :-)
    855940             */
    856             if (EaOp.fpFEA2List->list[0].cbValue)
    857             {
    858                 /* Validate the EA. */
    859                 PUSHORT pusType = (PUSHORT)((char *)&EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);
    860                 char   *pszSymlink = (char *)&pusType[2];
    861                 if (    pusType[0] != EAT_ASCII
    862                     ||  pusType[1] > EaOp.fpFEA2List->list[0].cbValue
    863                     ||  !pusType[1]
    864                     ||  !*pszSymlink)
     941            PFILEFINDBUF4 pFindBuf = (PFILEFINDBUF4)pachBuffer;
     942            ULONG cFiles = 1;
     943            int rc = DosFindFirst((PCSZ)&szTmp[0], &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED,
     944                                  pFindBuf, SIZEOF_ACHBUFFER, &cFiles, FIL_QUERYEASIZE);
     945            if (rc || cFiles == 0)
     946            {
     947                LIBCLOG_MSG("DosFindFirst('%s',,,,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn);
     948                if (fFlags == BACKFS_FLAGS_RESOLVE_FULL_MAYBE && !chSlash)
     949                    rcRet = 0;
     950                else
     951                    rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc);
     952                hDir = HDIR_CREATE;
     953                break;
     954            }
     955            memcpy(pszPrev, pFindBuf->achName, psz - pszPrev);
     956            int     fIsDirectory = (pFindBuf->attrFile & FILE_DIRECTORY) != 0;
     957
     958            /*
     959             * Try querying the symlink EA value.
     960             * (This operation will reuse the achBuffer overwriting the pFindBuf data!)
     961             *
     962             * Yeah, we could do this in the same operation as the DosFindFirst() but
     963             * a little bird told me that level 3 DosFindFirst request had not been
     964             * returning the right things at some point, and besides it's return data
     965             * is rather clumsily laid out. So, I decided not to try my luck on it.
     966             */
     967            if (pFindBuf->cbList > sizeof(USHORT) * 2 + 1)
     968            {
     969                EAOP2   EaOp;
     970                EaOp.fpGEA2List = (PGEA2LIST)&gSymlinkGEA2List;
     971                EaOp.fpFEA2List = (PFEA2LIST)pachBuffer;
     972                EaOp.oError     = 0;
     973                EaOp.fpFEA2List->cbList = SIZEOF_ACHBUFFER;
     974                rc = DosQueryPathInfo((PCSZ)&szTmp[0], FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
     975                if (rc)
    865976                {
    866                     LIBC_ASSERTM_FAILED("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c\n",
    867                                         pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink);
    868                     rcRet = EFTYPE;
     977                    LIBCLOG_MSG("DosQueryPathInfo('%s',,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn);
     978                    if (fFlags == BACKFS_FLAGS_RESOLVE_FULL_MAYBE && !chSlash)
     979                        rcRet = 0;
     980                    else
     981                        rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc);
    869982                    break;
    870983                }
    871984
    872                 /* Cleanup the symlink and find it's length. */
    873                 pszSymlink[pusType[1]] = '\0';
    874                 int cchSymlink = fsCleanPath(pszSymlink);
    875 
    876                 /* Merge symlink with the path. */
    877                 int cchLeft = cchTmp - (psz - &szTmp[0]);
    878                 if (*pszSymlink == '/' || *pszSymlink == '\\' || pszSymlink[1] == ':')
     985                /*
     986                 * Did we find any symlink EA?
     987                 */
     988                if (    EaOp.fpFEA2List->cbList > sizeof(EaOp.fpFEA2List->list[0])
     989                    &&  EaOp.fpFEA2List->list[0].cbValue)
    879990                {
    880                     /*
    881                      * Replace the path up to the current point with the symlink,
    882                      */
    883                     if (cchSymlink + cchLeft + 2 >= PATH_MAX)
     991                    /* Validate the EA. */
     992                    PUSHORT pusType = (PUSHORT)((char *)&EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);
     993                    char   *pszSymlink = (char *)&pusType[2];
     994                    if (    pusType[0] != EAT_ASCII
     995                        ||  pusType[1] > EaOp.fpFEA2List->list[0].cbValue
     996                        ||  !pusType[1]
     997                        ||  !*pszSymlink)
     998                    {
     999                        LIBC_ASSERTM_FAILED("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c\n",
     1000                                            pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink);
     1001                        rcRet = -EFTYPE;
    8841002                        break;
    885                     if (cchLeft)
     1003                    }
     1004
     1005                    /* Cleanup the symlink and find it's length. */
     1006                    pszSymlink[pusType[1]] = '\0';
     1007                    int cchSymlink = fsCleanPath(pszSymlink);
     1008
     1009                    /* Merge symlink with the path. */
     1010                    int cchLeft = cchTmp - (psz - &szTmp[0]);
     1011                    if (*pszSymlink == '/' || *pszSymlink == '\\' || pszSymlink[1] == ':')
    8861012                    {
    887                         if (pszSymlink[cchSymlink - 1] != '/')
     1013                        /*
     1014                         * Replace the path up to the current point with the symlink,
     1015                         */
     1016                        if (cchSymlink + cchLeft + 2 >= PATH_MAX)
     1017                            break;
     1018                        if (cchLeft)
     1019                        {
     1020                            if (pszSymlink[cchSymlink - 1] != '/')
     1021                                pszSymlink[cchSymlink++] = '/';
     1022                            memcpy(&pszSymlink[cchSymlink], psz + 1, cchLeft + 1);
     1023                        }
     1024
     1025                        /* restart the whole shebang. */
     1026                        pszUserPath = pszSymlink;
     1027                        fDone = 0;
     1028                        break;
     1029                    }
     1030                    else
     1031                    {
     1032                        /*
     1033                         * Squeeze the symlink in instead of the current path component.
     1034                         */
     1035                        if (cchSymlink + cchTmp + 2 >= PATH_MAX)
     1036                            break;
     1037                        if (cchLeft)
     1038                        {
    8881039                            pszSymlink[cchSymlink++] = '/';
    889                         memcpy(&pszSymlink[cchSymlink], psz + 1, cchLeft + 1);
     1040                            memcpy(&pszSymlink[cchSymlink], psz + 1, cchLeft + 1);
     1041                            cchSymlink += cchLeft;
     1042                        }
     1043                        memcpy(pszPrev, pszSymlink, cchSymlink + 1);
     1044
     1045                        psz = pszPrev;
     1046                        while (*psz != '/')
     1047                        {
     1048                            if (!*psz)
     1049                            {
     1050                                if (    fFlags != BACKFS_FLAGS_RESOLVE_FULL
     1051                                    &&  fFlags != BACKFS_FLAGS_RESOLVE_FULL_MAYBE)
     1052                                {
     1053                                    rcRet = 0;
     1054                                    psz = NULL;
     1055                                }
     1056                                break;
     1057                            }
     1058                            psz++;
     1059                        }
     1060                        continue;
    8901061                    }
    891 
    892                     /* restart the whole shebang. */
    893                     pszUserPath = pszSymlink;
    894                     fDone = 0;
    895                     break;
    8961062                }
    897                 else
    898                 {
    899                     /*
    900                      * Squeeze the symlink in instead of the current path component.
    901                      */
    902                     if (cchSymlink + cchTmp + 2 >= PATH_MAX)
    903                         break;
    904                     if (cchLeft)
    905                     {
    906                         pszSymlink[cchSymlink++] = '/';
    907                         memcpy(&pszSymlink[cchSymlink], psz + 1, cchLeft + 1);
    908                         cchSymlink += cchLeft;
    909                     }
    910                     memcpy(pszPrev, pszSymlink, cchSymlink + 1);
    911 
    912                     psz = pszPrev;
    913                     while (*psz != '/')
    914                     {
    915                         if (!*psz)
    916                         {
    917                             if (!fVerifyLast)
    918                             {
    919                                 rcRet = 0;
    920                                 psz = NULL;
    921                             }
    922                             break;
    923                         }
    924                         psz++;
    925                     }
    926                     continue;
    927                 }
     1063            }
     1064
     1065            /*
     1066             * If we get here it was not a symlink and we should check if the directoryness
     1067             * of it fit's into the big picture...
     1068             */
     1069            if (!fIsDirectory && chSlash)
     1070            {
     1071                LIBCLOG_MSG("'%s' is not a directory (resolving '%s')\n", szTmp, pszUserPathIn);
     1072                rcRet = -ENOTDIR;
     1073                break;
    9281074            }
    9291075
     
    9421088                if (!*psz)
    9431089                {
    944                     if (!fVerifyLast)
     1090                    if (    fFlags != BACKFS_FLAGS_RESOLVE_FULL
     1091                        &&  fFlags != BACKFS_FLAGS_RESOLVE_FULL_MAYBE)
    9451092                    {
    9461093                        rcRet = 0;
     
    9571104    } /* outer loop */
    9581105
     1106    /*
     1107     * Cleanup find handle.
     1108     */
     1109    if (hDir != HDIR_CREATE)
     1110        DosFindClose(hDir);
     1111    FS_RESTORE();
    9591112
    9601113    /*
     
    9691122            szTmp[cch++] = '\0';
    9701123        }
    971         if (cch <= cchNativePath)
    972         {
    973             memcpy(pszNativePath, szTmp, cch);
    974             if (pfInUnixTree)
    975                 *pfInUnixTree = fInUnixTree;
    976             LIBCLOG_RETURN_INT(0);
    977         }
    978         rcRet = ENAMETOOLONG;
     1124        memcpy(pszNativePath, szTmp, cch);
     1125        if (pfInUnixTree)
     1126            *pfInUnixTree = fInUnixTree;
     1127        LIBCLOG_RETURN_INT(0);
    9791128    }
    9801129
    9811130    /* failure */
    982     errno = rcRet;
    983     LIBCLOG_RETURN_INT(-1);
     1131    LIBCLOG_RETURN_INT(rcRet);
    9841132    pszUserPathIn = pszUserPathIn;
    9851133}
     1134
     1135
     1136/**
     1137 * Creates the unix EAs for a new file or directory.
     1138 * @returns 0 on success.
     1139 * @returns Negative errno on failure.
     1140 * @param   hFile           File handle to the newly created fs object. If no
     1141 *                          handle handy, set to -1.
     1142 * @param   pszNativePath   Native path of the newly created fs object. If
     1143 *                          handle is give this will be ignored.
     1144 * @param   mode            The specified file permission mode mask.
     1145 */
     1146int __libc_back_fsSetUnixAttribs(int hFile, const char *pszNativePath, mode_t mode)
     1147{
     1148    /* later */
     1149    return 0;
     1150}
     1151
  • trunk/src/emx/src/lib/sys/fs.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    3131#include <sys/syslimits.h>
    3232#include <sys/types.h>
     33#include <InnoTekLIBC/sharedpm.h>
     34#include "backend.h"
    3335
     36struct stat;
    3437
    3538__BEGIN_DECLS
     
    4144/** The current unix root. */
    4245extern char __libc_gszUnixRoot[PATH_MAX];
     46/** The current umask of the process. */
     47extern mode_t __libc_gfsUMask;
    4348
     49#ifdef _OS2EMX_H
     50/** @group Large File Support - API pointers.
     51 * Test if the function pointer is set before calling it.
     52 * For APIs which take a structure level parameter, check __pfnDosOpenL.
     53 * @{ */
     54extern ULONG (* _System __libc_gpfnDosOpenL)(PCSZ pszFileName, PHFILE phFile, PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags, ULONG ulOpenMode, PEAOP2 pEABuf);
     55extern ULONG (* _System __libc_gpfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset, ULONG ulOrigin, PLONGLONG pllPos);
     56extern ULONG (* _System __libc_gpfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize);
     57extern ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags);
     58/** @} */
     59#endif
     60
     61/**
     62 * Init the file system stuff.
     63 *
     64 * @returns 0 on success.
     65 * @returns -1 on failure.
     66 */
     67int __libc_back_fsInit(void);
     68
     69/**
     70 * Pack inherit data.
     71 * @returns 0 on success.
     72 * @returns -1 on failure.
     73 * @param   ppFS    Where to store the pointer to the inherit data.
     74 * @param   pcbFS   Where to store the size of the inherit data.
     75 */
     76int __libc_back_fsInheritPack(__LIBC_PSPMINHFS *ppFS, size_t *pcbFS);
    4477
    4578/**
     
    70103 * @returns -1 and errno on failure.
    71104 * @param   pszUserPath     The user path.
    72  * @param   pszNativePath   Where to store the native path.
    73  * @param   cchNativePath   Size of the buffer for the native path.
    74  * @param   fVerify         Whether or not to verify that the path exists.
    75  * @param   pfDrvSpec       Where to store the drive spec indicator. Optional.
    76  *                          *pfDrvSpec will be set if the pszUserPath or any symbolic link
    77  *                          contained pszUserPath referenced contained a drive letter specifier.
     105 * @parm    fFlags          Flags controlling the operation of the function.
     106 *                          See the BACKFS_FLAGS_* defines.
     107 * @param   pszNativePath   Where to store the native path. This buffer is at
     108 *                          least PATH_MAX bytes big.
     109 * @param   pfInUnixTree    Where to store the result-in-unix-tree indicator. Optional.
    78110 */
    79 int __libc_back_fsResolve(const char *pszUserPath, int fVerify, char *pszNativePath, size_t cchNativePath, int *pfDrvSpec);
     111int __libc_back_fsResolve(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree);
     112
     113/** __libc_back_fsResolve() flags.
     114 * @{ */
     115/** Resolves the path up to but not including the last component. */
     116#define BACKFS_FLAGS_RESOLVE_PARENT     0x1
     117/** Resolves and verfies the entire path. */
     118#define BACKFS_FLAGS_RESOLVE_FULL       0x2
     119/** Resolves and verfies the entire path but it's ok if the last component doesn't exist. */
     120#define BACKFS_FLAGS_RESOLVE_FULL_MAYBE 0x3
     121/** @} */
     122
    80123
    81124/**
    82  * Creates a symlink.
     125 * Creates the unix EAs for a new file or directory.
     126 * @returns 0 on success.
     127 * @returns Negative errno on failure.
     128 * @param   hFile           File handle to the newly created fs object. If no
     129 *                          handle handy, set to -1.
     130 * @param   pszNativePath   Native path of the newly created fs object. If
     131 *                          handle is give this will be ignored.
     132 * @param   mode            The specified file permission mode mask.
     133 */
     134int __libc_back_fsSetUnixAttribs(int hFile, const char *pszNativePath, mode_t mode);
     135
     136
     137/**
     138 * Creates a symbolic link.
    83139 *
    84140 * @returns 0 on success.
    85141 * @returns -1 and errno on failure.
    86  * @param   pszTarget       The symlink target.
    87  * @param   pszSymlink      The symlink, the one to be updated.
     142 * @param   pszTarget       The target of the symlink link.
     143 * @param   pszNativePath   The path to the symbolic link to create.
    88144 */
    89 int __libc_Back_fsSymlinkCreate(const char *pszTarget, const char *pszSymlink);
     145int __libc_back_fsNativeSymlinkCreate(const char *pszTarget, const char *pszNativePath);
    90146
    91147/**
    92  * Reads a symbolic link.
     148 * Reads the content of a symbolic link.
     149 *
     150 * This is weird interface as it will return a truncated result if not
     151 * enough buffer space. It is also weird in that there is no string
     152 * terminator.
     153 *
     154 * @returns Number of bytes returned in pachBuf.
     155 * @returns -1 and errno on failure.
     156 * @param   pszNativePath   The path to the symlink to read.
     157 * @param   pachBuf         Where to store the symlink value.
     158 * @param   cchBuf          Size of buffer.
     159 */
     160int __libc_back_fsNativeSymlinkRead(const char *pszNativePath, char *pachBuf, size_t cchBuf);
     161
     162/**
     163 * Stats a native file.
    93164 *
    94165 * @returns 0 on success.
    95166 * @returns -1 and errno on failure.
    96  * @param   pszPath     The symlink to read.
    97  * @param   pszBuf      Where to read to.
    98  * @param   cchBuf      Size of the buffer.
     167 * @param   pszNativePath   Path to the file to stat. This path is resolved, no
     168 *                          processing required.
     169 * @param   pStat           Where to store the file stats.
    99170 */
    100 int __libc_Back_fsSymlinkRead(const char *pszPath, char *pszBuf, size_t cchBuf);
    101 
     171int __libc_back_fsNativeFileStat(const char *pszNativePath, struct stat *pStat);
    102172
    103173
  • trunk/src/emx/src/lib/sys/largefileio.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    1 /* $Id$ */
    2 /** @file
    3  *
    4  * Large File Support.
    5  *
    6  * Copyright (c) 2003 Dimitry Froloff
    7  * Copyright (c) 2003 knut st. osmundsen <bird-srcspam@anduin.net>
    8  *
    9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU Lesser General Public License as published
    12  * by the Free Software Foundation; either version 2 of the License, or
    13  * (at your option) any later version.
    14  *
    15  * This program is distributed in the hope that it will be useful,
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU Lesser General Public License for more details.
    19  *
    20  * You should have received a copy of the GNU Lesser General Public License
    21  * along with This program; if not, write to the Free Software
    22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23  *
    24  */
    25 
    26 /*******************************************************************************
    27 *   Defined Constants And Macros                                               *
    28 *******************************************************************************/
    29 #define ORD_DOS32OPENL              981
    30 #define ORD_DOS32SETFILEPTRL        988
    31 #define ORD_DOS32SETFILESIZEL       989
    32 #define ORD_DOS32SETFILELOCKSL      986
    33 
    34 /*******************************************************************************
    35 *   Header Files                                                               *
    36 *******************************************************************************/
    37 #define INCL_BASE
    38 #include <os2.h>
    39 #include "syscalls.h"
    40 
    41 
    42 /*******************************************************************************
    43 *   Defined Constants And Macros                                               *
    44 *******************************************************************************/
    45 ULONG (* _System __pfnDosOpenL)(PCSZ pszFileName, PHFILE phFile,
    46     PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags,
    47     ULONG ulOpenMode, PEAOP2 pEABuf) = NULL;
    48 ULONG (* _System __pfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset,
    49     ULONG ulOrigin, PLONGLONG pllPos) = NULL;
    50 ULONG (* _System __pfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize) = NULL;
    51 ULONG (* _System __pfnDosSetFileLocksL)(HFILE hFile,
    52     __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock,
    53     ULONG ulTimeout, ULONG flFlags) = NULL;
    54 
    55 
    56 /**
    57  * Initiates the function pointers to the large file APIs.
    58  *
    59  * I/O functions should test if the function pointer is NULL to determin
    60  * support for large files.
    61  *
    62  * @author  Dimitry Froloff
    63  * @author  knut st. osmundsen <bird-srcspam@anduin.net>
    64  */
    65 void _sys_init_largefileio(void)
    66 {
    67     HMODULE     hmod = NULLHANDLE;
    68 
    69     /* only once! */
    70     if (__pfnDosOpenL)
    71         return;
    72 
    73     /*
    74      * Get a handle to DOSCALLS/DOSCALL1 which is suitable for DosQueryProcAddr.
    75      */
    76     if (DosLoadModule(NULL, 0, (PCSZ)"DOSCALLS", &hmod))
    77     {
    78         /* this is impossible! */
    79 #ifdef DEBUG
    80         asm ("int $3");
    81 #endif
    82         return;
    83     }
    84 
    85     if (    DosQueryProcAddr(hmod, ORD_DOS32OPENL, NULL, (PFN*)(void *)&__pfnDosOpenL)
    86         ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILEPTRL, NULL, (PFN*)(void *)&__pfnDosSetFilePtrL)
    87         ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILESIZEL, NULL, (PFN*)(void *)&__pfnDosSetFileSizeL)
    88         ||  DosQueryProcAddr(hmod, ORD_DOS32SETFILELOCKSL, NULL, (PFN*)(void *)&__pfnDosSetFileLocksL)
    89           )
    90     {
    91         __pfnDosOpenL = NULL;
    92         __pfnDosSetFilePtrL = NULL;
    93         __pfnDosSetFileSizeL = NULL;
    94         __pfnDosSetFileLocksL = NULL;
    95     }
    96     DosFreeModule(hmod);
    97 }
    98 
     1/* dead */
  • trunk/src/emx/src/lib/sys/libcfork.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU General Public License
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/os2error.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/pathrewrite.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    207207
    208208
    209 
    210 /*
    211  * Unix root.
    212  */
    213 /** The unixroot directory. */
    214 static char                 gszUnixRoot[260];
    215 /** /@unixroot/ -> ${UNIXROOT} rewrite rules */
    216 static __LIBC_PATHREWRITE   gBltinRule_unixroot =
    217 {   __LIBC_PRWF_CASE_SENSITIVE | __LIBC_PRWF_TYPE_DIR,      "/@unixroot",  10, gszUnixRoot, 0 };
    218 
     209/** Flag which tells if we're initialized or not. */
     210static int gfInited;
    219211
    220212/*******************************************************************************
     
    235227    static void *pfnDummy = __libc_pathRewriteInit;
    236228    LIBCLOG_ENTER("\n");
    237     const char *psz;
    238 
    239     /*
    240      * Extra unix features.
    241      */
    242     if (!__libc_gfNoUnix)
    243     {
    244         /*
    245          * Check for unixroot.
    246          */
    247         psz = getenv("UNIXROOT");
    248         if (psz)
    249         {
    250             size_t cch = strlen(psz);
    251             if (cch < sizeof(gszUnixRoot) - 1)
    252             {
    253                 memcpy(gszUnixRoot, psz, cch + 1);
    254                 gBltinRule_unixroot.cchTo = cch;
    255                 __libc_PathRewriteAdd(&gBltinRule_unixroot, 1);
    256             }
    257         }
    258     }
     229    if (gfInited)
     230        LIBCLOG_RETURN_VOID();
     231    gfInited = 1;
    259232
    260233    /*
    261234     * Check for the presense of the variable.
    262235     */
    263     psz = getenv("LIBC_PATHREWRITERS");
     236    const char *psz = getenv("LIBC_PATHREWRITERS");
    264237    if (!psz || !*psz)
    265238        LIBCLOG_RETURN_MSG_VOID("no rewriters\n");
     
    445418         */
    446419        cch = strlen(paRules[i].pszTo);
    447         if (cch != paRules[i].cchTo)
     420        if (cch != paRules[i].cchTo || !cch)
    448421        {
    449422            LIBC_ASSERTM_FAILED("rule %d: invalid TO length. actual=%d given=%d\n", i, cch, paRules[i].cchTo);
    450423            LIBCLOG_RETURN_INT(-1);
    451424        }
    452         if (    paRules[i].pszTo[cch - 1] == '\\'
    453             ||  paRules[i].pszTo[cch - 1] == '/')
     425        if (    !(cch == 1  || (cch == 3 && paRules[i].pszTo[1] == ':'))
     426            && (    paRules[i].pszTo[cch - 1] == '\\'
     427                ||  paRules[i].pszTo[cch - 1] == '/') )
    454428        {
    455429            LIBC_ASSERTM_FAILED("rule %d: invalid TO ends with slash.\n", i);
    456430            LIBCLOG_RETURN_INT(-1);
    457431        }
     432
    458433
    459434        /*
     
    578553    LIBCLOG_ENTER("paRules=%p cRules=%d\n", (void*)paRules, cRules);
    579554    int i;
     555
     556    /* 'Random' init order forces this. :/ */
     557    if (!gfInited)
     558         __libc_pathRewriteInit();
    580559
    581560    /*
     
    720699    int i;
    721700
     701    /* 'Random' init order forces this. :/ */
     702    if (!gfInited)
     703         __libc_pathRewriteInit();
     704
    722705    /*
    723706     * Validation.
     
    859842    const char         *psz;
    860843    const char         *pszBest;
     844
     845    /* 'Random' init order forces this. :/ */
     846    if (!gfInited)
     847         __libc_pathRewriteInit();
    861848
    862849    /*
  • trunk/src/emx/src/lib/sys/resource.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1111 *
    1212 * InnoTek LIBC is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
    1515 * (at your option) any later version.
    1616 *
     
    1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
     20 * GNU Lesser General Public License for more details.
    2121 *
    22  * You should have received a copy of the GNU General Public License
     22 * You should have received a copy of the GNU Lesser General Public License
    2323 * along with InnoTek LIBC; if not, write to the Free Software
    2424 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/seterrno.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    44#include <errno.h>
    55#include "syscalls.h"
    6 
    7 extern int errno;
     6#include "backend.h"
    87
    98static unsigned char const errno_tab[] =
  • trunk/src/emx/src/lib/sys/sharedpm.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1518 r1519  
    1111 *
    1212 * InnoTek LIBC is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
    1515 * (at your option) any later version.
    1616 *
     
    1818 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
    21  *
    22  * You should have received a copy of the GNU General Public License
     20 * GNU Lesser General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU Lesser General Public License
    2323 * along with InnoTek LIBC; if not, write to the Free Software
    2424 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     
    109109static int  spmForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation);
    110110static void spmCrtInit1(void);
     111static int  spmRequestMutexErrno(__LIBC_PSPMXCPTREGREC pRegRec);
    111112static int  spmRequestMutex(__LIBC_PSPMXCPTREGREC pRegRec);
    112113static int  spmReleaseMutex(__LIBC_PSPMXCPTREGREC pRegRec);
     
    162163     */
    163164    FS_SAVE_LOAD();
    164     if (!spmRequestMutex(&RegRec))
     165    if (!spmRequestMutexErrno(&RegRec))
    165166    {
    166167        /*
     
    230231        FS_SAVE_LOAD();
    231232        DosGetInfoBlocks(&pTib, &pPib);
    232         if (spmRequestMutex(&RegRec))
     233        if (spmRequestMutexErrno(&RegRec))
    233234            LIBCLOG_RETURN_P(NULL);
    234235        if (!gpSPMSelf)
     
    257258    __LIBC_PSPMINHERIT      pRet = NULL;
    258259    __LIBC_SPMXCPTREGREC    RegRec;
    259     if (!spmRequestMutex(&RegRec))
     260    if (!spmRequestMutexErrno(&RegRec))
    260261    {
    261262        if ((pRet = gpSPMSelf->pInherit) != NULL)
     
    285286    LIBCLOG_ENTER("\n");
    286287    __LIBC_SPMXCPTREGREC    RegRec;
    287     int rc = spmRequestMutex(&RegRec);
     288    int rc = spmRequestMutexErrno(&RegRec);
    288289    if (!rc)
    289290    {
     
    312313    {
    313314        __LIBC_SPMXCPTREGREC    RegRec;
    314         if (!spmRequestMutex(&RegRec))
     315        if (!spmRequestMutexErrno(&RegRec))
    315316        {
    316317            if (gpSPMSelf->pInherit)
     
    358359     * Get mutex.
    359360     */
    360     if (spmRequestMutex(&RegRec))
     361    if (spmRequestMutexErrno(&RegRec))
    361362        LIBCLOG_RETURN_P(NULL);
    362363
     
    448449     * Request mutex.
    449450     */
    450     if (spmRequestMutex(&RegRec))
     451    if (spmRequestMutexErrno(&RegRec))
    451452        LIBCLOG_RETURN_P(NULL);
    452453
     
    501502     * Request mutex.
    502503     */
    503     if (spmRequestMutex(&RegRec))
     504    if (spmRequestMutexErrno(&RegRec))
    504505        LIBCLOG_RETURN_P(NULL);
    505506
     
    545546     * Obtain semaphore.
    546547     */
    547     if (spmRequestMutex(&RegRec))
     548    if (spmRequestMutexErrno(&RegRec))
    548549        LIBCLOG_RETURN_INT(-1);
    549550
     
    585586{
    586587    LIBCLOG_ENTER("\n");
    587     int rc = spmRequestMutex(pRegRec);
    588     LIBCLOG_RETURN_INT(rc);
     588    int rc = spmRequestMutexErrno(pRegRec);
     589    if (!rc)
     590        LIBCLOG_RETURN_INT(0);
     591    errno = rc;
     592    LIBCLOG_RETURN_INT(-1);
    589593}
    590594
     
    602606    LIBCLOG_ENTER("\n");
    603607    int rc = spmReleaseMutex(pRegRec);
    604     LIBCLOG_RETURN_INT(rc);
     608    if (!rc)
     609        LIBCLOG_RETURN_INT(0);
     610    errno = rc;
     611    LIBCLOG_RETURN_INT(-1);
    605612}
    606613
     
    632639     * Request access to shared memory.
    633640     */
    634     if (spmRequestMutex(&RegRec))
     641    if (spmRequestMutexErrno(&RegRec))
    635642        LIBCLOG_RETURN_P(NULL);
    636643
     
    676683     * Take sem.
    677684     */
    678     if (spmRequestMutex(&RegRec))
     685    if (spmRequestMutexErrno(&RegRec))
    679686        LIBCLOG_RETURN_INT(-1);
    680687
     
    819826 *
    820827 * @returns 0 on success.
    821  * @returns -1 and errno on failure.
     828 * @returns Negative error code (errno.h) on failure.
    822829 * @param   pLoadAvg    Where to store the load average samples.
    823830 * @param   puTimestamp Where to store the current timestamp.
     
    842849    *puTimestamp = spmTimestamp();
    843850
    844     return rc;
     851    return 0;
    845852}
    846853
     
    850857 *
    851858 * @returns 0 on success.
    852  * @returns -1 and errno on failure.
     859 * @returns Negative error code (errno.h) on failure.
    853860 * @param   pLoadAvg    Where to store the load average samples.
    854861 */
     
    863870    LoadAvg.uTimestamp = spmTimestamp();
    864871
    865     rc = spmRequestMutex(&RegRec);
     872    rc = spmRequestMutexErrno(&RegRec);
    866873    if (rc)
    867874        return rc;
     
    870877
    871878    spmReleaseMutex(&RegRec);
    872     return rc;
     879    return 0;
    873880}
    874881
     
    888895    int                     rc;
    889896
    890     rc = spmRequestMutex(&RegRec);
     897    rc = spmRequestMutexErrno(&RegRec);
    891898    if (rc)
    892899        return rc;
     
    981988
    982989
    983 
    984990/**
    985991 * Requests the shared mutex semphore and checks that we're
    986992 * successfully initialized.
    987993 * @internal
     994 */
     995static int spmRequestMutexErrno(__LIBC_PSPMXCPTREGREC pRegRec)
     996{
     997    int rc = spmRequestMutex(pRegRec);
     998    if (!rc)
     999        return 0;
     1000    errno = rc;
     1001    return -1;
     1002}
     1003
     1004
     1005/**
     1006 * Requests the shared mutex semphore and checks that we're
     1007 * successfully initialized.
     1008 * @internal
     1009 * @returns 0 on success.
     1010 * @returns Negative error code (errno.h) on failure.
    9881011 */
    9891012static int spmRequestMutex(__LIBC_PSPMXCPTREGREC pRegRec)
     
    10101033         * Perform lazy init.
    10111034         */
    1012         if (!spmInit())
     1035        rc = spmInit();
     1036        if (!rc)
    10131037        {
    10141038            FS_RESTORE();
     
    10191043        DosUnsetExceptionHandler(&pRegRec->Core);
    10201044        FS_RESTORE();
    1021         LIBCLOG_RETURN_INT(-1);
     1045        LIBCLOG_RETURN_INT(rc);
    10221046    }
    10231047
     
    10371061        LIBC_ASSERTM_FAILED("Nested access to shared memory is not allowed\n");
    10381062        DosReleaseMutexSem(ghmtxSPM);
    1039         errno = EBUSY;
     1063        rc = -EBUSY;
    10401064    }
    10411065    else
     
    10431067        /* @todo recover from owner died. */
    10441068        LIBC_ASSERTM_FAILED("DosRequestMutexSem(%lu) failed with rc=%d!\n", ghmtxSPM, rc);
    1045         _sys_set_errno(rc);
     1069        rc = -__libc_native2errno(rc);
    10461070    }
    10471071
     
    10491073    DosExitMustComplete(&ul);
    10501074    FS_RESTORE();
    1051     LIBCLOG_RETURN_INT(-1);
     1075    LIBCLOG_RETURN_INT(rc);
    10521076}
    10531077
     
    10911115 *
    10921116 * @returns 0 on success. Mutex is owned.
    1093  * @returns -1 and errno on failure.
     1117 * @returns Negative error code (errno.h) on failure.
    10941118 */
    10951119static int spmInit(void)
     
    11071131    LIBC_ASSERT(!gcNesting);
    11081132    if (gcNesting)
    1109     {
    1110         errno = EINVAL;
    1111         LIBCLOG_RETURN_INT(-1);
    1112     }
     1133        LIBCLOG_RETURN_INT(-EINVAL);
    11131134
    11141135    /*
     
    11361157                LIBC_ASSERTM_FAILED("Failed to open mutex. rc=%d rc2=%d\n", rc, rc2);
    11371158                ghmtxSPM = NULLHANDLE;
    1138                 _sys_set_errno(rc);
    1139                 LIBCLOG_RETURN_INT(-1);
     1159                rc = -__libc_native2errno(rc);
     1160                LIBCLOG_RETURN_INT(rc);
    11401161            }
    11411162        }
     
    12311252     */
    12321253    LIBCLOG_MSG("Failed rc=%d\n", rc);
    1233     _sys_set_errno(rc);
    12341254    DosCloseMutexSem(ghmtxSPM);
    12351255    ghmtxSPM = NULLHANDLE;
     
    12371257    gpSPMSelf = NULL;
    12381258    FS_RESTORE();
    1239     LIBCLOG_RETURN_INT(-1);
     1259    rc = -__libc_native2errno(rc);
     1260    LIBCLOG_RETURN_INT(rc);
    12401261}
    12411262
     
    13111332    FS_SAVE_LOAD();
    13121333    DosGetInfoBlocks(&pTib, &pPib);
    1313     if (!spmRequestMutex(&RegRec))
     1334    if (!spmRequestMutexErrno(&RegRec))
    13141335    {
    13151336        /*
  • trunk/src/emx/src/lib/sys/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.13 to 1.14
    r1518 r1519  
    4848};
    4949
    50 EXTERN int _sys_umask INIT (0022);
    5150EXTERN unsigned _sys_uflags INIT (0);
    5251EXTERN unsigned long _sys_clock0_ms INIT (0);
     
    8685
    8786#if defined (_OS2EMX_H)
    88 
    89 /** @group Large File Support - API pointers.
    90  * Test if the function pointer is set before calling it.
    91  * For APIs which take a structure level parameter, check __pfnDosOpenL.
    92  * @{ */
    93 extern ULONG (* _System __pfnDosOpenL)(PCSZ pszFileName, PHFILE phFile,
    94     PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags,
    95     ULONG ulOpenMode, PEAOP2 pEABuf);
    96 extern ULONG (* _System __pfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset,
    97     ULONG ulOrigin, PLONGLONG pllPos);
    98 extern ULONG (* _System __pfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize);
    99 extern ULONG (* _System __pfnDosSetFileLocksL)(HFILE hFile,
    100     __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock,
    101     ULONG ulTimeout, ULONG flFlags);
    102 /** @} */
    103 
    10487
    10588/** Test if a DOS/OS2 file time is zero. */
  • trunk/src/emx/src/lib/sys/tcpip.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1818 *
    1919 * InnoTek LIBC is free software; you can redistribute it and/or modify
    20  * it under the terms of the GNU General Public License as published by
    21  * the Free Software Foundation; either version 2 of the License, or
     20 * it under the terms of the GNU Lesser General Public License as published
     21 * by the Free Software Foundation; either version 2 of the License, or
    2222 * (at your option) any later version.
    2323 *
     
    2525 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2626 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    27  * GNU General Public License for more details.
     27 * GNU Lesser General Public License for more details.
    2828 *
    29  * You should have received a copy of the GNU General Public License
     29 * You should have received a copy of the GNU Lesser General Public License
    3030 * along with InnoTek LIBC; if not, write to the Free Software
    3131 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/tcpipver.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1518 r1519  
    1414 *
    1515 * InnoTek LIBC is free software; you can redistribute it and/or modify
    16  * it under the terms of the GNU General Public License as published by
    17  * the Free Software Foundation; either version 2 of the License, or
     16 * it under the terms of the GNU Lesser General Public License as published
     17 * by the Free Software Foundation; either version 2 of the License, or
    1818 * (at your option) any later version.
    1919 *
     
    2121 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2222 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  * GNU General Public License for more details.
    24  *
    25  * You should have received a copy of the GNU General Public License
     23 * GNU Lesser General Public License for more details.
     24 *
     25 * You should have received a copy of the GNU Lesser General Public License
    2626 * along with InnoTek LIBC; if not, write to the Free Software
    2727 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/timebomb.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1518 r1519  
    1010 *
    1111 * InnoTek LIBC is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
     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
    1414 * (at your option) any later version.
    1515 *
     
    1717 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
     19 * GNU Lesser General Public License for more details.
    2020 *
    21  * You should have received a copy of the GNU General Public License
     21 * You should have received a copy of the GNU Lesser General Public License
    2222 * along with InnoTek LIBC; if not, write to the Free Software
    2323 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  • trunk/src/emx/src/lib/sys/umask.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1518 r1519  
    1 /* sys/umask.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     1/* $Id: $ *//* $Id: $ */
     2/** @file
     3 *
     4 * LIBC SYS Backend - umask.
     5 *
     6 * Copyright (c) 2004 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*   Header Files                                                               *
     29*******************************************************************************/
    330#include "libc-alias.h"
    4 #include <emx/syscalls.h>
     31#include "fs.h"
     32#include <386/builtin.h>
    533#include <sys/stat.h>
    6 #include "syscalls.h"
     34#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     35#include <InnoTekLIBC/logstrict.h>
    736
    8 mode_t _STD(umask) (int pmode)
     37
     38/**
     39 * Sets the umask to mask & 0777.
     40 *
     41 * The umask is used by open(), creat(), mkdir(), mkfifo(),
     42 * mknod(), mq_open() and sem_open() to set the initial permissions
     43 * for an newly created object.
     44 *
     45 * @returns The old umask. (Will never fail!)
     46 * @param   mask    The new umask.
     47 */
     48mode_t _STD(umask)(mode_t mask)
    949{
    10   mode_t old;
     50    LIBCLOG_ENTER("mask=0%o\n", mask);
     51    mask &= 0777;
     52    mode_t rc = __atomic_xchg((volatile unsigned *)&__libc_gfsUMask, mask); /* (paranoia^2) */
     53    LIBCLOG_RETURN_MSG(rc, "ret 0%o (%d)\n", rc, rc);
     54}
    1155
    12   old = _sys_umask;
    13   _sys_umask = pmode;
    14   return old;
    15 }
Note: See TracChangeset for help on using the changeset viewer.