mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added lockf() support, as supplied by Henning Nielsen Lund.
Thank you very much! - symlink() now also works for absolute and relative links, and is part of "libunix.a". This patch was supplied by Henning Nielsen Lund. Thank you very much! git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15081 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.68k,v 1.79 2005-12-31 12:23:53 obarthel Exp $
|
||||
# $Id: GNUmakefile.68k,v 1.80 2006-01-29 09:16:59 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -21,7 +21,6 @@ LIBC_OBJS = libc_objs
|
||||
LIBUNIX_OBJS = libunix_objs
|
||||
LIBM_OBJS = libm_objs
|
||||
LIBM881_OBJS = libm881_objs
|
||||
LIBSTACK_OBJS = libstack_objs
|
||||
LIBNET_OBJS = libnet_objs
|
||||
LIBDEBUG_OBJS = libdebug_objs
|
||||
LIBAMIGA_OBJS = libamiga_objs
|
||||
@ -30,7 +29,6 @@ LIBC_OBJS = $(TYPE)/libc_objs
|
||||
LIBUNIX_OBJS = $(TYPE)/libunix_objs
|
||||
LIBM_OBJS = $(TYPE)/libm_objs
|
||||
LIBM881_OBJS = $(TYPE)/libm881_objs
|
||||
LIBSTACK_OBJS = $(TYPE)/libstack_objs
|
||||
LIBNET_OBJS = $(TYPE)/libnet_objs
|
||||
LIBDEBUG_OBJS = $(TYPE)/libdebug_objs
|
||||
LIBAMIGA_OBJS = $(TYPE)/libamiga_objs
|
||||
@ -58,10 +56,6 @@ $(LIBM881_OBJS)/%.o : %.c
|
||||
@echo "Compiling $< [$(TYPE):m881]"
|
||||
@$(CC) -o $(LIBM881_OBJS)/$*.o -c $(CFLAGS) -DM68881_FLOATING_POINT_SUPPORT -m68881 $<
|
||||
|
||||
$(LIBSTACK_OBJS)/%.o : %.c
|
||||
@echo "Compiling $< [$(TYPE):stack]"
|
||||
@$(CC) -o $(LIBSTACK_OBJS)/$*.o -c $(CFLAGS) -DSTACK_EXTENSION $<
|
||||
|
||||
$(LIBNET_OBJS)/%.o : %.c
|
||||
@echo "Compiling $< [$(TYPE):net]"
|
||||
@$(CC) -o $(LIBNET_OBJS)/$*.o -c $(CFLAGS) -DSOCKET_SUPPORT -DUSERGROUP_SUPPORT $<
|
||||
@ -447,6 +441,7 @@ C_LIB = \
|
||||
unistd_isatty.o \
|
||||
unistd_lchown.o \
|
||||
unistd_link.o \
|
||||
unistd_lockf.o \
|
||||
unistd_readlink.o \
|
||||
unistd_realpath.o \
|
||||
unistd_sleep.o \
|
||||
@ -526,11 +521,13 @@ UNIX_LIB = \
|
||||
unistd_getcwd.o \
|
||||
unistd_lchown.o \
|
||||
unistd_link.o \
|
||||
unistd_lockf.o \
|
||||
unistd_readlink.o \
|
||||
unistd_realpath.o \
|
||||
unistd_restorepathname.o \
|
||||
unistd_setcurrentpath.o \
|
||||
unistd_strip_double_slash.o \
|
||||
unistd_symlink.o \
|
||||
unistd_translatea2u.o \
|
||||
unistd_translaterel.o \
|
||||
unistd_translateu2a.o \
|
||||
@ -740,14 +737,6 @@ MATH_LIB_IEEE = \
|
||||
math_subsf3.o \
|
||||
math_truncdfsf2.o
|
||||
|
||||
STACK_LIB = \
|
||||
stack.lib_rev.o \
|
||||
stdlib_setjmp.o \
|
||||
stdlib_stackextension.o \
|
||||
stdlib_stackminframe.o \
|
||||
stdlib_stackoverflow.o \
|
||||
stdlib_stacksafezone.o
|
||||
|
||||
NET_LIB = \
|
||||
net.lib_rev.o \
|
||||
socket_accept.o \
|
||||
@ -906,7 +895,7 @@ MEMDEBUG_LIB = \
|
||||
|
||||
##############################################################################
|
||||
|
||||
LIBS_68K := $(LIBC_OBJS)/libc.a $(LIBSTACK_OBJS)/libstack.a $(LIBUNIX_OBJS)/libunix.a \
|
||||
LIBS_68K := $(LIBC_OBJS)/libc.a $(LIBUNIX_OBJS)/libunix.a \
|
||||
$(LIBNET_OBJS)/libnet.a $(LIBDEBUG_OBJS)/libdebug.a $(LIBAMIGA_OBJS)/libamiga.a \
|
||||
$(LIBM_OBJS)/libm.a
|
||||
LIBS_020 := $(LIBM881_OBJS)/libm881.a $(LIBS_68K)
|
||||
@ -943,7 +932,7 @@ all: \
|
||||
clean:
|
||||
-$(DELETE) $(TYPE) $(LIBS_020) $(STARTUPS) \
|
||||
$(LIBC_OBJS) $(LIBUNIX_OBJS) $(LIBM_OBJS) \
|
||||
$(LIBM881_OBJS) $(LIBSTACK_OBJS) $(LIBNET_OBJS) $(LIBDEBUG_OBJS) \
|
||||
$(LIBM881_OBJS) $(LIBNET_OBJS) $(LIBDEBUG_OBJS) \
|
||||
$(LIBAMIGA_OBJS)
|
||||
|
||||
realclean:
|
||||
@ -959,7 +948,6 @@ version:
|
||||
copy clone c.lib_rev.rev m.lib_rev.rev
|
||||
copy clone c.lib_rev.rev m881.lib_rev.rev
|
||||
copy clone c.lib_rev.rev net.lib_rev.rev
|
||||
copy clone c.lib_rev.rev stack.lib_rev.rev
|
||||
copy clone c.lib_rev.rev unix.lib_rev.rev
|
||||
bumprev 1 amiga.lib
|
||||
bumprev 1 c.lib
|
||||
@ -967,7 +955,6 @@ version:
|
||||
bumprev 1 m.lib
|
||||
bumprev 1 m881.lib
|
||||
bumprev 1 net.lib
|
||||
bumprev 1 stack.lib
|
||||
bumprev 1 unix.lib
|
||||
|
||||
##############################################################################
|
||||
@ -1051,8 +1038,6 @@ $(LIBC_OBJS)/stdlib_swapstack.o : stdlib_swapstack.c
|
||||
|
||||
$(LIBC_OBJS)/stdlib_setjmp.o : stdlib_setjmp.c
|
||||
|
||||
$(LIBSTACK_OBJS)/stdlib_setjmp.o : stdlib_setjmp.c
|
||||
|
||||
##############################################################################
|
||||
|
||||
$(LIBC_OBJS)/c.lib_rev.o : c.lib_rev.c c.lib_rev.h
|
||||
@ -1063,8 +1048,6 @@ $(LIBM_OBJS)/m.lib_rev.o : m.lib_rev.c m.lib_rev.h
|
||||
|
||||
$(LIBM881_OBJS)/m881.lib_rev.o : m881.lib_rev.c m881.lib_rev.h
|
||||
|
||||
$(LIBSTACK_OBJS)/stack.lib_rev.o : stack.lib_rev.c stack.lib_rev.h
|
||||
|
||||
$(LIBNET_OBJS)/net.lib_rev.o : net.lib_rev.c net.lib_rev.h
|
||||
|
||||
$(LIBDEBUG_OBJS)/debug.lib_rev.o : debug.lib_rev.c debug.lib_rev.h
|
||||
@ -1204,16 +1187,6 @@ $(LIBM881_OBJS)/libm881.a : $(LIBM881_OBJS) $(foreach file,$(MATH_LIB_881),$(LIB
|
||||
|
||||
##############################################################################
|
||||
|
||||
$(LIBSTACK_OBJS) :
|
||||
$(MAKEDIR) $@
|
||||
|
||||
$(LIBSTACK_OBJS)/libstack.a : $(LIBSTACK_OBJS) $(foreach file,$(STACK_LIB),$(LIBSTACK_OBJS)/$(file))
|
||||
-$(DELETE) $@
|
||||
@$(AR) $@ $(foreach file,$(STACK_LIB),$(LIBSTACK_OBJS)/$(file))
|
||||
$(RANLIB) $@
|
||||
|
||||
##############################################################################
|
||||
|
||||
$(LIBNET_OBJS) :
|
||||
$(MAKEDIR) $@
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.os4,v 1.91 2005-12-31 12:23:53 obarthel Exp $
|
||||
# $Id: GNUmakefile.os4,v 1.92 2006-01-29 09:17:00 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -481,6 +481,7 @@ C_LIB = \
|
||||
unistd_isatty.o \
|
||||
unistd_lchown.o \
|
||||
unistd_link.o \
|
||||
unistd_lockf.o \
|
||||
unistd_readlink.o \
|
||||
unistd_realpath.o \
|
||||
unistd_sleep.o \
|
||||
@ -562,11 +563,13 @@ UNIX_LIB = \
|
||||
unistd_getcwd.o \
|
||||
unistd_lchown.o \
|
||||
unistd_link.o \
|
||||
unistd_lockf.o \
|
||||
unistd_readlink.o \
|
||||
unistd_realpath.o \
|
||||
unistd_restorepathname.o \
|
||||
unistd_setcurrentpath.o \
|
||||
unistd_strip_double_slash.o \
|
||||
unistd_symlink.o \
|
||||
unistd_translatea2u.o \
|
||||
unistd_translaterel.o \
|
||||
unistd_translateu2a.o \
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
- Added lockf() support, as supplied by Henning Nielsen Lund.
|
||||
Thank you very much!
|
||||
|
||||
- symlink() now also works for absolute and relative links, and is
|
||||
part of "libunix.a". This patch was supplied by Henning Nielsen Lund.
|
||||
Thank you very much!
|
||||
|
||||
- The __main() stub function expected by the 68k GCC build is no
|
||||
longer part of "stdlib_main.c". This helps the C++ support, since the
|
||||
__main symbol definition no longer clashes with the definition in
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd.h,v 1.17 2006-01-08 12:06:14 obarthel Exp $
|
||||
* $Id: unistd.h,v 1.18 2006-01-29 09:17:00 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -83,6 +83,13 @@ extern "C" {
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define F_ULOCK 0
|
||||
#define F_LOCK 1
|
||||
#define F_TLOCK 2
|
||||
#define F_TEST 3
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern int opterr;
|
||||
extern int optind;
|
||||
extern int optopt;
|
||||
@ -104,6 +111,7 @@ extern int unlink(const char * path_name);
|
||||
extern int symlink(const char * actual_path, const char * symbolic_path);
|
||||
extern int readlink(const char * path_name, char * buffer, int buffer_size);
|
||||
extern int chdir(const char * path_name);
|
||||
extern int lockf(int file_descriptor, int function, off_t size);
|
||||
extern unsigned int sleep(unsigned int seconds);
|
||||
extern void usleep(unsigned long microseconds);
|
||||
extern int getopt(int argc, char * argv[], char *opts);
|
||||
|
||||
102
library/unistd_lockf.c
Executable file
102
library/unistd_lockf.c
Executable file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* $Id:
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _UNISTD_HEADERS_H
|
||||
#include "unistd_headers.h"
|
||||
#endif /* _UNISTD_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
lockf(int file_descriptor,int function,off_t size)
|
||||
{
|
||||
struct flock l;
|
||||
int result = -1;
|
||||
int cmd;
|
||||
|
||||
l.l_whence = SEEK_CUR;
|
||||
l.l_start = 0;
|
||||
l.l_len = size;
|
||||
|
||||
switch(function)
|
||||
{
|
||||
case F_ULOCK:
|
||||
|
||||
cmd = F_SETLK;
|
||||
l.l_type = F_UNLCK;
|
||||
break;
|
||||
|
||||
case F_LOCK:
|
||||
|
||||
cmd = F_SETLKW;
|
||||
l.l_type = F_WRLCK;
|
||||
break;
|
||||
|
||||
case F_TLOCK:
|
||||
|
||||
cmd = F_SETLK;
|
||||
l.l_type = F_WRLCK;
|
||||
break;
|
||||
|
||||
case F_TEST:
|
||||
|
||||
l.l_type = F_WRLCK;
|
||||
|
||||
if(fcntl(file_descriptor,F_GETLK,&l) == -1)
|
||||
goto out;
|
||||
|
||||
if(l.l_pid == getpid() || l.l_type == F_UNLCK)
|
||||
{
|
||||
result = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
__set_errno(EAGAIN);
|
||||
goto out;
|
||||
|
||||
default:
|
||||
|
||||
__set_errno(EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = fcntl(file_descriptor,cmd,&l);
|
||||
|
||||
out:
|
||||
|
||||
return(result);
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd_symlink.c,v 1.7 2006-01-08 12:04:27 obarthel Exp $
|
||||
* $Id: unistd_symlink.c,v 1.8 2006-01-29 09:17:00 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -47,12 +47,13 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* ZZZ symbolic_path must be interpreted relative to the current (!)
|
||||
* directory here.
|
||||
*/
|
||||
int
|
||||
symlink(const char * actual_path, const char * symbolic_path)
|
||||
{
|
||||
#if defined(UNIX_PATH_SEMANTICS)
|
||||
struct name_translation_info actual_path_name_nti;
|
||||
struct name_translation_info symbolic_path_name_nti;
|
||||
#endif /* UNIX_PATH_SEMANTICS */
|
||||
int result = ERROR;
|
||||
LONG status;
|
||||
|
||||
@ -78,6 +79,33 @@ symlink(const char * actual_path, const char * symbolic_path)
|
||||
}
|
||||
#endif /* CHECK_FOR_NULL_POINTERS */
|
||||
|
||||
#if defined(UNIX_PATH_SEMANTICS)
|
||||
{
|
||||
if(__unix_path_semantics)
|
||||
{
|
||||
if(actual_path[0] == '\0' || symbolic_path[0] == '\0')
|
||||
{
|
||||
SHOWMSG("no name given");
|
||||
|
||||
__set_errno(ENOENT);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(__translate_unix_to_amiga_path_name(&actual_path,&actual_path_name_nti) != 0)
|
||||
goto out;
|
||||
|
||||
if(__translate_unix_to_amiga_path_name(&symbolic_path,&symbolic_path_name_nti) != 0)
|
||||
goto out;
|
||||
|
||||
if(actual_path_name_nti.is_root || symbolic_path_name_nti.is_root)
|
||||
{
|
||||
__set_errno(EACCES);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* UNIX_PATH_SEMANTICS */
|
||||
|
||||
SHOWMSG("trying to make that link");
|
||||
|
||||
PROFILE_OFF();
|
||||
|
||||
Reference in New Issue
Block a user