Refuse to implement broken POSIX advisory file locks.
This commit is contained in:
parent
554894d840
commit
4ee83c9466
|
@ -61,6 +61,23 @@ will need to be removed as well.
|
||||||
|
|
||||||
Sortix currently implement these functions for compatibility reasons.
|
Sortix currently implement these functions for compatibility reasons.
|
||||||
|
|
||||||
|
F_GETLK, F_SETLK, F_SETLKW
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
These fcntl commands implement POSIX advisory file locking. Unfortunately, this
|
||||||
|
standard interface is very poorly designed. In particular, if a process closes
|
||||||
|
a file descriptor, then all locks the process has for that file is unlocked,
|
||||||
|
even though there might not be a lock associated with that file descriptor in
|
||||||
|
the first place. This means that if the main program locks /foo/bar and runs
|
||||||
|
a library routine that also happen to open /foo/bar, then the advsisory lock set
|
||||||
|
up by the main program is silently gone when when the library routine closes the
|
||||||
|
file and returns to the main program. Additionally, the locks are attached to
|
||||||
|
processes, rather than file descriptors. This complicates using them for threads
|
||||||
|
and passing file locks onto child processes.
|
||||||
|
|
||||||
|
Use the flock (not to be confused with lockf) call instead as it works at a file
|
||||||
|
descriptor level.
|
||||||
|
|
||||||
ftime
|
ftime
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -109,6 +126,16 @@ This function is rather pointless. If we use a character encoding that wasn't
|
||||||
ascii compatible, then it doesn't make sense. If we use a sane character
|
ascii compatible, then it doesn't make sense. If we use a sane character
|
||||||
encoding such as UTF-8, then you can simply check if the value is at most 127.
|
encoding such as UTF-8, then you can simply check if the value is at most 127.
|
||||||
|
|
||||||
|
lockf
|
||||||
|
-----
|
||||||
|
|
||||||
|
This function implements POSIX advisory locks. It suffers from the same basic
|
||||||
|
design mistakes that the fnctl advistory lock commands (F_GETLK, F_SETLK,
|
||||||
|
F_SETLKW) do and should be avoided for the same reasons (see above).
|
||||||
|
|
||||||
|
Use the flock (not to be confused with lockf) call instead as it works at a file
|
||||||
|
descriptor level.
|
||||||
|
|
||||||
PATH_MAX
|
PATH_MAX
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ likely take a very long time to phase out and wholly remove.
|
||||||
|
|
||||||
Mandated by POSIX but not implemented in Sortix
|
Mandated by POSIX but not implemented in Sortix
|
||||||
----
|
----
|
||||||
|
* POSIX advisory locks (fcntl, lockf) are not implemented.
|
||||||
* getpgrp is not implemented.
|
* getpgrp is not implemented.
|
||||||
* <strings.h> has been merged into <string.h>.
|
* <strings.h> has been merged into <string.h>.
|
||||||
* Numerous namespace violations (will be fixed or documented here).
|
* Numerous namespace violations (will be fixed or documented here).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/* TODO: POSIX-1.2008 compliance is only partial */
|
|
||||||
|
|
||||||
#ifndef INCLUDE_FCNTL_H
|
#ifndef INCLUDE_FCNTL_H
|
||||||
#define INCLUDE_FCNTL_H
|
#define INCLUDE_FCNTL_H
|
||||||
|
|
||||||
|
@ -31,9 +29,10 @@
|
||||||
|
|
||||||
#include <sys/__/types.h>
|
#include <sys/__/types.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <sortix/fcntl.h>
|
#include <sortix/fcntl.h>
|
||||||
#include <sortix/seek.h>
|
#include <sortix/seek.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -51,12 +50,6 @@ __BEGIN_DECLS
|
||||||
/* Compatibility with Linux and other systems that have this. */
|
/* Compatibility with Linux and other systems that have this. */
|
||||||
#define O_ACCMODE (O_READ | O_WRITE | O_EXEC | O_SEARCH)
|
#define O_ACCMODE (O_READ | O_WRITE | O_EXEC | O_SEARCH)
|
||||||
|
|
||||||
/* TODO: F_* missing here */
|
|
||||||
|
|
||||||
/* TODO: F_RDLCK, F_UNLCK, F_WRLCK missing here */
|
|
||||||
|
|
||||||
/* TODO: AT_SYMLINK_FOLLOW missing here */
|
|
||||||
|
|
||||||
/* TODO: POSIX_FADV_* missing here */
|
/* TODO: POSIX_FADV_* missing here */
|
||||||
|
|
||||||
#ifndef __pid_t_defined
|
#ifndef __pid_t_defined
|
||||||
|
@ -64,15 +57,6 @@ __BEGIN_DECLS
|
||||||
typedef __pid_t pid_t;
|
typedef __pid_t pid_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct flock
|
|
||||||
{
|
|
||||||
short l_type; /* Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. */
|
|
||||||
short l_whence; /* Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. */
|
|
||||||
off_t l_start; /* Relative offset in bytes. */
|
|
||||||
off_t l_len; /* Size; if 0 then until EOF. */
|
|
||||||
pid_t l_pid; /* Process ID of the process holding the lock; returned with F_GETLK. */
|
|
||||||
};
|
|
||||||
|
|
||||||
int creat(const char* path, mode_t mode);
|
int creat(const char* path, mode_t mode);
|
||||||
int fcntl(int fd, int cmd, ...);
|
int fcntl(int fd, int cmd, ...);
|
||||||
int open(const char* path, int oflag, ...);
|
int open(const char* path, int oflag, ...);
|
||||||
|
|
|
@ -315,7 +315,6 @@ long gethostid(void);
|
||||||
|
|
||||||
pid_t getpgrp(void);
|
pid_t getpgrp(void);
|
||||||
pid_t getsid(pid_t);
|
pid_t getsid(pid_t);
|
||||||
int lockf(int, int, off_t);
|
|
||||||
int nice(int);
|
int nice(int);
|
||||||
int pause(void);
|
int pause(void);
|
||||||
int setregid(gid_t, gid_t);
|
int setregid(gid_t, gid_t);
|
||||||
|
|
Loading…
Reference in New Issue