Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F169927045
D52487.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D52487.id.diff
View Options
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -658,6 +658,7 @@
error = EBADF;
break;
}
+ fsetfl_lock(fp);
do {
tmp = flg = fp->f_flag;
tmp &= ~FCNTLFLAGS;
@@ -677,6 +678,7 @@
if (error != 0)
goto revert_nonblock;
}
+ fsetfl_unlock(fp);
fdrop(fp, td);
break;
revert_nonblock:
@@ -691,6 +693,7 @@
tmp |= got_cleared;
tmp &= ~got_set;
} while (atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0);
+ fsetfl_unlock(fp);
fdrop(fp, td);
break;
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -896,6 +896,18 @@
return (atomic_load_long(&fp->f_offset));
}
+void
+fsetfl_lock(struct file *fp)
+{
+ file_v_lock(fp, FILE_V_SETFL_LOCKED, FILE_V_SETFL_LOCK_WAITING);
+}
+
+void
+fsetfl_unlock(struct file *fp)
+{
+ file_v_unlock(fp, FILE_V_SETFL_LOCKED, FILE_V_SETFL_LOCK_WAITING);
+}
+
#else /* OFF_MAX <= LONG_MAX */
static void
@@ -971,6 +983,30 @@
return (foffset_lock(fp, FOF_NOLOCK));
}
+
+void
+fsetfl_lock(struct file *fp)
+{
+ struct mtx *mtxp;
+
+ mtxp = mtx_pool_find(mtxpool_sleep, fp);
+ mtx_lock(mtxp);
+ file_v_lock_mtxp(fp, mtxp, FILE_V_SETFL_LOCKED,
+ FILE_V_SETFL_LOCK_WAITING);
+ mtx_unlock(mtxp);
+}
+
+void
+fsetfl_unlock(struct file *fp)
+{
+ struct mtx *mtxp;
+
+ mtxp = mtx_pool_find(mtxpool_sleep, fp);
+ mtx_lock(mtxp);
+ file_v_unlock_mtxp(fp, mtxp, FILE_V_SETFL_LOCKED,
+ FILE_V_SETFL_LOCK_WAITING);
+ mtx_unlock(mtxp);
+}
#endif
void
diff --git a/sys/sys/file.h b/sys/sys/file.h
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -93,6 +93,8 @@
void foffset_lock_uio(struct file *fp, struct uio *uio, int flags);
void foffset_unlock(struct file *fp, off_t val, int flags);
void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags);
+void fsetfl_lock(struct file *fp);
+void fsetfl_unlock(struct file *fp);
static inline off_t
foffset_get(struct file *fp)
@@ -222,6 +224,8 @@
#define FILE_V_FOFFSET_LOCKED 0x0001
#define FILE_V_FOFFSET_LOCK_WAITING 0x0002
+#define FILE_V_SETFL_LOCKED 0x0004
+#define FILE_V_SETFL_LOCK_WAITING 0x0008
#endif /* __BSD_VISIBLE */
#endif /* _KERNEL || _WANT_FILE */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 4, 12:08 AM (8 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38173745
Default Alt Text
D52487.id.diff (2 KB)
Attached To
Mode
D52487: fcntl(F_SETFL): only allow one thread to perform F_SETFL
Attached
Detach File
Event Timeline
Log In to Comment