The Pedigree Project 0.1
PsAuxFile.h
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#ifndef _POSIX_PSAUXFILE_H
21#define _POSIX_PSAUXFILE_H
22
23#include "pedigree/kernel/utilities/Buffer.h"
24
25#include "modules/drivers/x86/ps2mouse/Ps2MouseCallbackRegistry.h"
26#include "modules/system/vfs/File.h"
27
28class PsAuxFile : public File {
29 public:
30 PsAuxFile(String str, size_t inode, Filesystem* pParentFS, File* pParentNode)
31 : File(str, 0, 0, 0, inode, pParentFS, 0, pParentNode),
32 m_Lock(),
33 m_Buffer(1024),
34 m_MouseRegistration() {
35 setPermissionsOnly(FILE_UR | FILE_UW | FILE_GR | FILE_GW | FILE_OR | FILE_OW);
36 setUidOnly(0);
37 setGidOnly(0);
38 }
39 ~PsAuxFile();
40
41 bool initialise();
42
43 uint64_t readBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock = true);
44 uint64_t writeBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock = true);
45
46 virtual int select(bool bWriting = false, int timeout = 0);
47
48 private:
49 Mutex m_Lock;
50 Buffer<uint8_t> m_Buffer;
52
53 static void subscriber(void* param, const void* buffer, size_t len);
54
55 void handleIncoming(const void* buffer, size_t len);
56
57 virtual bool isBytewise() const {
58 return true;
59 }
60};
61
62#endif
Definition File.h:75
void setGidOnly(size_t gid)
Definition File.cc:1448
void setPermissionsOnly(uint32_t perms)
Definition File.cc:1440
void setUidOnly(size_t uid)
Definition File.cc:1444
File()
Definition File.cc:165
Definition Mutex.h:56
uint64_t readBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
Definition PsAuxFile.cc:38
virtual bool isBytewise() const
Definition PsAuxFile.h:57
virtual int select(bool bWriting=false, int timeout=0)
Definition PsAuxFile.cc:49
uint64_t writeBytewise(uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
Definition PsAuxFile.cc:43