summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/libraries/nacl_io/mount.cc
blob: 3c0d7a2f1a651995a834d55d64cfb6ac6811f0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "nacl_io/mount.h"

#include <errno.h>
#include <fcntl.h>
#include <string>

#include "nacl_io/mount_node.h"
#include "nacl_io/mount_node_dir.h"
#include "nacl_io/mount_node_mem.h"
#include "nacl_io/osstat.h"
#include "nacl_io/path.h"
#include "sdk_util/auto_lock.h"
#include "sdk_util/ref_object.h"

#if defined(WIN32)
#include <windows.h>
#endif

namespace nacl_io {

Mount::Mount() : dev_(0) {}

Mount::~Mount() {}

Error Mount::Init(const MountInitArgs& args) {
  dev_ = args.dev;
  ppapi_ = args.ppapi;
  return 0;
}

void Mount::Destroy() {}

Error Mount::OpenResource(const Path& path, ScopedMountNode* out_node) {
  out_node->reset(NULL);
  return EINVAL;
}

void Mount::OnNodeCreated(MountNode* node) {
  node->stat_.st_ino = inode_pool_.Acquire();
  node->stat_.st_dev = dev_;
}

void Mount::OnNodeDestroyed(MountNode* node) {
  if (node->stat_.st_ino)
    inode_pool_.Release(node->stat_.st_ino);
}

}  // namespace nacl_io