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