filedesc: fix up breakage introduced in 272505
Include sequence counter supports incoditionally [1]. This fixes reprted build problems with e.g. nvidia driver due to missing opt_capsicum.h. Replace fishy looking sizeof with offsetof. Make fde_seq the last member in order to simplify calculations. Suggested by: kib [1] X-MFC: with 272505
This commit is contained in:
parent
57c2505e65
commit
2b4a2528d7
@ -295,7 +295,7 @@ _fdfree(struct filedesc *fdp, int fd, int last)
|
||||
filecaps_free(&fde->fde_caps);
|
||||
if (last)
|
||||
return;
|
||||
bzero(fde_change(fde), fde_change_size);
|
||||
bzero(fde, fde_change_size);
|
||||
fdunused(fdp, fd);
|
||||
#ifdef CAPABILITIES
|
||||
seq_write_end(&fde->fde_seq);
|
||||
@ -894,7 +894,7 @@ do_dup(struct thread *td, int flags, int old, int new,
|
||||
seq_write_begin(&newfde->fde_seq);
|
||||
#endif
|
||||
filecaps_free(&newfde->fde_caps);
|
||||
memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size);
|
||||
memcpy(newfde, oldfde, fde_change_size);
|
||||
filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps);
|
||||
if ((flags & DUP_CLOEXEC) != 0)
|
||||
newfde->fde_flags = oldfde->fde_flags | UF_EXCLOSE;
|
||||
@ -2778,7 +2778,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
||||
#ifdef CAPABILITIES
|
||||
seq_write_begin(&newfde->fde_seq);
|
||||
#endif
|
||||
memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size);
|
||||
memcpy(newfde, oldfde, fde_change_size);
|
||||
filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps);
|
||||
#ifdef CAPABILITIES
|
||||
seq_write_end(&newfde->fde_seq);
|
||||
@ -2793,8 +2793,8 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
||||
#ifdef CAPABILITIES
|
||||
seq_write_begin(&newfde->fde_seq);
|
||||
#endif
|
||||
memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size);
|
||||
bzero(fde_change(oldfde), fde_change_size);
|
||||
memcpy(newfde, oldfde, fde_change_size);
|
||||
bzero(oldfde, fde_change_size);
|
||||
fdunused(fdp, dfd);
|
||||
#ifdef CAPABILITIES
|
||||
seq_write_end(&newfde->fde_seq);
|
||||
|
@ -33,10 +33,6 @@
|
||||
#ifndef _SYS_FILEDESC_H_
|
||||
#define _SYS_FILEDESC_H_
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include "opt_capsicum.h"
|
||||
#endif
|
||||
|
||||
#include <sys/caprights.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/event.h>
|
||||
@ -55,24 +51,16 @@ struct filecaps {
|
||||
};
|
||||
|
||||
struct filedescent {
|
||||
#ifdef CAPABILITIES
|
||||
seq_t fde_seq; /* if you need fde_file and fde_caps in sync */
|
||||
#endif
|
||||
struct file *fde_file; /* file structure for open file */
|
||||
struct filecaps fde_caps; /* per-descriptor rights */
|
||||
uint8_t fde_flags; /* per-process open file flags */
|
||||
seq_t fde_seq; /* if you need fde_file and fde_caps in sync */
|
||||
};
|
||||
#define fde_rights fde_caps.fc_rights
|
||||
#define fde_fcntls fde_caps.fc_fcntls
|
||||
#define fde_ioctls fde_caps.fc_ioctls
|
||||
#define fde_nioctls fde_caps.fc_nioctls
|
||||
#ifdef CAPABILITIES
|
||||
#define fde_change(fde) ((char *)(fde) + sizeof(seq_t))
|
||||
#define fde_change_size (sizeof(struct filedescent) - sizeof(seq_t))
|
||||
#else
|
||||
#define fde_change(fde) ((fde))
|
||||
#define fde_change_size (sizeof(struct filedescent))
|
||||
#endif
|
||||
#define fde_change_size (offsetof(struct filedescent, fde_seq))
|
||||
|
||||
/*
|
||||
* This structure is used for the management of descriptors. It may be
|
||||
@ -97,9 +85,7 @@ struct filedesc {
|
||||
int fd_holdleaderscount; /* block fdfree() for shared close() */
|
||||
int fd_holdleaderswakeup; /* fdfree() needs wakeup */
|
||||
};
|
||||
#ifdef CAPABILITIES
|
||||
#define fd_seq(fdp, fd) (&(fdp)->fd_ofiles[(fd)].fde_seq)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure to keep track of (process leader, struct fildedesc) tuples.
|
||||
|
Loading…
Reference in New Issue
Block a user