Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow full path reassembly in USN parser to be disabled #95

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions parser/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ func (self *NTFSContext) SetOptions(options Options) {
self.options = options
}

func (self *NTFSContext) GetOptions() *Options {
self.mu.Lock()
defer self.mu.Unlock()

return &self.options
}

func (self *NTFSContext) Close() {
if debug {
fmt.Printf(STATS.DebugString())
Expand Down
4 changes: 4 additions & 0 deletions parser/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type Options struct {
// These path components will be added in front of each link
// generated.
PrefixComponents []string

// Disable resolution of USN paths through the MFT. This is useful
// when there is no MFT to look at.
DisableFullPathResolution bool
}

func GetDefaultOptions() Options {
Expand Down
4 changes: 4 additions & 0 deletions parser/usn.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (self *USN_RECORD) Links() []string {
}

func (self *USN_RECORD) _Links(depth int) []string {
if self.context.GetOptions().DisableFullPathResolution {
return []string{self.Filename()}
}

// Since this record could have meant a file deletion event
// then resolving the actual MFT entry to a full path is less
// reliable. It is more reliable to resolve the parent path,
Expand Down
Loading