forked from KolibriOS/kolibrios
newlib: update
git-svn-id: svn://kolibrios.org@5215 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
626b281b77
commit
35d9f2ccf2
@ -15,7 +15,7 @@ LIBC_INCLUDES = $(LIBC_TOPDIR)/include
|
|||||||
|
|
||||||
NAME:= libc
|
NAME:= libc
|
||||||
|
|
||||||
DEFINES:= -D_IEEE_LIBM
|
DEFINES:= -D_IEEE_LIBM -DHAVE_RENAME
|
||||||
|
|
||||||
INCLUDES:= -I $(LIBC_INCLUDES)
|
INCLUDES:= -I $(LIBC_INCLUDES)
|
||||||
|
|
||||||
@ -97,27 +97,29 @@ CORE_SRCS:= \
|
|||||||
locale/locale.c \
|
locale/locale.c \
|
||||||
locale/lctype.c \
|
locale/lctype.c \
|
||||||
locale/ldpart.c \
|
locale/ldpart.c \
|
||||||
|
reent/closer.c \
|
||||||
|
reent/fstatr.c \
|
||||||
|
reent/getreent.c \
|
||||||
|
reent/gettimeofdayr.c \
|
||||||
reent/impure.c \
|
reent/impure.c \
|
||||||
reent/init_reent.c \
|
reent/init_reent.c \
|
||||||
reent/getreent.c \
|
|
||||||
reent/mutex.c \
|
|
||||||
reent/gettimeofdayr.c \
|
|
||||||
reent/isattyr.c \
|
reent/isattyr.c \
|
||||||
reent/openr.c \
|
|
||||||
reent/closer.c \
|
|
||||||
reent/linkr.c \
|
reent/linkr.c \
|
||||||
reent/readr.c \
|
|
||||||
reent/lseekr.c \
|
reent/lseekr.c \
|
||||||
reent/fstatr.c \
|
reent/mutex.c \
|
||||||
reent/writer.c \
|
reent/openr.c \
|
||||||
|
reent/readr.c \
|
||||||
|
reent/renamer.c \
|
||||||
|
reent/statr.c \
|
||||||
reent/timesr.c \
|
reent/timesr.c \
|
||||||
reent/unlinkr.c \
|
reent/unlinkr.c \
|
||||||
|
reent/writer.c \
|
||||||
search/qsort.c \
|
search/qsort.c \
|
||||||
search/bsearch.c \
|
search/bsearch.c \
|
||||||
signal/signal.c \
|
signal/signal.c \
|
||||||
|
sys/access.c \
|
||||||
sys/close.c \
|
sys/close.c \
|
||||||
sys/create.c \
|
sys/create.c \
|
||||||
sys/delete.c \
|
|
||||||
sys/errno.c \
|
sys/errno.c \
|
||||||
sys/finfo.c \
|
sys/finfo.c \
|
||||||
sys/fsize.c \
|
sys/fsize.c \
|
||||||
@ -130,6 +132,7 @@ CORE_SRCS:= \
|
|||||||
sys/lseek.c \
|
sys/lseek.c \
|
||||||
sys/open.c \
|
sys/open.c \
|
||||||
sys/read.c \
|
sys/read.c \
|
||||||
|
sys/_rename.c \
|
||||||
sys/stat.c \
|
sys/stat.c \
|
||||||
sys/unlink.c \
|
sys/unlink.c \
|
||||||
sys/write.c \
|
sys/write.c \
|
||||||
@ -267,11 +270,13 @@ STDIO_SRCS= \
|
|||||||
fwrite.c \
|
fwrite.c \
|
||||||
fvwrite.c \
|
fvwrite.c \
|
||||||
fwalk.c \
|
fwalk.c \
|
||||||
|
mktemp.c \
|
||||||
putc.c \
|
putc.c \
|
||||||
puts.c \
|
puts.c \
|
||||||
refill.c \
|
refill.c \
|
||||||
rget.c \
|
rget.c \
|
||||||
remove.c \
|
remove.c \
|
||||||
|
rename.c \
|
||||||
rewind.c \
|
rewind.c \
|
||||||
setvbuf.c \
|
setvbuf.c \
|
||||||
stdio.c \
|
stdio.c \
|
||||||
|
68
contrib/sdk/sources/newlib/libc/reent/statr.c
Normal file
68
contrib/sdk/sources/newlib/libc/reent/statr.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* Reentrant versions of stat system call. This implementation just
|
||||||
|
calls the stat system call. */
|
||||||
|
|
||||||
|
#include <reent.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <_syslist.h>
|
||||||
|
|
||||||
|
/* Some targets provides their own versions of these functions. Those
|
||||||
|
targets should define REENTRANT_SYSCALLS_PROVIDED in
|
||||||
|
TARGET_CFLAGS. */
|
||||||
|
|
||||||
|
#ifdef _REENT_ONLY
|
||||||
|
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
#define REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
||||||
|
|
||||||
|
int _dummy_stat_syscalls = 1;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* We use the errno variable used by the system dependent layer. */
|
||||||
|
#undef errno
|
||||||
|
extern int errno;
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
<<_stat_r>>---Reentrant version of stat
|
||||||
|
|
||||||
|
INDEX
|
||||||
|
_stat_r
|
||||||
|
|
||||||
|
ANSI_SYNOPSIS
|
||||||
|
#include <reent.h>
|
||||||
|
int _stat_r(struct _reent *<[ptr]>,
|
||||||
|
const char *<[file]>, struct stat *<[pstat]>);
|
||||||
|
|
||||||
|
TRAD_SYNOPSIS
|
||||||
|
#include <reent.h>
|
||||||
|
int _stat_r(<[ptr]>, <[file]>, <[pstat]>)
|
||||||
|
struct _reent *<[ptr]>;
|
||||||
|
char *<[file]>;
|
||||||
|
struct stat *<[pstat]>;
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
This is a reentrant version of <<stat>>. It
|
||||||
|
takes a pointer to the global data block, which holds
|
||||||
|
<<errno>>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN (_stat_r, (ptr, file, pstat),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
_CONST char *file _AND
|
||||||
|
struct stat *pstat)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
if ((ret = _stat (file, pstat)) == -1 && errno != 0)
|
||||||
|
ptr->_errno = errno;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|
385
contrib/sdk/sources/newlib/libc/stdio/mktemp.c
Normal file
385
contrib/sdk/sources/newlib/libc/stdio/mktemp.c
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1987 Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms are permitted
|
||||||
|
* provided that: (1) source distributions retain this entire copyright
|
||||||
|
* notice and comment, and (2) distributions including binaries display
|
||||||
|
* the following acknowledgement: ``This product includes software
|
||||||
|
* developed by the University of California, Berkeley and its contributors''
|
||||||
|
* in the documentation or other materials provided with the distribution
|
||||||
|
* and in all advertising materials mentioning features or use of this
|
||||||
|
* software. Neither the name of the University nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
/* This is file MKTEMP.C */
|
||||||
|
/* This file may have been modified by DJ Delorie (Jan 1991). If so,
|
||||||
|
** these modifications are Copyright (C) 1991 DJ Delorie.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
FUNCTION
|
||||||
|
<<mktemp>>, <<mkstemp>>, <<mkostemp>>, <<mkstemps>>,
|
||||||
|
<<mkostemps>>---generate unused file name
|
||||||
|
<<mkdtemp>>---generate unused directory
|
||||||
|
|
||||||
|
INDEX
|
||||||
|
mktemp
|
||||||
|
INDEX
|
||||||
|
mkdtemp
|
||||||
|
INDEX
|
||||||
|
mkstemp
|
||||||
|
INDEX
|
||||||
|
mkstemps
|
||||||
|
INDEX
|
||||||
|
mkostemp
|
||||||
|
INDEX
|
||||||
|
mkostemps
|
||||||
|
INDEX
|
||||||
|
_mktemp_r
|
||||||
|
INDEX
|
||||||
|
_mkdtemp_r
|
||||||
|
INDEX
|
||||||
|
_mkstemp_r
|
||||||
|
INDEX
|
||||||
|
_mkstemps_r
|
||||||
|
INDEX
|
||||||
|
_mkostemp_r
|
||||||
|
INDEX
|
||||||
|
_mkostemps_r
|
||||||
|
|
||||||
|
ANSI_SYNOPSIS
|
||||||
|
#include <stdlib.h>
|
||||||
|
char *mktemp(char *<[path]>);
|
||||||
|
char *mkdtemp(char *<[path]>);
|
||||||
|
int mkstemp(char *<[path]>);
|
||||||
|
int mkstemps(char *<[path]>, int <[suffixlen]>);
|
||||||
|
int mkostemp(char *<[path]>, int <[flags]>);
|
||||||
|
int mkostemps(char *<[path]>, int <[suffixlen]>, int <[flags]>);
|
||||||
|
|
||||||
|
char *_mktemp_r(struct _reent *<[reent]>, char *<[path]>);
|
||||||
|
char *_mkdtemp_r(struct _reent *<[reent]>, char *<[path]>);
|
||||||
|
int *_mkstemp_r(struct _reent *<[reent]>, char *<[path]>);
|
||||||
|
int *_mkstemps_r(struct _reent *<[reent]>, char *<[path]>, int <[len]>);
|
||||||
|
int *_mkostemp_r(struct _reent *<[reent]>, char *<[path]>,
|
||||||
|
int <[flags]>);
|
||||||
|
int *_mkostemps_r(struct _reent *<[reent]>, char *<[path]>, int <[len]>,
|
||||||
|
int <[flags]>);
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
<<mktemp>>, <<mkstemp>>, and <<mkstemps>> attempt to generate a file name
|
||||||
|
that is not yet in use for any existing file. <<mkstemp>> and <<mkstemps>>
|
||||||
|
create the file and open it for reading and writing; <<mktemp>> simply
|
||||||
|
generates the file name (making <<mktemp>> a security risk). <<mkostemp>>
|
||||||
|
and <<mkostemps>> allow the addition of other <<open>> flags, such
|
||||||
|
as <<O_CLOEXEC>>, <<O_APPEND>>, or <<O_SYNC>>. On platforms with a
|
||||||
|
separate text mode, <<mkstemp>> forces <<O_BINARY>>, while <<mkostemp>>
|
||||||
|
allows the choice between <<O_BINARY>>, <<O_TEXT>>, or 0 for default.
|
||||||
|
<<mkdtemp>> attempts to create a directory instead of a file, with a
|
||||||
|
permissions mask of 0700.
|
||||||
|
|
||||||
|
You supply a simple pattern for the generated file name, as the string
|
||||||
|
at <[path]>. The pattern should be a valid filename (including path
|
||||||
|
information if you wish) ending with at least six `<<X>>'
|
||||||
|
characters. The generated filename will match the leading part of the
|
||||||
|
name you supply, with the trailing `<<X>>' characters replaced by some
|
||||||
|
combination of digits and letters. With <<mkstemps>>, the `<<X>>'
|
||||||
|
characters end <[suffixlen]> bytes before the end of the string.
|
||||||
|
|
||||||
|
The alternate functions <<_mktemp_r>>, <<_mkdtemp_r>>, <<_mkstemp_r>>,
|
||||||
|
<<_mkostemp_r>>, <<_mkostemps_r>>, and <<_mkstemps_r>> are reentrant
|
||||||
|
versions. The extra argument <[reent]> is a pointer to a reentrancy
|
||||||
|
structure.
|
||||||
|
|
||||||
|
RETURNS
|
||||||
|
<<mktemp>> returns the pointer <[path]> to the modified string
|
||||||
|
representing an unused filename, unless it could not generate one, or
|
||||||
|
the pattern you provided is not suitable for a filename; in that case,
|
||||||
|
it returns <<NULL>>. Be aware that there is an inherent race between
|
||||||
|
generating the name and attempting to create a file by that name;
|
||||||
|
you are advised to use <<O_EXCL|O_CREAT>>.
|
||||||
|
|
||||||
|
<<mkdtemp>> returns the pointer <[path]> to the modified string if the
|
||||||
|
directory was created, otherwise it returns <<NULL>>.
|
||||||
|
|
||||||
|
<<mkstemp>>, <<mkstemps>>, <<mkostemp>>, and <<mkostemps>> return a file
|
||||||
|
descriptor to the newly created file, unless it could not generate an
|
||||||
|
unused filename, or the pattern you provided is not suitable for a
|
||||||
|
filename; in that case, it returns <<-1>>.
|
||||||
|
|
||||||
|
NOTES
|
||||||
|
Never use <<mktemp>>. The generated filenames are easy to guess and
|
||||||
|
there's a race between the test if the file exists and the creation
|
||||||
|
of the file. In combination this makes <<mktemp>> prone to attacks
|
||||||
|
and using it is a security risk. Whenever possible use <<mkstemp>>
|
||||||
|
instead. It doesn't suffer the race condition.
|
||||||
|
|
||||||
|
PORTABILITY
|
||||||
|
ANSI C does not require either <<mktemp>> or <<mkstemp>>; the System
|
||||||
|
V Interface Definition requires <<mktemp>> as of Issue 2. POSIX 2001
|
||||||
|
requires <<mkstemp>>, and POSIX 2008 requires <<mkdtemp>> while
|
||||||
|
deprecating <<mktemp>>. <<mkstemps>>, <<mkostemp>>, and <<mkostemps>>
|
||||||
|
are not standardized.
|
||||||
|
|
||||||
|
Supporting OS subroutines required: <<getpid>>, <<mkdir>>, <<open>>, <<stat>>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <_ansi.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <reent.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
_DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen, flags),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path _AND
|
||||||
|
register int *doopen _AND
|
||||||
|
int domkdir _AND
|
||||||
|
size_t suffixlen _AND
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
register char *start, *trv;
|
||||||
|
char *end;
|
||||||
|
#ifdef __USE_INTERNAL_STAT64
|
||||||
|
struct stat64 sbuf;
|
||||||
|
#else
|
||||||
|
struct stat sbuf;
|
||||||
|
#endif
|
||||||
|
unsigned int pid;
|
||||||
|
|
||||||
|
pid = _getpid_r (ptr);
|
||||||
|
for (trv = path; *trv; ++trv) /* extra X's get set to 0's */
|
||||||
|
continue;
|
||||||
|
if (trv - path < suffixlen)
|
||||||
|
{
|
||||||
|
ptr->_errno = EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
trv -= suffixlen;
|
||||||
|
end = trv;
|
||||||
|
while (path < trv && *--trv == 'X')
|
||||||
|
{
|
||||||
|
*trv = (pid % 10) + '0';
|
||||||
|
pid /= 10;
|
||||||
|
}
|
||||||
|
if (end - trv < 6)
|
||||||
|
{
|
||||||
|
ptr->_errno = EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the target directory; if you have six X's and it
|
||||||
|
* doesn't exist this runs for a *very* long time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (start = trv + 1;; --trv)
|
||||||
|
{
|
||||||
|
if (trv <= path)
|
||||||
|
break;
|
||||||
|
if (*trv == '/')
|
||||||
|
{
|
||||||
|
*trv = '\0';
|
||||||
|
#ifdef __USE_INTERNAL_STAT64
|
||||||
|
if (_stat64_r (ptr, path, &sbuf))
|
||||||
|
#else
|
||||||
|
if (_stat_r (ptr, path, &sbuf))
|
||||||
|
#endif
|
||||||
|
return (0);
|
||||||
|
if (!(sbuf.st_mode & S_IFDIR))
|
||||||
|
{
|
||||||
|
ptr->_errno = ENOTDIR;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
*trv = '/';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
#if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4
|
||||||
|
if (domkdir)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_MKDIR
|
||||||
|
if (_mkdir_r (ptr, path, 0700) == 0)
|
||||||
|
return 1;
|
||||||
|
if (ptr->_errno != EEXIST)
|
||||||
|
return 0;
|
||||||
|
#else /* !HAVE_MKDIR */
|
||||||
|
ptr->_errno = ENOSYS;
|
||||||
|
return 0;
|
||||||
|
#endif /* !HAVE_MKDIR */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* _ELIX_LEVEL */
|
||||||
|
if (doopen)
|
||||||
|
{
|
||||||
|
if ((*doopen = _open_r (ptr, path, O_CREAT | O_EXCL | O_RDWR | flags,
|
||||||
|
0600)) >= 0)
|
||||||
|
return 1;
|
||||||
|
if (ptr->_errno != EEXIST)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef __USE_INTERNAL_STAT64
|
||||||
|
else if (_stat64_r (ptr, path, &sbuf))
|
||||||
|
#else
|
||||||
|
else if (_stat_r (ptr, path, &sbuf))
|
||||||
|
#endif
|
||||||
|
return (ptr->_errno == ENOENT ? 1 : 0);
|
||||||
|
|
||||||
|
/* tricky little algorithm for backward compatibility */
|
||||||
|
for (trv = start;;)
|
||||||
|
{
|
||||||
|
if (trv == end)
|
||||||
|
return 0;
|
||||||
|
if (*trv == 'z')
|
||||||
|
*trv++ = 'a';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Safe, since it only encounters 7-bit characters. */
|
||||||
|
if (isdigit ((unsigned char) *trv))
|
||||||
|
*trv = 'a';
|
||||||
|
else
|
||||||
|
++ * trv;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
# define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(_mkstemp_r, (ptr, path),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (ptr, path, &fd, 0, 0, O_BINARY) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4
|
||||||
|
char *
|
||||||
|
_DEFUN(_mkdtemp_r, (ptr, path),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
return (_gettemp (ptr, path, (int *) NULL, 1, 0, 0) ? path : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(_mkstemps_r, (ptr, path, len),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path _AND
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (ptr, path, &fd, 0, len, O_BINARY) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(_mkostemp_r, (ptr, path, flags),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path _AND
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (ptr, path, &fd, 0, 0, flags & ~O_ACCMODE) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(_mkostemps_r, (ptr, path, len, flags),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path _AND
|
||||||
|
int len _AND
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (ptr, path, &fd, 0, len, flags & ~O_ACCMODE) ? fd : -1);
|
||||||
|
}
|
||||||
|
#endif /* _ELIX_LEVEL */
|
||||||
|
|
||||||
|
char *
|
||||||
|
_DEFUN(_mktemp_r, (ptr, path),
|
||||||
|
struct _reent *ptr _AND
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
return (_gettemp (ptr, path, (int *) NULL, 0, 0, 0) ? path : (char *) NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _REENT_ONLY
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(mkstemp, (path),
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (_REENT, path, &fd, 0, 0, O_BINARY) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4
|
||||||
|
char *
|
||||||
|
_DEFUN(mkdtemp, (path),
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
return (_gettemp (_REENT, path, (int *) NULL, 1, 0, 0) ? path : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(mkstemps, (path, len),
|
||||||
|
char *path _AND
|
||||||
|
int len)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (_REENT, path, &fd, 0, len, O_BINARY) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(mkostemp, (path, flags),
|
||||||
|
char *path _AND
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (_REENT, path, &fd, 0, 0, flags & ~O_ACCMODE) ? fd : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN(mkostemps, (path, len, flags),
|
||||||
|
char *path _AND
|
||||||
|
int len _AND
|
||||||
|
int flags)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
return (_gettemp (_REENT, path, &fd, 0, len, flags & ~O_ACCMODE) ? fd : -1);
|
||||||
|
}
|
||||||
|
# endif /* _ELIX_LEVEL */
|
||||||
|
|
||||||
|
char *
|
||||||
|
_DEFUN(mktemp, (path),
|
||||||
|
char *path)
|
||||||
|
{
|
||||||
|
return (_gettemp (_REENT, path, (int *) NULL, 0, 0, 0) ? path : (char *) NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! defined (_REENT_ONLY) */
|
@ -1,70 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms are permitted
|
* Redistribution and use in source and binary forms are permitted
|
||||||
* provided that the above copyright notice and this paragraph are
|
* provided that the above copyright notice and this paragraph are
|
||||||
* duplicated in all such forms and that any documentation,
|
* duplicated in all such forms and that any documentation,
|
||||||
* advertising materials, and other materials related to such
|
* advertising materials, and other materials related to such
|
||||||
* distribution and use acknowledge that the software was developed
|
* distribution and use acknowledge that the software was developed
|
||||||
* by the University of California, Berkeley. The name of the
|
* by the University of California, Berkeley. The name of the
|
||||||
* University may not be used to endorse or promote products derived
|
* University may not be used to endorse or promote products derived
|
||||||
* from this software without specific prior written permission.
|
* from this software without specific prior written permission.
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FUNCTION
|
FUNCTION
|
||||||
<<rename>>---rename a file
|
<<rename>>---rename a file
|
||||||
|
|
||||||
INDEX
|
INDEX
|
||||||
rename
|
rename
|
||||||
|
|
||||||
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int rename(const char *<[old]>, const char *<[new]>);
|
int rename(const char *<[old]>, const char *<[new]>);
|
||||||
|
|
||||||
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int rename(<[old]>, <[new]>)
|
int rename(<[old]>, <[new]>)
|
||||||
char *<[old]>;
|
char *<[old]>;
|
||||||
char *<[new]>;
|
char *<[new]>;
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Use <<rename>> to establish a new name (the string at <[new]>) for a
|
Use <<rename>> to establish a new name (the string at <[new]>) for a
|
||||||
file now known by the string at <[old]>. After a successful
|
file now known by the string at <[old]>. After a successful
|
||||||
<<rename>>, the file is no longer accessible by the string at <[old]>.
|
<<rename>>, the file is no longer accessible by the string at <[old]>.
|
||||||
|
|
||||||
If <<rename>> fails, the file named <<*<[old]>>> is unaffected. The
|
If <<rename>> fails, the file named <<*<[old]>>> is unaffected. The
|
||||||
conditions for failure depend on the host operating system.
|
conditions for failure depend on the host operating system.
|
||||||
|
|
||||||
RETURNS
|
RETURNS
|
||||||
The result is either <<0>> (when successful) or <<-1>> (when the file
|
The result is either <<0>> (when successful) or <<-1>> (when the file
|
||||||
could not be renamed).
|
could not be renamed).
|
||||||
|
|
||||||
PORTABILITY
|
PORTABILITY
|
||||||
ANSI C requires <<rename>>, but only specifies that the result on
|
ANSI C requires <<rename>>, but only specifies that the result on
|
||||||
failure be nonzero. The effects of using the name of an existing file
|
failure be nonzero. The effects of using the name of an existing file
|
||||||
as <<*<[new]>>> may vary from one implementation to another.
|
as <<*<[new]>>> may vary from one implementation to another.
|
||||||
|
|
||||||
Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
|
Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <_ansi.h>
|
#include <_ansi.h>
|
||||||
#include <reent.h>
|
#include <reent.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
|
|
||||||
int
|
int
|
||||||
_DEFUN(rename, (old, new),
|
_DEFUN(rename, (old, new),
|
||||||
_CONST char *old _AND
|
_CONST char *old _AND
|
||||||
_CONST char *new)
|
_CONST char *new)
|
||||||
{
|
{
|
||||||
return _rename_r (_REENT, old, new);
|
return _rename_r (_REENT, old, new);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
71
contrib/sdk/sources/newlib/libc/sys/_rename.c
Normal file
71
contrib/sdk/sources/newlib/libc/sys/_rename.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* _rename.c -- Implementation of the low-level rename() routine
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 National Semiconductor Corporation
|
||||||
|
*
|
||||||
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||||
|
* and license this software and its documentation for any purpose, provided
|
||||||
|
* that existing copyright notices are retained in all copies and that this
|
||||||
|
* notice is included verbatim in any distributions. No written agreement,
|
||||||
|
* license, or royalty fee is required for any of the authorized uses.
|
||||||
|
* Modifications to this software may be copyrighted by their authors
|
||||||
|
* and need not follow the licensing terms described here, provided that
|
||||||
|
* the new terms are clearly indicated on the first page of each file where
|
||||||
|
* they apply.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
|
int _rename (char *from, char *to)
|
||||||
|
{
|
||||||
|
void* buf;
|
||||||
|
int f_from;
|
||||||
|
int f_to;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
printf("%s from %s to %s\n", __FUNCTION__,
|
||||||
|
from, to);
|
||||||
|
|
||||||
|
f_from = open(from,O_RDONLY);
|
||||||
|
|
||||||
|
if (f_from < 0)
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
f_to = open(to,O_CREAT|O_WRONLY|O_EXCL);
|
||||||
|
|
||||||
|
if (f_to < 0)
|
||||||
|
{
|
||||||
|
close(f_from);
|
||||||
|
errno = EACCES;
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
buf = alloca(32768);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size = read(f_from, buf, 32768);
|
||||||
|
|
||||||
|
if (size >= 0)
|
||||||
|
size = write(f_to, buf, size);
|
||||||
|
|
||||||
|
}while (size == 32768);
|
||||||
|
|
||||||
|
close(f_to);
|
||||||
|
close(f_from);
|
||||||
|
|
||||||
|
if (size == -1)
|
||||||
|
{
|
||||||
|
errno = EACCES;
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
remove(from);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
};
|
33
contrib/sdk/sources/newlib/libc/sys/access.c
Normal file
33
contrib/sdk/sources/newlib/libc/sys/access.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* This is file ACCESS.C */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1993 DJ Delorie
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution, modification, and use in source and binary forms is permitted
|
||||||
|
* provided that the above copyright notice and following paragraph are
|
||||||
|
* duplicated in all such forms.
|
||||||
|
*
|
||||||
|
* This file is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int access(const char *fn, int flags)
|
||||||
|
{
|
||||||
|
struct stat s;
|
||||||
|
if (stat(fn, &s))
|
||||||
|
return -1;
|
||||||
|
if (s.st_mode & S_IFDIR)
|
||||||
|
return 0;
|
||||||
|
if (flags & W_OK)
|
||||||
|
{
|
||||||
|
if (s.st_mode & S_IWRITE)
|
||||||
|
return 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ int create_file(const char *path)
|
|||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl $0 \n\t"
|
"pushl $0 \n\t"
|
||||||
"pushl $0 \n\t"
|
"pushl $0 \n\t"
|
||||||
"movl %0, 1(%%esp) \n\t"
|
"movl %1, 1(%%esp) \n\t"
|
||||||
"pushl $0 \n\t"
|
"pushl $0 \n\t"
|
||||||
"pushl $0 \n\t"
|
"pushl $0 \n\t"
|
||||||
"pushl $0 \n\t"
|
"pushl $0 \n\t"
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/kos_io.h>
|
|
||||||
|
|
||||||
int delete_file(const char *path)
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"movl %0, 1(%%esp) \n\t"
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"pushl $0 \n\t"
|
|
||||||
"pushl $8 \n\t"
|
|
||||||
"movl %%esp, %%ebx \n\t"
|
|
||||||
"movl $70, %%eax \n\t"
|
|
||||||
"int $0x40 \n\t"
|
|
||||||
"addl $28, %%esp \n\t"
|
|
||||||
:"=a" (retval)
|
|
||||||
:"r" (path)
|
|
||||||
:"ebx");
|
|
||||||
return retval;
|
|
||||||
};
|
|
||||||
|
|
@ -26,6 +26,8 @@ _DEFUN (fstat, (fd, buf),
|
|||||||
struct stat *buf)
|
struct stat *buf)
|
||||||
{
|
{
|
||||||
fileinfo_t info;
|
fileinfo_t info;
|
||||||
|
struct tm time;
|
||||||
|
|
||||||
__io_handle *ioh;
|
__io_handle *ioh;
|
||||||
|
|
||||||
if( (fd < 0) || (fd >=64) )
|
if( (fd < 0) || (fd >=64) )
|
||||||
@ -47,9 +49,44 @@ _DEFUN (fstat, (fd, buf),
|
|||||||
ioh = &__io_tab[fd];
|
ioh = &__io_tab[fd];
|
||||||
get_fileinfo(ioh->name, &info);
|
get_fileinfo(ioh->name, &info);
|
||||||
|
|
||||||
buf->st_mode = S_IFREG;
|
if (info.attr & 0x10)
|
||||||
|
buf->st_mode = S_IFDIR;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (info.attr & 0x07)
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IXUSR;
|
||||||
|
else
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR|S_IXUSR;
|
||||||
|
}
|
||||||
buf->st_blksize = 4096;
|
buf->st_blksize = 4096;
|
||||||
buf->st_size = info.size;
|
|
||||||
|
time.tm_sec = info.atime.sec;
|
||||||
|
time.tm_min = info.atime.min;
|
||||||
|
time.tm_hour = info.atime.hour;
|
||||||
|
time.tm_mday = info.adate.day;
|
||||||
|
time.tm_mon = info.adate.month;
|
||||||
|
time.tm_year = info.adate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_atime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.ctime.sec;
|
||||||
|
time.tm_min = info.ctime.min;
|
||||||
|
time.tm_hour = info.ctime.hour;
|
||||||
|
time.tm_mday = info.cdate.day;
|
||||||
|
time.tm_mon = info.cdate.month;
|
||||||
|
time.tm_year = info.cdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_ctime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.mtime.sec;
|
||||||
|
time.tm_min = info.mtime.min;
|
||||||
|
time.tm_hour = info.mtime.hour;
|
||||||
|
time.tm_mday = info.mdate.day;
|
||||||
|
time.tm_mon = info.mdate.month;
|
||||||
|
time.tm_year = info.mdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_mtime = mktime(&time);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -128,8 +128,6 @@ int open (const char * filename, int flags, ...)
|
|||||||
buildpath(buf, filename);
|
buildpath(buf, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%s %s\n", __FUNCTION__, buf);
|
|
||||||
|
|
||||||
err = get_fileinfo(buf, &info);
|
err = get_fileinfo(buf, &info);
|
||||||
|
|
||||||
if( flags & O_EXCL &&
|
if( flags & O_EXCL &&
|
||||||
@ -189,8 +187,6 @@ int open (const char * filename, int flags, ...)
|
|||||||
ioh->read = read_file;
|
ioh->read = read_file;
|
||||||
ioh->write = write_file;
|
ioh->write = write_file;
|
||||||
|
|
||||||
// printf("%s %s\n", __FUNCTION__, ioh->name);
|
|
||||||
|
|
||||||
return hid;
|
return hid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
* they apply.
|
* they apply.
|
||||||
*/
|
*/
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/kos_io.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
#include "glue.h"
|
#include "glue.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -24,7 +27,68 @@ _DEFUN (stat, (path, buf),
|
|||||||
const char *path _AND
|
const char *path _AND
|
||||||
struct stat *buf)
|
struct stat *buf)
|
||||||
{
|
{
|
||||||
errno = EIO;
|
|
||||||
return (-1);
|
fileinfo_t info;
|
||||||
|
struct tm time;
|
||||||
|
|
||||||
|
if( get_fileinfo(path, &info))
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return (-1);
|
||||||
|
};
|
||||||
|
|
||||||
|
memset (buf, 0, sizeof (* buf));
|
||||||
|
|
||||||
|
buf->st_size = info.size;
|
||||||
|
|
||||||
|
if (info.attr & 0x10)
|
||||||
|
buf->st_mode = S_IFDIR;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (info.attr & 0x07)
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IXUSR;
|
||||||
|
else
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR|S_IXUSR;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf->st_blksize = 4096;
|
||||||
|
|
||||||
|
time.tm_sec = info.atime.sec;
|
||||||
|
time.tm_min = info.atime.min;
|
||||||
|
time.tm_hour = info.atime.hour;
|
||||||
|
time.tm_mday = info.adate.day;
|
||||||
|
time.tm_mon = info.adate.month;
|
||||||
|
time.tm_year = info.adate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_atime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.ctime.sec;
|
||||||
|
time.tm_min = info.ctime.min;
|
||||||
|
time.tm_hour = info.ctime.hour;
|
||||||
|
time.tm_mday = info.cdate.day;
|
||||||
|
time.tm_mon = info.cdate.month;
|
||||||
|
time.tm_year = info.cdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_ctime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.mtime.sec;
|
||||||
|
time.tm_min = info.mtime.min;
|
||||||
|
time.tm_hour = info.mtime.hour;
|
||||||
|
time.tm_mday = info.mdate.day;
|
||||||
|
time.tm_mon = info.mdate.month;
|
||||||
|
time.tm_year = info.mdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_mtime = mktime(&time);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN (lstat, (path, buf),
|
||||||
|
const char *path _AND
|
||||||
|
struct stat *buf)
|
||||||
|
{
|
||||||
|
return stat(path, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
96
contrib/sdk/sources/newlib/libc/sys/stat.c.bak
Normal file
96
contrib/sdk/sources/newlib/libc/sys/stat.c.bak
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/* stat.c -- Get the status of a file.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1995 Cygnus Support
|
||||||
|
*
|
||||||
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||||
|
* and license this software and its documentation for any purpose, provided
|
||||||
|
* that existing copyright notices are retained in all copies and that this
|
||||||
|
* notice is included verbatim in any distributions. No written agreement,
|
||||||
|
* license, or royalty fee is required for any of the authorized uses.
|
||||||
|
* Modifications to this software may be copyrighted by their authors
|
||||||
|
* and need not follow the licensing terms described here, provided that
|
||||||
|
* the new terms are clearly indicated on the first page of each file where
|
||||||
|
* they apply.
|
||||||
|
*/
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/kos_io.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "glue.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* stat -- Since we have no file system, we just return an error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
_DEFUN (stat, (path, buf),
|
||||||
|
const char *path _AND
|
||||||
|
struct stat *buf)
|
||||||
|
{
|
||||||
|
|
||||||
|
fileinfo_t info;
|
||||||
|
struct tm time;
|
||||||
|
|
||||||
|
printf("%s %s\n", __FUNCTION__, path);
|
||||||
|
|
||||||
|
if( get_fileinfo(path, &info))
|
||||||
|
{
|
||||||
|
errno = ENOENT;
|
||||||
|
return (-1);
|
||||||
|
};
|
||||||
|
|
||||||
|
memset (buf, 0, sizeof (* buf));
|
||||||
|
|
||||||
|
buf->st_size = info.size;
|
||||||
|
|
||||||
|
if (info.attr & 0x10)
|
||||||
|
buf->st_mode = S_IFDIR;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (info.attr & 0x07)
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IXUSR;
|
||||||
|
else
|
||||||
|
buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR|S_IXUSR;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf->st_blksize = 4096;
|
||||||
|
|
||||||
|
time.tm_sec = info.atime.sec;
|
||||||
|
time.tm_min = info.atime.min;
|
||||||
|
time.tm_hour = info.atime.hour;
|
||||||
|
time.tm_mday = info.adate.day;
|
||||||
|
time.tm_mon = info.adate.month;
|
||||||
|
time.tm_year = info.adate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_atime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.ctime.sec;
|
||||||
|
time.tm_min = info.ctime.min;
|
||||||
|
time.tm_hour = info.ctime.hour;
|
||||||
|
time.tm_mday = info.cdate.day;
|
||||||
|
time.tm_mon = info.cdate.month;
|
||||||
|
time.tm_year = info.cdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_ctime = mktime(&time);
|
||||||
|
|
||||||
|
time.tm_sec = info.mtime.sec;
|
||||||
|
time.tm_min = info.mtime.min;
|
||||||
|
time.tm_hour = info.mtime.hour;
|
||||||
|
time.tm_mday = info.mdate.day;
|
||||||
|
time.tm_mon = info.mdate.month;
|
||||||
|
time.tm_year = info.mdate.year - 1900;
|
||||||
|
time.tm_isdst = -1;
|
||||||
|
buf->st_mtime = mktime(&time);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
_DEFUN (lstat, (path, buf),
|
||||||
|
const char *path _AND
|
||||||
|
struct stat *buf)
|
||||||
|
{
|
||||||
|
return stat(path, buf);
|
||||||
|
}
|
||||||
|
|
@ -19,16 +19,48 @@
|
|||||||
|
|
||||||
#include "glue.h"
|
#include "glue.h"
|
||||||
|
|
||||||
/*
|
static int delete_file(const char *path)
|
||||||
* unlink -- since we have no file system,
|
{
|
||||||
* we just return an error.
|
int retval;
|
||||||
*/
|
__asm__ __volatile__ (
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"movl %1, 1(%%esp) \n\t"
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"pushl $0 \n\t"
|
||||||
|
"pushl $8 \n\t"
|
||||||
|
"movl %%esp, %%ebx \n\t"
|
||||||
|
"movl $70, %%eax \n\t"
|
||||||
|
"int $0x40 \n\t"
|
||||||
|
"addl $28, %%esp \n\t"
|
||||||
|
:"=a" (retval)
|
||||||
|
:"r" (path)
|
||||||
|
:"ebx");
|
||||||
|
return retval;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_DEFUN (unlink, (path),
|
_DEFUN (unlink, (path),
|
||||||
char * path)
|
char * path)
|
||||||
{
|
{
|
||||||
errno = EIO;
|
int err;
|
||||||
return (-1);
|
|
||||||
|
printf("%s %s\n", __FUNCTION__, path);
|
||||||
|
|
||||||
|
err = delete_file(path);
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (err == 5)
|
||||||
|
errno = ENOENT;
|
||||||
|
else
|
||||||
|
errno = EIO;
|
||||||
|
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user