mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Share file offset across processes
This change ensures that if a file descriptor for an open disk file gets shared by multiple processes within a process tree, then lseek() changes will be visible across processes, and read() / write() are synchronized. Note this only applies to Windows, because UNIX kernels already do this.
This commit is contained in:
parent
a80ab3f8fe
commit
761c6ad615
15 changed files with 256 additions and 63 deletions
|
@ -1,5 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/thread/thread.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define kFdEmpty 0
|
||||
|
@ -13,19 +15,25 @@ COSMOPOLITAN_C_START_
|
|||
#define kFdDevNull 9
|
||||
#define kFdDevRandom 10
|
||||
|
||||
struct Cursor {
|
||||
pthread_mutex_t lock;
|
||||
long pointer;
|
||||
};
|
||||
|
||||
struct Fd {
|
||||
char kind;
|
||||
bool isdup;
|
||||
bool isbound;
|
||||
unsigned flags;
|
||||
unsigned mode;
|
||||
long handle;
|
||||
long pointer;
|
||||
int family;
|
||||
int type;
|
||||
int protocol;
|
||||
unsigned rcvtimeo; /* millis; 0 means wait forever */
|
||||
unsigned sndtimeo; /* millis; 0 means wait forever */
|
||||
void *connect_op;
|
||||
struct Cursor *shared;
|
||||
};
|
||||
|
||||
struct Fds {
|
||||
|
@ -34,5 +42,9 @@ struct Fds {
|
|||
struct Fd *p, *e;
|
||||
};
|
||||
|
||||
void __fd_lock(struct Fd *);
|
||||
void __fd_unlock(struct Fd *);
|
||||
struct Cursor *__cursor_new(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue