*参照元 [#ff592b0a]
#backlinks

*説明 [#vca44a18]
-パス: [[linux-4.4.1/fs/file.c]]

-FIXME: これは何?
--説明


**引数 [#a23a0ff2]
-struct files_struct *files
--
--[[linux-4.4.1/files_struct]]
-unsigned int fd
--
-struct file *file
--
--[[linux-4.4.1/file]]


**返り値 [#l0d33d53]
-なし


**参考 [#b383a3fb]


*実装 [#xb5a1412]
 /*
  * Install a file pointer in the fd array.
  *
  * The VFS is full of places where we drop the files lock between
  * setting the open_fds bitmap and installing the file in the file
  * array.  At any such point, we are vulnerable to a dup2() race
  * installing a file in the array before us.  We need to detect this and
  * fput() the struct file we are about to overwrite in this case.
  *
  * It should never happen - if we allow dup2() do it, _really_ bad things
  * will follow.
  *
  * NOTE: __fd_install() variant is really, really low-level; don't
  * use it unless you are forced to by truly lousy API shoved down
  * your throat.  'files' *MUST* be either current->files or obtained
  * by get_files_struct(current) done by whoever had given it to you,
  * or really bad things will happen.  Normally you want to use
  * fd_install() instead.
  */
 
 void __fd_install(struct files_struct *files, unsigned int fd,
                 struct file *file)
 {
         struct fdtable *fdt;
 
-
--[[linux-4.4.1/fdtable]]

         might_sleep();
         rcu_read_lock_sched();
 
-
--[[linux-4.4.1/might_sleep()]]
--[[linux-4.4.1/rcu_read_lock_sched()]]

         while (unlikely(files->resize_in_progress)) {
                 rcu_read_unlock_sched();
                 wait_event(files->resize_wait, !files->resize_in_progress);
                 rcu_read_lock_sched();
         }
-
--[[linux-4.4.1/unlikely()]]
--[[linux-4.4.1/rcu_read_unlock_sched()]]
--[[linux-4.4.1/wait_event()]]

         /* coupled with smp_wmb() in expand_fdtable() */
         smp_rmb();
         fdt = rcu_dereference_sched(files->fdt);
         BUG_ON(fdt->fd[fd] != NULL);
         rcu_assign_pointer(fdt->fd[fd], file);
         rcu_read_unlock_sched();
-
--[[linux-4.4.1/smp_rmb()]]
--[[linux-4.4.1/rcu_dereference_sched()]]
--[[linux-4.4.1/BUG_ON()]]
--[[linux-4.4.1/rcu_assign_pointer()]]

 }


*コメント [#td5a0876]


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS