Init
This commit is contained in:
97
posixlib/Makefile
Normal file
97
posixlib/Makefile
Normal file
@@ -0,0 +1,97 @@
|
||||
#
|
||||
# @(#)Makefile 1.1 92/07/30 SMI
|
||||
#
|
||||
|
||||
CC=/usr/5bin/cc
|
||||
CFLAGS=-O -I/usr/include/posix -DS5EMUL -DPOSIX
|
||||
LIB=libposix.a
|
||||
|
||||
ARCH-mc68020= m68k
|
||||
ARCH-sparc = sparc
|
||||
ARCH= $(ARCH$(TARGET_MACH))
|
||||
|
||||
LIBDIR= $(DESTDIR)/usr/lib
|
||||
INCDIR= $(DESTDIR)/usr/include/posix
|
||||
INCSYSDIR= $(INCDIR)/sys
|
||||
|
||||
GENDIR=../lib/libc/gen/common
|
||||
STDIODIR=../lib/libc/stdio/common
|
||||
SYS5DIR=../lib/libc/stdio/sys5
|
||||
|
||||
GENFILES= execvp.c\
|
||||
posix_sig.c
|
||||
|
||||
STDFILES= fgetc.c\
|
||||
fgets.c\
|
||||
scanf.c\
|
||||
fputs.c \
|
||||
fread.c \
|
||||
fwrite.c \
|
||||
getc.c \
|
||||
getchar.c \
|
||||
gets.c \
|
||||
putc.c
|
||||
|
||||
STD5FILES= filbuf.c \
|
||||
flsbuf.c \
|
||||
fopen.c\
|
||||
fprintf.c\
|
||||
vfprintf.c \
|
||||
vprintf.c
|
||||
|
||||
.KEEP_STATE:
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
CFILES= cuserid.c \
|
||||
fcntl.c
|
||||
|
||||
INCFILES= fcntl.h
|
||||
|
||||
INCSYSFILES= fcntlcom.h
|
||||
|
||||
HDRS=
|
||||
|
||||
OBJS1= $(CFILES:%.c=obj/%.o)
|
||||
OBJS2= $(GENFILES:%.c=obj/%.o)
|
||||
OBJS3= $(STDFILES:%.c=obj/%.o)
|
||||
OBJS4= $(STD5FILES:%.c=obj/%.o)
|
||||
$(OBJS1): obj fcntl.h fcntlcom.h
|
||||
obj/%.o: $(ARCH)/%.s
|
||||
cd $(ARCH); $(MAKE) $(MFLAGS) OBJDIR=../obj
|
||||
obj/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
obj:
|
||||
test -d $@ || mkdir $@
|
||||
|
||||
$(GENFILES):
|
||||
(if [ ! -f $(GENDIR)/$@ ]; then cd $(GENDIR);sccs get $@; fi;)
|
||||
cd obj; ${CC} ${CFLAGS} -c ../$(GENDIR)/$@
|
||||
|
||||
$(STDFILES):
|
||||
(if [ ! -f $(STDIODIR)/$@ ]; then cd $(STDIODIR);sccs get $@; fi;)
|
||||
cd obj; ${CC} ${CFLAGS} -c ../$(STDIODIR)/$@
|
||||
|
||||
$(STD5FILES):
|
||||
(if [ ! -f $(SYS5DIR)/$@ ]; then cd $(SYS5DIR);sccs get $@; fi;)
|
||||
cd obj; ${CC} ${CFLAGS} -c ../$(SYS5DIR)/$@
|
||||
|
||||
$(LIB): $(HDRS) $(OBJS1) $(GENFILES) $(STDFILES) $(STD5FILES)
|
||||
cd $(ARCH); make
|
||||
ar rv $(LIB) $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(ARCH)/*.o
|
||||
ranlib $(LIB)
|
||||
|
||||
install: all
|
||||
install -d -o bin -m 755 $(LIBDIR)
|
||||
install -m 644 $(LIB) $(LIBDIR)
|
||||
ranlib $(LIBDIR)/$(LIB)
|
||||
install -d -m 755 $(INCDIR)
|
||||
install -d -o bin -m 755 $(INCSYSDIR)
|
||||
install -m 444 $(INCFILES) $(INCDIR)
|
||||
install -m 444 $(INCSYSFILES) $(INCSYSDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS1)
|
||||
rm -f $(LIB)
|
||||
rm -f obj/*.o
|
||||
|
||||
32
posixlib/cuserid.c
Normal file
32
posixlib/cuserid.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#if !defined(lint) && defined(SCCSIDS)
|
||||
static char sccsid[] = "@(#)cuserid.c 1.1 92/07/30 SMI"; /* from S5R2 1.3 */
|
||||
#endif
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
|
||||
extern char *strcpy(), *getlogin();
|
||||
extern int getuid();
|
||||
extern struct passwd *getpwuid();
|
||||
static char res[L_cuserid];
|
||||
|
||||
char *
|
||||
cuserid(s)
|
||||
char *s;
|
||||
{
|
||||
register struct passwd *pw;
|
||||
register char *p;
|
||||
|
||||
if (s == NULL)
|
||||
s = res;
|
||||
pw = getpwuid(geteuid());
|
||||
endpwent();
|
||||
if (pw != NULL)
|
||||
return (strcpy(s, pw->pw_name));
|
||||
p = getlogin();
|
||||
if (p != NULL)
|
||||
return (strcpy(s, p));
|
||||
*s = '\0';
|
||||
return (NULL);
|
||||
}
|
||||
21
posixlib/fcntl.c
Normal file
21
posixlib/fcntl.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* @(#)fcntl.c 1.1 92/07/30 Copyright SMI 1992 */
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "fcntlcom.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
fcntl(fd, cmd, arg)
|
||||
int fd, cmd;
|
||||
struct flock *arg;
|
||||
{
|
||||
int hold;
|
||||
|
||||
hold = posix_fcntl(fd, cmd, arg);
|
||||
if (cmd == F_GETLK) {
|
||||
arg->l_pid >>= 16;
|
||||
arg->l_whence = SEEK_SET;
|
||||
}
|
||||
return (hold);
|
||||
}
|
||||
10
posixlib/fcntl.h
Normal file
10
posixlib/fcntl.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/* @(#)fcntl.h 1.1 92/07/30 Copyright SMI 1992 */
|
||||
|
||||
#ifndef _FCNTL_
|
||||
#define _FCNTL_
|
||||
|
||||
#include <sys/fcntlcom.h>
|
||||
|
||||
#define O_NDELAY _FNDELAY /* Non-blocking I/O (4.2 style) */
|
||||
|
||||
#endif /* !_FCNTL_ */
|
||||
154
posixlib/fcntlcom.h
Normal file
154
posixlib/fcntlcom.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/* @(#)fcntlcom.h 1.1 92/07/30 SMI; from UCB fcntl.h 5.2 1/8/86 */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved. The Berkeley software License Agreement
|
||||
* specifies the terms and conditions for redistribution.
|
||||
*/
|
||||
|
||||
#ifndef __sys_fcntlcom_h
|
||||
#define __sys_fcntlcom_h
|
||||
|
||||
/*
|
||||
* Rewack the FXXXXX values as _FXXXX so that _POSIX_SOURCE works.
|
||||
*/
|
||||
#define _FOPEN (-1) /* from sys/file.h, kernel use only */
|
||||
#define _FREAD 0x0001 /* read enabled */
|
||||
#define _FWRITE 0x0002 /* write enabled */
|
||||
#define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
|
||||
#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
|
||||
#define _FSETBLK 0x0010 /* use block offsets */
|
||||
#define _FASYNC 0x0040 /* signal pgrp when data ready */
|
||||
#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
|
||||
#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
|
||||
#define _FCREAT 0x0200 /* open with file create */
|
||||
#define _FTRUNC 0x0400 /* open with truncation */
|
||||
#define _FEXCL 0x0800 /* error on open if file exists */
|
||||
#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
|
||||
#define _FSYNC 0x2000 /* do all writes synchronously */
|
||||
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
|
||||
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
|
||||
#define _FMARK 0x10000 /* internal; mark during gc() */
|
||||
#define _FDEFER 0x20000 /* internal; defer for next gc pass */
|
||||
|
||||
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
||||
|
||||
/*
|
||||
* Flag values for open(2) and fcntl(2)
|
||||
* The kernel adds 1 to the open modes to turn it into some
|
||||
* combination of FREAD and FWRITE.
|
||||
*/
|
||||
#define O_RDONLY 0 /* +1 == FREAD */
|
||||
#define O_WRONLY 1 /* +1 == FWRITE */
|
||||
#define O_RDWR 2 /* +1 == FREAD|FWRITE */
|
||||
#define O_APPEND _FAPPEND
|
||||
#define O_CREAT _FCREAT
|
||||
#define O_TRUNC _FTRUNC
|
||||
#define O_EXCL _FEXCL
|
||||
/* O_SYNC _FSYNC not posix, defined below */
|
||||
/* O_NDELAY _FNDELAY set in include/fcntl.h */
|
||||
/* O_NDELAY _FNBIO set in 5include/fcntl.h */
|
||||
#define O_NONBLOCK _FNONBLOCK
|
||||
#define O_NOCTTY _FNOCTTY
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
|
||||
#define O_SYNC _FSYNC
|
||||
|
||||
/*
|
||||
* Flags that work for fcntl(fd, F_SETFL, FXXXX)
|
||||
*/
|
||||
#define FAPPEND _FAPPEND
|
||||
#define FSYNC _FSYNC
|
||||
#define FASYNC _FASYNC
|
||||
#define FNBIO _FNBIO
|
||||
#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */
|
||||
#define FNDELAY _FNDELAY
|
||||
|
||||
/*
|
||||
* Flags that are disallowed for fcntl's (FCNTLCANT);
|
||||
* used for opens, internal state, or locking.
|
||||
*/
|
||||
#define FREAD _FREAD
|
||||
#define FWRITE _FWRITE
|
||||
#define FMARK _FMARK
|
||||
#define FDEFER _FDEFER
|
||||
#define FSETBLK _FSETBLK
|
||||
#define FSHLOCK _FSHLOCK
|
||||
#define FEXLOCK _FEXLOCK
|
||||
|
||||
/*
|
||||
* The rest of the flags, used only for opens
|
||||
*/
|
||||
#define FOPEN _FOPEN
|
||||
#define FCREAT _FCREAT
|
||||
#define FTRUNC _FTRUNC
|
||||
#define FEXCL _FEXCL
|
||||
#define FNOCTTY _FNOCTTY
|
||||
|
||||
#endif !_POSIX_SOURCE
|
||||
|
||||
/* XXX close on exec request; must match UF_EXCLOSE in user.h */
|
||||
#define FD_CLOEXEC 1 /* posix */
|
||||
|
||||
/* fcntl(2) requests */
|
||||
#define F_DUPFD 0 /* Duplicate fildes */
|
||||
#define F_GETFD 1 /* Get fildes flags (close on exec) */
|
||||
#define F_SETFD 2 /* Set fildes flags (close on exec) */
|
||||
#define F_GETFL 3 /* Get file flags */
|
||||
#define F_SETFL 4 /* Set file flags */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define F_GETOWN 5 /* Get owner - for ASYNC */
|
||||
#define F_SETOWN 6 /* Set owner - for ASYNC */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#define F_GETLK 7 /* Get record-locking information */
|
||||
#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
|
||||
#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
|
||||
#define F_RSETLK 11 /* Set or unlock a remote lock */
|
||||
#define F_CNVT 12 /* Convert a fhandle to an open fd */
|
||||
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
/* fcntl(2) flags (l_type field of flock structure) */
|
||||
#define F_RDLCK 1 /* read lock */
|
||||
#define F_WRLCK 2 /* write lock */
|
||||
#define F_UNLCK 3 /* remove lock(s) */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define F_UNLKSYS 4 /* remove remote locks for a given system */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
#include <sys/stdtypes.h>
|
||||
|
||||
/* file segment locking set data type - information passed to system by user */
|
||||
struct flock {
|
||||
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
|
||||
short l_whence; /* flag to choose starting offset */
|
||||
long l_start; /* relative offset, in bytes */
|
||||
long l_len; /* length, in bytes; 0 means lock to EOF */
|
||||
pid_t l_pid; /* returned with F_GETLK */
|
||||
};
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
/* extended file segment locking set data type */
|
||||
struct eflock {
|
||||
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
|
||||
short l_whence; /* flag to choose starting offset */
|
||||
long l_start; /* relative offset, in bytes */
|
||||
long l_len; /* length, in bytes; 0 means lock to EOF */
|
||||
short l_pid; /* returned with F_GETLK */
|
||||
short l_xxx; /* reserved for future use */
|
||||
long l_rpid; /* Remote process id wanting this lock */
|
||||
long l_rsys; /* Remote system id wanting this lock */
|
||||
};
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
|
||||
#ifndef KERNEL
|
||||
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
|
||||
|
||||
int open(/* char *path, int flags, mode_t modes */);
|
||||
int creat(/* char *path, mode_t modes */);
|
||||
int fcntl(/* int fd, cmd, ... */);
|
||||
#endif /* !KERNEL */
|
||||
#endif /* !__sys_fcntlcom_h */
|
||||
9
posixlib/sparc/Makefile
Normal file
9
posixlib/sparc/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# @(#)Makefile 1.1 92/07/30 SMI
|
||||
#
|
||||
# Copyright (c) 1991 by Sun Microsystems, Inc.
|
||||
|
||||
all: posix_fcntl.o
|
||||
|
||||
posix_fcntl.o:
|
||||
as -Isparc -sparc -P -DLOCORE -I/usr/5include -DS5EMUL -I/usr/src/include -I/usr/src/lib/libc/sys/common/sparc -P posix_fcntl.s -o posix_fcntl.o
|
||||
12
posixlib/sparc/posix_fcntl.s
Normal file
12
posixlib/sparc/posix_fcntl.s
Normal file
@@ -0,0 +1,12 @@
|
||||
/* @(#)posix_fcntl.s 1.1 92/07/30 SMI */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "SYS.h"
|
||||
ENTRY(posix_fcntl);
|
||||
mov SYS_fcntl, %g1;
|
||||
t 0;
|
||||
CERROR(o5)
|
||||
RET
|
||||
Reference in New Issue
Block a user