Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: disk-manager.cc

Issue 6824032: First batch of cros-disk changes (Closed) Base URL: ssh://gitrw.chromium.org:9222/cros-disks.git@master
Patch Set: adds set_ and removes j's Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « disk-manager.h ('k') | main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: disk-manager.cc
diff --git a/disk-manager.cc b/disk-manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1568565dc9779b21843839786cd55dadb11aac3c
--- /dev/null
+++ b/disk-manager.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 The Chromium OS 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 "disk-manager.h"
+
+#include "disk.h"
+
+#include <base/logging.h>
+#include <libudev.h>
+#include <vector>
+
+
+namespace cros_disks {
+
+DiskManager::DiskManager()
+ : udev_(udev_new()),
+ udev_monitor_fd_(0) {
+
+ CHECK(udev_) << "Failed to initialize udev";
+ udev_monitor_ = udev_monitor_new_from_netlink(udev_, "udev");
+ udev_monitor_filter_add_match_subsystem_devtype(udev_monitor_, "block", NULL);
+ udev_monitor_enable_receiving(udev_monitor_);
+ udev_monitor_fd_ = udev_monitor_get_fd(udev_monitor_);
+}
+
+DiskManager::~DiskManager() {
+ udev_monitor_unref(udev_monitor_);
+ udev_unref(udev_);
+}
+
+std::vector<Disk> DiskManager::EnumerateDisks() {
+ //TODO(rtc): implement this...
+ std::vector<Disk> disks;
+ return disks;
+}
+
+bool DiskManager::ProcessUdevChanges() {
+ struct udev_device *dev = udev_monitor_receive_device(udev_monitor_);
+ CHECK(dev) << "Unknown udev device";
+ LOG(INFO) << "Got Device";
+ LOG(INFO) << " Node: " << udev_device_get_devnode(dev);
+ LOG(INFO) << " Subsystem: " << udev_device_get_subsystem(dev);
+ LOG(INFO) << " Devtype: " << udev_device_get_devtype(dev);
+ LOG(INFO) << " Action: " << udev_device_get_action(dev);
+ udev_device_unref(dev);
+ return true;
+}
+
+} // namespace cros_disks
« no previous file with comments | « disk-manager.h ('k') | main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698