View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.software.os.linux;
6   
7   import oshi.annotation.concurrent.ThreadSafe;
8   import oshi.software.common.AbstractOSFileStore;
9   import oshi.software.os.OSFileStore;
10  
11  /**
12   * OSFileStore implementation
13   */
14  @ThreadSafe
15  public class LinuxOSFileStore extends AbstractOSFileStore {
16  
17      private String logicalVolume;
18      private String description;
19      private String fsType;
20  
21      private long freeSpace;
22      private long usableSpace;
23      private long totalSpace;
24      private long freeInodes;
25      private long totalInodes;
26  
27      public LinuxOSFileStore(String name, String volume, String label, String mount, String options, String uuid,
28              String logicalVolume, String description, String fsType, long freeSpace, long usableSpace, long totalSpace,
29              long freeInodes, long totalInodes) {
30          super(name, volume, label, mount, options, uuid);
31          this.logicalVolume = logicalVolume;
32          this.description = description;
33          this.fsType = fsType;
34          this.freeSpace = freeSpace;
35          this.usableSpace = usableSpace;
36          this.totalSpace = totalSpace;
37          this.freeInodes = freeInodes;
38          this.totalInodes = totalInodes;
39      }
40  
41      @Override
42      public String getLogicalVolume() {
43          return this.logicalVolume;
44      }
45  
46      @Override
47      public String getDescription() {
48          return this.description;
49      }
50  
51      @Override
52      public String getType() {
53          return this.fsType;
54      }
55  
56      @Override
57      public long getFreeSpace() {
58          return this.freeSpace;
59      }
60  
61      @Override
62      public long getUsableSpace() {
63          return this.usableSpace;
64      }
65  
66      @Override
67      public long getTotalSpace() {
68          return this.totalSpace;
69      }
70  
71      @Override
72      public long getFreeInodes() {
73          return this.freeInodes;
74      }
75  
76      @Override
77      public long getTotalInodes() {
78          return this.totalInodes;
79      }
80  
81      @Override
82      public boolean updateAttributes() {
83          for (OSFileStore fileStore : LinuxFileSystem.getFileStoreMatching(getName(), null)) {
84              if (getVolume().equals(fileStore.getVolume()) && getMount().equals(fileStore.getMount())) {
85                  this.logicalVolume = fileStore.getLogicalVolume();
86                  this.description = fileStore.getDescription();
87                  this.fsType = fileStore.getType();
88                  this.freeSpace = fileStore.getFreeSpace();
89                  this.usableSpace = fileStore.getUsableSpace();
90                  this.totalSpace = fileStore.getTotalSpace();
91                  this.freeInodes = fileStore.getFreeInodes();
92                  this.totalInodes = fileStore.getTotalInodes();
93                  return true;
94              }
95          }
96          return false;
97      }
98  }