vfs: check userland buffers before reading them.
[haiku.git] / src / system / boot / loader / file_systems / bfs / File.cpp
blob2853ed11b18513baf46412d2e18d7c1237a57314
1 /*
2 * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de.
3 * This file may be used under the terms of the MIT License.
4 */
7 #include "File.h"
10 namespace BFS {
13 File::File(Volume &volume, block_run run)
15 fStream(volume, run)
20 File::File(Volume &volume, off_t id)
22 fStream(volume, id)
27 File::File(const Stream &stream)
29 fStream(stream)
34 File::~File()
39 status_t
40 File::InitCheck()
42 return fStream.InitCheck();
46 ssize_t
47 File::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
49 status_t status = fStream.ReadAt(pos, (uint8 *)buffer, &bufferSize);
50 if (status < B_OK)
51 return status;
53 return bufferSize;
57 ssize_t
58 File::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
60 return EROFS;
64 status_t
65 File::GetName(char *nameBuffer, size_t bufferSize) const
67 return fStream.GetName(nameBuffer, bufferSize);
71 int32
72 File::Type() const
74 return S_IFREG;
78 off_t
79 File::Size() const
81 return fStream.Size();
85 ino_t
86 File::Inode() const
88 return fStream.ID();
92 } // namespace BFS