fd: add fde_copy
To dedup handrolled memcpy. This will be used later to make fd code atomic-clean.
This commit is contained in:
parent
ec12b4f4ff
commit
e68a5225e8
@ -1022,7 +1022,7 @@ kern_dup(struct thread *td, u_int mode, int flags, int old, int new)
|
|||||||
seqc_write_begin(&newfde->fde_seqc);
|
seqc_write_begin(&newfde->fde_seqc);
|
||||||
#endif
|
#endif
|
||||||
oioctls = filecaps_free_prep(&newfde->fde_caps);
|
oioctls = filecaps_free_prep(&newfde->fde_caps);
|
||||||
memcpy(newfde, oldfde, fde_change_size);
|
fde_copy(oldfde, newfde);
|
||||||
filecaps_copy_finish(&oldfde->fde_caps, &newfde->fde_caps,
|
filecaps_copy_finish(&oldfde->fde_caps, &newfde->fde_caps,
|
||||||
nioctls);
|
nioctls);
|
||||||
if ((flags & FDDUP_FLAG_CLOEXEC) != 0)
|
if ((flags & FDDUP_FLAG_CLOEXEC) != 0)
|
||||||
@ -3628,7 +3628,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
|||||||
#ifdef CAPABILITIES
|
#ifdef CAPABILITIES
|
||||||
seqc_write_begin(&newfde->fde_seqc);
|
seqc_write_begin(&newfde->fde_seqc);
|
||||||
#endif
|
#endif
|
||||||
memcpy(newfde, oldfde, fde_change_size);
|
fde_copy(oldfde, newfde);
|
||||||
filecaps_copy_finish(&oldfde->fde_caps, &newfde->fde_caps,
|
filecaps_copy_finish(&oldfde->fde_caps, &newfde->fde_caps,
|
||||||
ioctls);
|
ioctls);
|
||||||
#ifdef CAPABILITIES
|
#ifdef CAPABILITIES
|
||||||
@ -3645,7 +3645,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
|||||||
seqc_write_begin(&oldfde->fde_seqc);
|
seqc_write_begin(&oldfde->fde_seqc);
|
||||||
seqc_write_begin(&newfde->fde_seqc);
|
seqc_write_begin(&newfde->fde_seqc);
|
||||||
#endif
|
#endif
|
||||||
memcpy(newfde, oldfde, fde_change_size);
|
fde_copy(oldfde, newfde);
|
||||||
oldfde->fde_file = NULL;
|
oldfde->fde_file = NULL;
|
||||||
fdunused(fdp, dfd);
|
fdunused(fdp, dfd);
|
||||||
#ifdef CAPABILITIES
|
#ifdef CAPABILITIES
|
||||||
|
@ -66,7 +66,17 @@ struct filedescent {
|
|||||||
#define fde_fcntls fde_caps.fc_fcntls
|
#define fde_fcntls fde_caps.fc_fcntls
|
||||||
#define fde_ioctls fde_caps.fc_ioctls
|
#define fde_ioctls fde_caps.fc_ioctls
|
||||||
#define fde_nioctls fde_caps.fc_nioctls
|
#define fde_nioctls fde_caps.fc_nioctls
|
||||||
#define fde_change_size (offsetof(struct filedescent, fde_seqc))
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
static inline void
|
||||||
|
fde_copy(struct filedescent *from, struct filedescent *to)
|
||||||
|
{
|
||||||
|
|
||||||
|
to->fde_file = from->fde_file;
|
||||||
|
to->fde_caps = from->fde_caps;
|
||||||
|
to->fde_flags = from->fde_flags;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct fdescenttbl {
|
struct fdescenttbl {
|
||||||
int fdt_nfiles; /* number of open files allocated */
|
int fdt_nfiles; /* number of open files allocated */
|
||||||
|
Loading…
Reference in New Issue
Block a user