Determining Views Supported by a Particular File System

昨天說明完 Pro Java 7 NIO.2 的第一章,今天開始說明第二章 (Metadata File Attributes),因為第二章的內容比較多,會分幾次說明,先來看這一段原文的內容:

NIO.2 comes with a set of six views, an overview of which follows:
• BasicFileAttributeView: This is a view of basic attributes that must be supported
by all file system implementations. The attribute view name is basic.
• DosFileAttributeView: This view provides the standard four supported attributes
on file systems that support the DOS attributes. The attribute view name is dos.
• PosixFileAttributeView: This view extends the basic attribute view with attributes
supported on file systems that support the POSIX (Portable Operating System
Interface for Unix) family of standards, such as Unix. The attribute view name is
posix.
• FileOwnerAttributeView: This view is supported by any file system
implementation that supports the concept of a file owner. The attribute view
name is owner.
• AclFileAttributeView: This view supports reading or updating a file’s ACL. The
NFSv4 ACL model is supported. The attribute view name is acl.
• UserDefinedFileAttributeView: This view enables support of metadata that is user
defined

NIO 2 針對檔案系統提供了上述六個 view,可以用來查詢、操作檔案系統的 metadata,不過,每個 OS 的檔案系統組成各不相同,上述六個 view 在程式正執行的那個 OS 上只會有部份是被支援的! 那麼到底 OS 支援那些 view 呢? 可以用這段程式來測試:

 1 package idv.steven.nio2.metadata;
 2
 3 import java.nio.file.FileSystem;
 4 import java.nio.file.FileSystems;
 5 import java.util.Set;
 6
 7 public class Determining {
 8
 9     public static void main(String[] args) {
10         FileSystem fs = FileSystems.getDefault();
11         Set<String> views = fs.supportedFileAttributeViews();
12         for (String view : views) {
13             System.out.println(view);
14         }
15     }
16 }

在 Windows 7 底下執行,輸出如下:

owner
dos
acl
basic
user

在 scientific linux 7.x 下執行,輸出如下:

basic
owner
user
unix
dos
posix

上面執行結果中,紅色標出兩個不同作業系統各自支援的 view,另外,如果想測試出目前的 OS 擁有那些 file store,要用什麼方法? 看一下如下程式:

 1 package idv.steven.nio2.metadata;
 2
 3 import java.nio.file.FileStore;
 4 import java.nio.file.FileSystem;
 5 import java.nio.file.FileSystems;
 6 import java.nio.file.attribute.BasicFileAttributeView;
 7
 8 public class Available {
 9
10     public static void main(String[] args) {
11         FileSystem fs = FileSystems.getDefault();
12         for (FileStore store : fs.getFileStores()) {
13             boolean supported = store.supportsFileAttributeView(BasicFileAttributeView.class);
14             System.out.println(store.name() + " ---" + supported);
15         }
16     }
17 }

在我的 Windows 7 中,因為有 C、D、E 三個磁碟,它們的 volume 分別命名為 System、Document、Software,所以執行結果如下:

System ---true
Document ---true
Software ---true

在 scientific linux 7.x 執行結果會如何呢? 在了解執行結果前,請先在命令列中下 df -a 的指令,用這指令輸出的結果和上述程式的結果比較就知道是什麼了。基本上,linux 上我們會將整顆硬碟劃分成比較多的 partition。

时间: 2024-07-31 08:11:09

Determining Views Supported by a Particular File System的相关文章

Global UNIX file system cylinder group cache

A global?cylinder?group?(CG) cache is stored in file server memory and shared by a plurality of file systems supported by the file server. The global CG cache comprises a number CG entries which are pre-allocated in memory. As different file systems

Extensible File System

An extensible file system format for portable storage media is provided. The extensible file system format includes the specification of primary and secondary directory entry types that may be custom defined. The primary and secondary directory entry

Can Microsoft’s exFAT file system bridge the gap between OSes?

转自:http://arstechnica.com/information-technology/2013/06/review-is-microsofts-new-data-sharing-system-a-cross-platform-savior/ With Apple's licensing of Microsoft's exFAT file system, it seems like we finally have a good option for OS X and Windows d

LFS(the Log-structured File System)系统详解

There was a large and growing gap between random I/O performance and sequential I/O performance: Existing file systems perform poorly on many common workloads: LFS文件系统的设计木主要是为了解决上面这以前文件系统所存在的两个问题:随机输入输出的性能和序列输入输出的性能相差很大:还有就是磁盘搜索和旋转延迟比较大. LFS, short f

File System Design Case Studies

SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Introduction We've studied various approaches to file system design. Now we'll look at some real file systems to explore the approaches that were taken i

HDFS分布式文件系统(The Hadoop Distributed File System)

The Hadoop Distributed File System (HDFS) is designed to store very large data sets reliably, and to stream those data sets at high bandwidth to user applications. In a large cluster, thousands of servers both host directly attached storage and execu

Parallel file system processing

A treewalk for splitting a file directory is disclosed for parallel execution of work items over a filesystem. The given work item is assigned to a worker. Thereafter, a request is sent to split the file directory to share a portion of the file direc

Low-overhead enhancement of reliability of journaled file system using solid state storage and de-duplication

A mechanism is provided in a data processing system for reliable asynchronous solid-state device based de-duplication. Responsive to receiving a write request to write data to the file system, the mechanism sends the write request to the file system,

Common Internet File System

CIFS (Common Internet File System) is a protocol that gained popularity around the year 2000, as vendors worked to establish an Internet Protocol-based file-sharing protocol. The Common Internet File System (CIFS) is the standard way that computer us