mirror of
https://github.com/ish-app/ish.git
synced 2026-02-01 14:32:26 +00:00
Fix lockfile flag checks
This commit is contained in:
parent
47078b8717
commit
910bbc398c
@ -212,9 +212,10 @@ out:
|
||||
int fcntl_setlk(struct fd *fd, struct flock_ *flock, bool blocking) {
|
||||
if (flock->type != F_RDLCK_ && flock->type != F_WRLCK_ && flock->type != F_UNLCK_)
|
||||
return _EINVAL;
|
||||
if (flock->type == F_RDLCK_ && !(fd_getflags(fd) & (O_RDONLY_|O_RDWR_)))
|
||||
int fd_mode = fd_getflags(fd) & O_ACCMODE_;
|
||||
if (flock->type == F_RDLCK_ && !(fd_mode == O_RDONLY_) && !(fd_mode == O_RDWR_))
|
||||
return _EBADF;
|
||||
if (flock->type == F_WRLCK_ && !(fd_getflags(fd) & (O_WRONLY_|O_RDWR_)))
|
||||
if (flock->type == F_WRLCK_ && !(fd_mode == O_WRONLY_) && !(fd_mode == O_RDWR_))
|
||||
return _EBADF;
|
||||
|
||||
struct inode_data *inode = fd->inode;
|
||||
|
||||
@ -113,6 +113,7 @@ int mount_remove(struct mount *mount);
|
||||
extern struct list mounts;
|
||||
|
||||
// open flags
|
||||
#define O_ACCMODE_ 3
|
||||
#define O_RDONLY_ 0
|
||||
#define O_WRONLY_ (1 << 0)
|
||||
#define O_RDWR_ (1 << 1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user