linux-4.4.1/__alloc_fd()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#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 fl...
{
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 structur...
* will limit the total number of files that can...
*/
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 n...
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]
終了行:
*参照元 [#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 fl...
{
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 structur...
* will limit the total number of files that can...
*/
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 n...
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]
ページ名: