*参照元 [#sce36166]
#backlinks

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

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


**引数 [#c7327776]
-struct files_struct *files
--
--[[linux-4.4.1/files_struct]]
-unsigned start
--
-unsigned end
--
-unsigned flags
--


**返り値 [#gce76bbe]
-int
--


**参考 [#f7d8728e]


*実装 [#l8fc96f7]
 /*
  * allocate a file descriptor, mark it busy.
  */
 int __alloc_fd(struct files_struct *files,
                unsigned start, unsigned end, unsigned flags)
 {
         unsigned int fd;
         int error;
         struct fdtable *fdt;
 
-
--[[linux-4.4.1/fdtable]]

         spin_lock(&files->file_lock);
-
--[[linux-4.4.1/spin_lock()]]

 repeat:
         fdt = files_fdtable(files);
         fd = start;
-
--[[linux-4.4.1/files_fdtable()]]

         if (fd < files->next_fd)
                 fd = files->next_fd;
 
         if (fd < fdt->max_fds)
                 fd = find_next_fd(fdt, fd);
 
-
--[[linux-4.4.1/find_next_fd()]]

         /*
          * N.B. For clone tasks sharing a files structure, this test
          * will limit the total number of files that can be opened.
          */
         error = -EMFILE;
         if (fd >= end)
                 goto out;
 
         error = expand_files(files, fd);
         if (error < 0)
                 goto out;
 
-
--[[linux-4.4.1/expand_files()]]

         /*
          * If we needed to expand the fs array we
          * might have blocked - try again.
          */
         if (error)
                 goto repeat;
 
         if (start <= files->next_fd)
                 files->next_fd = fd + 1;
 
         __set_open_fd(fd, fdt);
         if (flags & O_CLOEXEC)
                 __set_close_on_exec(fd, fdt);
         else
                 __clear_close_on_exec(fd, fdt);
         error = fd;
-
--[[linux-4.4.1/__set_open_fd()]]
--[[linux-4.4.1/__set_close_on_exec()]]
--[[linux-4.4.1/__clear_close_on_exec()]]

 #if 1
         /* Sanity check */
         if (rcu_access_pointer(fdt->fd[fd]) != NULL) {
                 printk(KERN_WARNING "alloc_fd: slot %d not NULL!\n", fd);
                 rcu_assign_pointer(fdt->fd[fd], NULL);
         }
-
--[[linux-4.4.1/rcu_access_pointer()]]
--[[linux-4.4.1/printk()]]
--[[linux-4.4.1/rcu_assign_pointer()]]

 #endif
 
 out:
         spin_unlock(&files->file_lock);
         return error;
-
--[[linux-4.4.1/spin_unlock()]]

 }


*コメント [#e2aff429]


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