15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// found in the LICENSE file.
45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)//
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#ifndef LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_
65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_
75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "nacl_io/node.h"
95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace nacl_io {
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class RealNode : public Node {
135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public:
145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  RealNode(Filesystem* filesystem, int real_fd, bool close_on_destroy = false);
155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) protected:
175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error Init(int flags) { return 0; }
185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void Destroy();
205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public:
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Normal read/write operations on a file
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error Read(const HandleAttr& attr,
245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     void* buf,
255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     size_t count,
265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     int* out_bytes);
275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error Write(const HandleAttr& attr,
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                      const void* buf,
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                      size_t count,
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                      int* out_bytes);
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error FTruncate(off_t size);
325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error GetDents(size_t offs,
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                         struct dirent* pdir,
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                         size_t count,
355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                         int* out_bytes);
365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error GetStat(struct stat* stat);
375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error Isatty();
385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual Error MMap(void* addr,
395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     size_t length,
405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     int prot,
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     int flags,
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     size_t offset,
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                     void** out_addr);
445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) private:
465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  int real_fd_;
475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool close_on_destroy_;
485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)};
495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}  // namespace nacl_io
515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif  // LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_
53