Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5214 → Rev 5215

/contrib/sdk/sources/newlib/libc/Makefile
15,7 → 15,7
 
NAME:= libc
 
DEFINES:= -D_IEEE_LIBM
DEFINES:= -D_IEEE_LIBM -DHAVE_RENAME
 
INCLUDES:= -I $(LIBC_INCLUDES)
 
97,27 → 97,29
locale/locale.c \
locale/lctype.c \
locale/ldpart.c \
reent/closer.c \
reent/fstatr.c \
reent/getreent.c \
reent/gettimeofdayr.c \
reent/impure.c \
reent/init_reent.c \
reent/getreent.c \
reent/isattyr.c \
reent/linkr.c \
reent/lseekr.c \
reent/mutex.c \
reent/gettimeofdayr.c \
reent/isattyr.c \
reent/openr.c \
reent/closer.c \
reent/linkr.c \
reent/readr.c \
reent/lseekr.c \
reent/fstatr.c \
reent/writer.c \
reent/renamer.c \
reent/statr.c \
reent/timesr.c \
reent/unlinkr.c \
reent/writer.c \
search/qsort.c \
search/bsearch.c \
signal/signal.c \
sys/access.c \
sys/close.c \
sys/create.c \
sys/delete.c \
sys/errno.c \
sys/finfo.c \
sys/fsize.c \
130,6 → 132,7
sys/lseek.c \
sys/open.c \
sys/read.c \
sys/_rename.c \
sys/stat.c \
sys/unlink.c \
sys/write.c \
267,11 → 270,13
fwrite.c \
fvwrite.c \
fwalk.c \
mktemp.c \
putc.c \
puts.c \
refill.c \
rget.c \
remove.c \
rename.c \
rewind.c \
setvbuf.c \
stdio.c \
/contrib/sdk/sources/newlib/libc/reent/statr.c
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) */
/contrib/sdk/sources/newlib/libc/stdio/mktemp.c
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) */
/contrib/sdk/sources/newlib/libc/sys/delete.c
File deleted
/contrib/sdk/sources/newlib/libc/sys/_rename.c
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);
};
/contrib/sdk/sources/newlib/libc/sys/access.c
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;
}
/contrib/sdk/sources/newlib/libc/sys/create.c
8,7 → 8,7
__asm__ __volatile__ (
"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"
/contrib/sdk/sources/newlib/libc/sys/fstat.c
26,6 → 26,8
struct stat *buf)
{
fileinfo_t info;
struct tm time;
 
__io_handle *ioh;
 
if( (fd < 0) || (fd >=64) )
47,9 → 49,44
ioh = &__io_tab[fd];
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_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);
/contrib/sdk/sources/newlib/libc/sys/open.c
128,8 → 128,6
buildpath(buf, filename);
}
 
// printf("%s %s\n", __FUNCTION__, buf);
 
err = get_fileinfo(buf, &info);
 
if( flags & O_EXCL &&
189,8 → 187,6
ioh->read = read_file;
ioh->write = write_file;
 
// printf("%s %s\n", __FUNCTION__, ioh->name);
 
return hid;
};
 
/contrib/sdk/sources/newlib/libc/sys/stat.c
13,7 → 13,10
* they apply.
*/
#include <sys/stat.h>
#include <sys/kos_io.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include "glue.h"
 
/*
24,7 → 27,68
const char *path _AND
struct stat *buf)
{
errno = EIO;
 
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);
}
 
/contrib/sdk/sources/newlib/libc/sys/stat.c.bak
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);
}
 
/contrib/sdk/sources/newlib/libc/sys/unlink.c
19,15 → 19,47
 
#include "glue.h"
 
/*
* unlink -- since we have no file system,
* we just return an error.
*/
static int delete_file(const char *path)
{
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
_DEFUN (unlink, (path),
char * path)
{
int err;
 
printf("%s %s\n", __FUNCTION__, path);
 
err = delete_file(path);
 
if (!err)
return 0;
 
if (err == 5)
errno = ENOENT;
else
errno = EIO;
 
return (-1);
}