/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); |
} |