The Pedigree Project  0.1
RawFsFile.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "RawFsFile.h"
21 #include "RawFs.h"
22 #include "pedigree/kernel/machine/Disk.h"
23 
24 class Filesystem;
25 
26 RawFsFile::RawFsFile(String name, RawFs *pFs, File *pParent, Disk *pDisk)
27  : File(
28  name, 0 /* Accessed time */, 0 /* Modified time */,
29  0 /* Creation time */, 0 /* Inode number */,
30  static_cast<Filesystem *>(pFs), 0 /* Size */, pParent),
31  m_pDisk(pDisk)
32 {
33  // Owned by root:root
34  setUid(0);
35  setGid(0);
36 
37  // RW for root, readable only by others.
38  uint32_t permissions = FILE_UR | FILE_UW | FILE_GR | FILE_OR;
39  setPermissions(permissions);
40 
41  // Disk size.
42  setSize(m_pDisk->getSize());
43 }
44 
46 {
47  return m_pDisk->getBlockSize();
48 }
49 
50 uintptr_t RawFsFile::readBlock(uint64_t location)
51 {
52  return m_pDisk->read(location);
53 }
Disk * m_pDisk
Definition: Filesystem.h:137
Definition: String.h:49
RawFsFile(const RawFsFile &file)
Definition: Disk.h:32
virtual uintptr_t readBlock(uint64_t location)
Definition: RawFsFile.cc:50
virtual uintptr_t read(uint64_t location)
Definition: Disk.cc:56
virtual size_t getSize() const
Gets the size of the disk.
Definition: Disk.cc:69
virtual size_t getBlockSize() const
Gets the block size of the disk.
Definition: Disk.cc:74
Definition: RawFs.h:32
Definition: File.h:66
virtual size_t getBlockSize() const
Definition: RawFsFile.cc:45