ApraLinuxUtils 1.0.0
C++ utility library for embedded Linux systems
 
Loading...
Searching...
No Matches
StorageUSB.h
Go to the documentation of this file.
1/*
2 * StorageUSB.h
3 *
4 * Copyright (c) 2024 Apra Labs
5 *
6 * This file is part of ApraUtils.
7 *
8 * Licensed under the MIT License.
9 * See LICENSE file in the project root for full license information.
10 */
11
12#ifndef INCLUDES_APRA_UTILS_STORAGEUSB_H_
13#define INCLUDES_APRA_UTILS_STORAGEUSB_H_
14#include <string>
15#include <vector>
19
20namespace apra
21{
22
24{
25public:
26 StorageUSB(std::string mountPath, std::vector<STORAGE_TYPE> supportedTypes,
27 bool shouldPrint, bool skipMount = false);
28 virtual ~StorageUSB();
29 virtual string insertCheck();
30 virtual string mountDevice();
31 virtual bool ejectDevice();
32 virtual bool isUnsafeEject();
33 bool getStorageInfo(uint64_t &freeSpaceInMB, uint64_t &totalCapacityInMB);
35 std::string getMountPath();
36 struct udev_device* getChildDevice(struct udev *udev,
37 struct udev_device *parent, const char *subsystem);
38protected:
39 string findMountDeviceBylsblk(string devicePartitionNode);
40 string findMountedDevice(string devicePartitionNode);
41 std::string enumerateDevices(struct udev *udev);
42 std::vector<StorageMinimalInfo> getPartitions(std::string devpath);
43 bool mountDeviceNode(string deviceNode);
44 bool mountUSBDevice(StorageMinimalInfo storageDevice,
45 uint8_t retryLimit = 3);
46 bool unMountUSBDevice();
49 bool mountWithPrivilege(StorageMinimalInfo storageDevice,
50 uint8_t retryLimit = 3);
51 bool mountWithoutPrivilege(StorageMinimalInfo storageDevice);
52 StorageMinimalInfo getHighCapacityPartition(std::string deviceNode);
54 void checkDeviceNode();
55
57 std::vector<STORAGE_TYPE> m_supportedTypes;
58 std::string m_mountPoint;
59 std::string m_deviceNode;
60 std::string m_partitionNode;
63 std::string m_manualPath;
65};
66
67} /* namespace apra */
68
69#endif /* INCLUDES_APRA_UTILS_STORAGEUSB_H_ */
bool isDeviceNodeConnected()
std::vector< StorageMinimalInfo > getPartitions(std::string devpath)
string findMountDeviceBylsblk(string devicePartitionNode)
bool unMountWithoutPrivilege()
STORAGE_STATE m_state
Definition StorageUSB.h:62
std::vector< STORAGE_TYPE > m_supportedTypes
Definition StorageUSB.h:57
virtual ~StorageUSB()
bool unMountWithPrivilege()
std::string m_mountPoint
Definition StorageUSB.h:58
bool getStorageInfo(uint64_t &freeSpaceInMB, uint64_t &totalCapacityInMB)
virtual string insertCheck()
virtual bool ejectDevice()
virtual string mountDevice()
std::string getMountPath()
string findMountedDevice(string devicePartitionNode)
std::string m_manualPath
Definition StorageUSB.h:63
int8_t m_retryCount
Definition StorageUSB.h:64
std::string m_partitionNode
Definition StorageUSB.h:60
struct udev_device * getChildDevice(struct udev *udev, struct udev_device *parent, const char *subsystem)
StorageMinimalInfo getHighCapacityPartition(std::string deviceNode)
bool mountWithoutPrivilege(StorageMinimalInfo storageDevice)
STORAGE_STATE getStatus()
std::string enumerateDevices(struct udev *udev)
bool mountUSBDevice(StorageMinimalInfo storageDevice, uint8_t retryLimit=3)
std::string m_deviceNode
Definition StorageUSB.h:59
bool mountDeviceNode(string deviceNode)
bool mountWithPrivilege(StorageMinimalInfo storageDevice, uint8_t retryLimit=3)
virtual bool isUnsafeEject()
STORAGE_STATE