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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « disk-manager.h ('k') | main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "disk-manager.h"
6
7 #include "disk.h"
8
9 #include <base/logging.h>
10 #include <libudev.h>
11 #include <vector>
12
13
14 namespace cros_disks {
15
16 DiskManager::DiskManager()
17 : udev_(udev_new()),
18 udev_monitor_fd_(0) {
19
20 CHECK(udev_) << "Failed to initialize udev";
21 udev_monitor_ = udev_monitor_new_from_netlink(udev_, "udev");
22 udev_monitor_filter_add_match_subsystem_devtype(udev_monitor_, "block", NULL);
23 udev_monitor_enable_receiving(udev_monitor_);
24 udev_monitor_fd_ = udev_monitor_get_fd(udev_monitor_);
25 }
26
27 DiskManager::~DiskManager() {
28 udev_monitor_unref(udev_monitor_);
29 udev_unref(udev_);
30 }
31
32 std::vector<Disk> DiskManager::EnumerateDisks() {
33 //TODO(rtc): implement this...
34 std::vector<Disk> disks;
35 return disks;
36 }
37
38 bool DiskManager::ProcessUdevChanges() {
39 struct udev_device *dev = udev_monitor_receive_device(udev_monitor_);
40 CHECK(dev) << "Unknown udev device";
41 LOG(INFO) << "Got Device";
42 LOG(INFO) << " Node: " << udev_device_get_devnode(dev);
43 LOG(INFO) << " Subsystem: " << udev_device_get_subsystem(dev);
44 LOG(INFO) << " Devtype: " << udev_device_get_devtype(dev);
45 LOG(INFO) << " Action: " << udev_device_get_action(dev);
46 udev_device_unref(dev);
47 return true;
48 }
49
50 } // namespace cros_disks
OLDNEW
« 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