View Javadoc
1   /*
2    * Copyright 2021-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.software.os.unix.openbsd;
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 OpenBsdOSFileStore 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 OpenBsdOSFileStore(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 : OpenBsdFileSystem.getFileStoreMatching(getName())) {
84              if (getName().equals(fileStore.getName()) && getVolume().equals(fileStore.getVolume())
85                      && getMount().equals(fileStore.getMount())) {
86                  this.logicalVolume = fileStore.getLogicalVolume();
87                  this.description = fileStore.getDescription();
88                  this.fsType = fileStore.getType();
89                  this.freeSpace = fileStore.getFreeSpace();
90                  this.usableSpace = fileStore.getUsableSpace();
91                  this.totalSpace = fileStore.getTotalSpace();
92                  this.freeInodes = fileStore.getFreeInodes();
93                  this.totalInodes = fileStore.getTotalInodes();
94                  return true;
95              }
96          }
97          return false;
98      }
99  }