diff --git a/src/fileset-example.in b/src/fileset-example.in index 3764abe..5eb57e8 100644 --- a/src/fileset-example.in +++ b/src/fileset-example.in @@ -1,3 +1,4 @@ mmlsfileset::HEADER:version:reserved:reserved:filesystemName:filesetName:id:rootInode:status:path:parentId:created:inodes:dataInKB:comment:filesetMode:afmTarget:afmState:afmMode:afmFileLookupRefreshInterval:afmFileOpenRefreshInterval:afmDirLookupRefreshInterval:afmDirOpenRefreshInterval:afmAsyncDelay:afmNeedsRecovery:afmExpirationTimeout:afmRPO:afmLastPSnapId:inodeSpace:isInodeSpaceOwner:maxInodes:allocInodes:inodeSpaceMask:afmShowHomeSnapshots:afmNumReadThreads:reserved:afmReadBufferSize:afmWriteBufferSize:afmReadSparseThreshold:afmParallelReadChunkSize:afmParallelReadThreshold:snapId:afmNumFlushThreads:afmPrefetchThreshold:afmEnableAutoEviction:permChangeFlag:afmParallelWriteThreshold:freeInodes:afmNeedsResync:afmParallelWriteChunkSize:afmNumWriteThreads:afmPrimaryID:afmDRState:afmAssociatedPrimaryId:afmDIO:afmGatewayNode:afmIOFlags:afmVerifyDmapi:afmSkipHomeACL:afmSkipHomeMtimeNsec:afmForceCtimeChange:afmSkipResyncRecovery:afmSkipConflictQDrop:afmRefreshAsync:afmParallelMounts:afmRefreshOnce:afmSkipHomeCtimeNsec:afmReaddirOnce:afmResyncVer2:afmSnapUncachedRead:afmFastCreate:afmObjectXattr:afmObjectVHB:afmObjectNoDirectoryObj:afmSkipHomeRefresh:afmObjectGCS:afmObjectUserKeys:afmWriteOnClose:afmObjectSSL:afmObjectACL:afmMUPromoted:afmMUAutoRemove:afmObjFastReaddir:afmObjectBlkIO:preventSnapshotRestore:permInheritFlag:afmIOFlags2:afmRemoteUpdate:falStatus: mmlsfileset::0:1:::gpfs1:public:271:73014444035:Linked:%2Fgpfs1%2Fpublic:0:Fri Oct 29 14%3A18%3A40 2021:-:-::off:-:-:-:-:-:-:-:-:-:-:-:-:136:1:20971520:5251072:66846720:-:-:-:-:-:-:-:-:0:-:-:-:chmodAndSetacl:-:4719472:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:no:inheritAclOnly:-:-:default: mmlsfileset::0:1:::gpfs1:work:269:72477573123:Linked:%2Fgpfs1%2Fwork:0:Fri Oct 29 14%3A07%3A35 2021:-:-::off:-:-:-:-:-:-:-:-:-:-:-:-:135:1:295313408:260063232:66846720:-:-:-:-:-:-:-:-:0:-:-:-:chmodAndSetacl:-:151587111:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:no:inheritAclOnly:-:-:default: +mmlsfileset::0:1:::gpfs1:data_foo:126:103079215107:Linked:%2Fgpfs1%2Fdata%2Ffoo:0:Tue Dec 5 10%3A44%3A05 2023:-:-:end of project%3A 2026-11:off:-:-:-:-:-:-:-:-:-:-:-:-:192:1:20000768:1032192:66846720:-:-:-:-:-:-:-:-:0:-:-:-:chmodAndSetacl:-:1031235:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:no:inheritAclOnly:-:-:-:-:-:-:-:-:default: diff --git a/src/fileset.rs b/src/fileset.rs index 4433767..bdb0d60 100644 --- a/src/fileset.rs +++ b/src/fileset.rs @@ -12,6 +12,7 @@ pub struct Fileset { fileset_name: String, max_inodes: u64, alloc_inodes: u64, + comment: Option, } impl Fileset { @@ -38,6 +39,12 @@ impl Fileset { pub const fn alloc_inodes(&self) -> u64 { self.alloc_inodes } + + /// Optionally returns the comment. + #[must_use] + pub const fn comment(&self) -> Option<&String> { + self.comment.as_ref() + } } /// Returns all filesets of the given file system. @@ -99,6 +106,7 @@ struct Index { fileset_name: Option, max_inodes: Option, alloc_inodes: Option, + comment: Option, } fn from_reader(input: Input) -> Result> { @@ -147,11 +155,17 @@ fn from_tokens(tokens: &[&str], index: &Index) -> Result { .parse() .with_context(|| "parsing allocInodes value")?; + let comment_index = + index.comment.ok_or_else(|| anyhow!("no comment index"))?; + let comment = tokens[comment_index].replace("%3A", ":"); + let comment = Some(comment).filter(|s| !s.is_empty()); + Ok(Fileset { filesystem_name, fileset_name, max_inodes, alloc_inodes, + comment, }) } @@ -162,6 +176,7 @@ fn header_to_index(tokens: &[&str], index: &mut Index) { "filesetName" => index.fileset_name = Some(i), "maxInodes" => index.max_inodes = Some(i), "allocInodes" => index.alloc_inodes = Some(i), + "comment" => index.comment = Some(i), _ => {} } } @@ -189,6 +204,7 @@ mod tests { fileset_name: "public".into(), max_inodes: 20_971_520, alloc_inodes: 5_251_072, + comment: None, }) ); @@ -199,6 +215,18 @@ mod tests { fileset_name: "work".into(), max_inodes: 295_313_408, alloc_inodes: 260_063_232, + comment: None, + }) + ); + + assert_eq!( + filesets.next(), + Some(Fileset { + filesystem_name: "gpfs1".into(), + fileset_name: "data_foo".into(), + max_inodes: 20_000_768, + alloc_inodes: 1_032_192, + comment: Some("end of project: 2026-11".into()), }) );