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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
|
// Copyright 2015 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SYSTEM_API_DBUS_CROS_DISKS_DBUS_CONSTANTS_H_
#define SYSTEM_API_DBUS_CROS_DISKS_DBUS_CONSTANTS_H_
#include <ostream>
#include <type_traits>
namespace cros_disks {
const char kCrosDisksInterface[] = "org.chromium.CrosDisks";
const char kCrosDisksServicePath[] = "/org/chromium/CrosDisks";
const char kCrosDisksServiceName[] = "org.chromium.CrosDisks";
const char kCrosDisksServiceError[] = "org.chromium.CrosDisks.Error";
// Methods.
const char kEnumerateAutoMountableDevices[] = "EnumerateAutoMountableDevices";
const char kEnumerateDevices[] = "EnumerateDevices";
const char kEnumerateMountEntries[] = "EnumerateMountEntries";
const char kFormat[] = "Format";
const char kSinglePartitionFormat[] = "SinglePartitionFormat";
const char kGetDeviceProperties[] = "GetDeviceProperties";
const char kMount[] = "Mount";
const char kRename[] = "Rename";
const char kUnmount[] = "Unmount";
// Signals.
const char kDeviceAdded[] = "DeviceAdded";
const char kDeviceScanned[] = "DeviceScanned";
const char kDeviceRemoved[] = "DeviceRemoved";
const char kDiskAdded[] = "DiskAdded";
const char kDiskChanged[] = "DiskChanged";
const char kDiskRemoved[] = "DiskRemoved";
const char kFormatCompleted[] = "FormatCompleted";
const char kMountCompleted[] = "MountCompleted";
const char kMountProgress[] = "MountProgress";
const char kRenameCompleted[] = "RenameCompleted";
// Properties.
// TODO(benchan): Drop unnecessary 'Device' / 'Drive' prefix as they were
// carried through old code base.
const char kDeviceFile[] = "DeviceFile";
const char kDeviceIsDrive[] = "DeviceIsDrive";
const char kDeviceIsMediaAvailable[] = "DeviceIsMediaAvailable";
const char kDeviceIsMounted[] = "DeviceIsMounted";
const char kDeviceIsOnBootDevice[] = "DeviceIsOnBootDevice";
const char kDeviceIsOnRemovableDevice[] = "DeviceIsOnRemovableDevice";
const char kDeviceIsReadOnly[] = "DeviceIsReadOnly";
const char kDeviceIsVirtual[] = "DeviceIsVirtual";
const char kDeviceMediaType[] = "DeviceMediaType";
const char kDeviceMountPaths[] = "DeviceMountPaths";
const char kDevicePresentationHide[] = "DevicePresentationHide";
const char kDeviceSize[] = "DeviceSize";
const char kDriveModel[] = "DriveModel";
const char kIsAutoMountable[] = "IsAutoMountable";
const char kIdLabel[] = "IdLabel";
const char kIdUuid[] = "IdUuid";
const char kVendorId[] = "VendorId";
const char kVendorName[] = "VendorName";
const char kProductId[] = "ProductId";
const char kProductName[] = "ProductName";
const char kBusNumber[] = "BusNumber";
const char kDeviceNumber[] = "DeviceNumber";
const char kStorageDevicePath[] = "StorageDevicePath";
const char kFileSystemType[] = "FileSystemType";
// Format options.
const char kFormatLabelOption[] = "Label";
// Device media type.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// See enum CrosDisksDeviceMediaType in tools/metrics/histograms/enums.xml.
enum class DeviceType {
kUnknown = 0,
kUSB = 1, // USB stick.
kSD = 2, // SD card.
kOpticalDisc = 3, // Optical disc, excluding DVD.
kMobile = 4, // Storage on a mobile device (e.g. Android).
kDVD = 5, // DVD.
kMaxValue = 5,
};
// Format error reported by cros-disks.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// See enum CrosDisksClientFormatError in tools/metrics/histograms/enums.xml.
enum class FormatError {
kSuccess = 0,
kUnknownError = 1,
kInternalError = 2,
kInvalidDevicePath = 3,
kDeviceBeingFormatted = 4,
kUnsupportedFilesystem = 5,
kFormatProgramNotFound = 6,
kFormatProgramFailed = 7,
kDeviceNotAllowed = 8,
kInvalidOptions = 9,
kLongName = 10,
kInvalidCharacter = 11,
kMaxValue = 11,
};
// Mount or unmount error code.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class MountError {
// Success.
kSuccess = 0,
// Generic error code.
kUnknownError = 1,
// Internal error.
kInternalError = 2,
// Invalid argument.
kInvalidArgument = 3,
// Invalid path.
kInvalidPath = 4,
// Not used.
kPathAlreadyMounted = 5,
// Tried to unmount a path that is not currently mounted.
kPathNotMounted = 6,
// Cannot create directory.
kDirectoryCreationFailed = 7,
// Invalid mount options.
kInvalidMountOptions = 8,
// Not used.
kInvalidUnmountOptions = 9,
// Insufficient permissions.
kInsufficientPermissions = 10,
// The FUSE mounter cannot be found.
kMountProgramNotFound = 11,
// The FUSE mounter finished with an error.
kMountProgramFailed = 12,
// The provided path to mount is invalid.
kInvalidDevicePath = 13,
// Cannot determine file system of the device.
kUnknownFilesystem = 14,
// The file system of the device is recognized but not supported.
kUnsupportedFilesystem = 15,
// Not used.
kInvalidArchive = 16,
// Either the FUSE mounter needs a password, or the provided password is
// incorrect.
kNeedPassword = 17,
// The FUSE mounter is currently launching, and it hasn't daemonized yet.
kInProgress = 18,
// The FUSE mounter was cancelled (killed) while it was launching.
kCancelled = 19,
// The device is busy.
kBusy = 20,
// Modify when adding enum values.
kMaxValue = 20,
};
// MountSourceType enum values are solely used by Chrome/CrosDisks in
// the MountCompleted signal, and currently not reported through UMA.
enum MountSourceType {
MOUNT_SOURCE_INVALID = 0,
MOUNT_SOURCE_REMOVABLE_DEVICE = 1,
MOUNT_SOURCE_ARCHIVE = 2,
MOUNT_SOURCE_NETWORK_STORAGE = 3,
};
// Partition error reported by cros-disks.
enum class PartitionError {
kSuccess = 0,
kUnknownError = 1,
kInternalError = 2,
kInvalidDevicePath = 3,
kDeviceBeingPartitioned = 4,
kProgramNotFound = 5,
kProgramFailed = 6,
kDeviceNotAllowed = 7,
};
// Rename error reported by cros-disks.
enum class RenameError {
kSuccess = 0,
kUnknownError = 1,
kInternalError = 2,
kInvalidDevicePath = 3,
kDeviceBeingRenamed = 4,
kUnsupportedFilesystem = 5,
kRenameProgramNotFound = 6,
kRenameProgramFailed = 7,
kDeviceNotAllowed = 8,
kLongName = 9,
kInvalidCharacter = 10,
};
// Output operators for logging and debugging.
template <typename C>
std::basic_ostream<C>& operator<<(std::basic_ostream<C>& out,
const DeviceType type) {
switch (type) {
#define PRINT(s) \
case DeviceType::k##s: \
return out << #s;
PRINT(Unknown)
PRINT(USB)
PRINT(SD)
PRINT(OpticalDisc)
PRINT(Mobile)
PRINT(DVD)
#undef PRINT
}
return out << "DeviceType(" << std::underlying_type_t<DeviceType>(type)
<< ")";
}
template <typename C>
std::basic_ostream<C>& operator<<(std::basic_ostream<C>& out,
const MountError error) {
switch (error) {
#define PRINT(s) \
case MountError::k##s: \
return out << #s;
PRINT(Success)
PRINT(UnknownError)
PRINT(InternalError)
PRINT(InvalidArgument)
PRINT(InvalidPath)
PRINT(PathAlreadyMounted)
PRINT(PathNotMounted)
PRINT(DirectoryCreationFailed)
PRINT(InvalidMountOptions)
PRINT(InvalidUnmountOptions)
PRINT(InsufficientPermissions)
PRINT(MountProgramNotFound)
PRINT(MountProgramFailed)
PRINT(InvalidDevicePath)
PRINT(UnknownFilesystem)
PRINT(UnsupportedFilesystem)
PRINT(InvalidArchive)
PRINT(NeedPassword)
PRINT(InProgress)
PRINT(Cancelled)
PRINT(Busy)
#undef PRINT
}
return out << "MountError(" << std::underlying_type_t<MountError>(error)
<< ")";
}
template <typename C>
std::basic_ostream<C>& operator<<(std::basic_ostream<C>& out,
const RenameError error) {
switch (error) {
#define PRINT(s) \
case RenameError::k##s: \
return out << #s;
PRINT(Success)
PRINT(UnknownError)
PRINT(InternalError)
PRINT(InvalidDevicePath)
PRINT(DeviceBeingRenamed)
PRINT(UnsupportedFilesystem)
PRINT(RenameProgramNotFound)
PRINT(RenameProgramFailed)
PRINT(DeviceNotAllowed)
PRINT(LongName)
PRINT(InvalidCharacter)
#undef PRINT
}
return out << "RenameError(" << std::underlying_type_t<RenameError>(error)
<< ")";
}
template <typename C>
std::basic_ostream<C>& operator<<(std::basic_ostream<C>& out,
const FormatError error) {
switch (error) {
#define PRINT(s) \
case FormatError::k##s: \
return out << #s;
PRINT(Success)
PRINT(UnknownError)
PRINT(InternalError)
PRINT(InvalidDevicePath)
PRINT(DeviceBeingFormatted)
PRINT(UnsupportedFilesystem)
PRINT(FormatProgramNotFound)
PRINT(FormatProgramFailed)
PRINT(DeviceNotAllowed)
PRINT(InvalidOptions)
PRINT(LongName)
PRINT(InvalidCharacter)
#undef PRINT
}
return out << "FormatError(" << std::underlying_type_t<FormatError>(error)
<< ")";
}
template <typename C>
std::basic_ostream<C>& operator<<(std::basic_ostream<C>& out,
const PartitionError error) {
switch (error) {
#define PRINT(s) \
case PartitionError::k##s: \
return out << #s;
PRINT(Success)
PRINT(UnknownError)
PRINT(InternalError)
PRINT(InvalidDevicePath)
PRINT(DeviceBeingPartitioned)
PRINT(ProgramNotFound)
PRINT(ProgramFailed)
PRINT(DeviceNotAllowed)
#undef PRINT
}
return out << "PartitionError("
<< std::underlying_type_t<PartitionError>(error) << ")";
}
} // namespace cros_disks
#endif // SYSTEM_API_DBUS_CROS_DISKS_DBUS_CONSTANTS_H_
|