libstorage-ng
Filesystem.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) 2016 SUSE LLC
4  *
5  * All Rights Reserved.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of version 2 of the GNU General Public License as published
9  * by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, contact Novell, Inc.
18  *
19  * To contact Novell about this file by physical or electronic mail, you may
20  * find current contact information at www.novell.com.
21  */
22 
23 
24 #ifndef STORAGE_FILESYSTEM_H
25 #define STORAGE_FILESYSTEM_H
26 
27 
28 #include <vector>
29 #include <list>
30 
31 #include "storage/Devices/Device.h"
32 
33 
34 namespace storage
35 {
36 
37  class BlkDevice;
38  class ContentInfo;
39 
40 
41  enum class FsType {
42  UNKNOWN, REISERFS, EXT2, EXT3, EXT4, BTRFS, VFAT, XFS, JFS, HFS, NTFS,
43  SWAP, HFSPLUS, NFS, NFS4, TMPFS, ISO9660, UDF
44  };
45 
46 
48  enum class MountByType {
49  DEVICE, UUID, LABEL, ID, PATH
50  };
51 
52 
53  std::string get_mount_by_name(MountByType mount_by_type);
54 
55 
56  // abstract class
57 
58  class Filesystem : public Device
59  {
60  public:
61 
62  static std::vector<Filesystem*> get_all(Devicegraph* devicegraph);
63  static std::vector<const Filesystem*> get_all(const Devicegraph* devicegraph);
64 
65  FsType get_type() const;
66 
67  virtual bool supports_label() const = 0;
68  virtual unsigned int max_labelsize() const = 0;
69 
70  const std::string& get_label() const;
71  void set_label(const std::string& label);
72 
73  virtual bool supports_uuid() const = 0;
74 
75  const std::string& get_uuid() const;
76  void set_uuid(const std::string& uuid);
77 
78  const std::vector<std::string>& get_mountpoints() const;
79  void set_mountpoints(const std::vector<std::string>& mountpoints);
80  void add_mountpoint(const std::string& mountpoint);
81 
82  MountByType get_mount_by() const;
83  void set_mount_by(MountByType mount_by);
84 
85  const std::list<std::string>& get_fstab_options() const;
86  void set_fstab_options(const std::list<std::string>& fstab_options);
87 
88  const std::string& get_mkfs_options() const;
89  void set_mkfs_options(const std::string& mkfs_options);
90 
91  const std::string& get_tune_options() const;
92  void set_tune_options(const std::string& tune_options);
93 
97  void set_resize_info(const ResizeInfo& resize_info);
98 
99  ContentInfo detect_content_info() const;
100 
104  void set_content_info(const ContentInfo& content_info);
105 
106  static std::vector<Filesystem*> find_by_label(const Devicegraph* devicegraph,
107  const std::string& label);
108 
109  static std::vector<Filesystem*> find_by_mountpoint(const Devicegraph* devicegraph,
110  const std::string& mountpoint);
111 
112  // TODO class BlkFilesystem for not nfs, tmpfs?
113  std::vector<const BlkDevice*> get_blk_devices() const;
114 
115  public:
116 
117  class Impl;
118 
119  Impl& get_impl();
120  const Impl& get_impl() const;
121 
122  protected:
123 
124  Filesystem(Impl* impl);
125 
126  };
127 
128 
129  bool is_filesystem(const Device* device);
130 
131  Filesystem* to_filesystem(Device* device);
132  const Filesystem* to_filesystem(const Device* device);
133 
134 }
135 
136 #endif
The master container of the libstorage.
Definition: Devicegraph.h:133
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:73
Definition: Filesystem.h:58
The storage namespace.
Definition: Actiongraph.h:36
MountByType
The key by which the mount program identifies a filesystem.
Definition: Filesystem.h:48