3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2009 Martin 'povik' Poviser (martin.povik@gmail.com)
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 for (fd
= fd_list
.next
; fd
!= &fd_list
; fd
= fd
->next
) {
33 if (fd
->id
== (unsigned) id
)
40 fd_t
*fd_create (int flags
)
43 fd_t
*fd
= kmalloc (sizeof (fd_t
));
72 fd
->prev
= fd_list
.prev
;
79 int fd_delete (fd_t
*fd
)
95 /* delete old file descriptor from fd_list */
96 fd
->next
->prev
= fd
->prev
;
97 fd
->prev
->next
= fd
->next
;
104 unsigned int init_fd ()
106 fd_list
.next
= &fd_list
;
107 fd_list
.prev
= &fd_list
;
109 /* HACK: first we need create file descriptor 0 and 1 for stdout and stdin */
110 stdin
= fd_create (0);
111 stdout
= fd_create (0);