3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
6 * Copyright (C) 2009 Martin 'povik' Poviser (martin.povik@gmail.com)
7 * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 int read (unsigned fd
, void *buf
, unsigned len
)
36 fd_t
*d
= fd_get (fd
);
41 if (d
->flags
& O_WRONLY
)
47 if (d
->flags
& FD_PIPE
) {
48 pipe_t
*p
= pipe_get (fd
);
51 return pipe_read (p
, buf
, len
);
59 /* copy data from cache to buffer */
60 memcpy ((char *) buf
, d
->s
+d
->p
, len
);
65 /* HACK: this should call UPDATE handler */
67 d
->dev
->handler (DEV_ACT_UPDATE
);