Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Remove miq-unicode dependency, encode manually #6

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions lib/virtfs/ntfs/attrib_attribute_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'fs/ntfs/utils'
require 'binary_struct'
require 'util/miq-unicode'

module NTFS
#
Expand Down Expand Up @@ -76,7 +75,7 @@ def initialize(buf, boot_sector)

# If there's a name get it.
len = aal['name_length'] * 2
aal['name'] = buf[pos + aal['name_offset'], len].UnicodeToUtf8 if len > 0
aal['name'] = NTFS::Utils.UnicodeToUtf8(buf[pos + aal['name_offset'], len]) if len > 0

# Log instances of funky references.
aal['mft'] = NTFS::Utils.MkRef(aal['mft_reference'])[1]
Expand Down
7 changes: 3 additions & 4 deletions lib/virtfs/ntfs/attrib_file_name.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'fs/ntfs/utils'
require 'util/win32/nt_util'
require 'binary_struct'
require 'util/miq-unicode'
require 'fs/ntfs/attrib_standard_information'

module NTFS
Expand Down Expand Up @@ -47,7 +46,7 @@ class FileName
NS_DOS = 2
NS_DOSWIN = 3

UNNAMED = '[unnamed]'.AsciiToUtf8.freeze
UNNAMED = '[unnamed]'.freeze

def initialize(buf)
raise "MIQ(NTFS::FileName.initialize) Nil buffer" if buf.nil?
Expand All @@ -62,8 +61,8 @@ def initialize(buf)
@refParent = NTFS::Utils.MkRef(@afn['ref_to_parent_dir'])

# If there's a name get it.
len = @afn['name_length'] * 2
@name = buf[0, len].UnicodeToUtf8 if len > 0
len = @afn['name_length'] * 2
@name = NTFS::Utils.UnicodeToUtf8(buf[0, len]) if len > 0

# If name is nil use NT standard unnamed.
@name ||= UNNAMED.dup
Expand Down
3 changes: 1 addition & 2 deletions lib/virtfs/ntfs/attrib_header.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'binary_struct'
require 'util/miq-unicode'
require 'fs/ntfs/utils'
require 'fs/ntfs/attrib_type'

Expand Down Expand Up @@ -102,7 +101,7 @@ def initialize(buf)
offset += len

# If there's a name get it.
@name = buf[offset, (@namelen * 2)].UnicodeToUtf8 if @namelen != 0
@name = NTFS::Utils.UnicodeToUtf8(buf[offset, (@namelen * 2)]) if @namelen != 0
end

def get_value(buf, boot_sector)
Expand Down
1 change: 0 additions & 1 deletion lib/virtfs/ntfs/attrib_index_root.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'binary_struct'
require 'util/miq-unicode'
require 'fs/ntfs/index_node_header'
require 'fs/ntfs/directory_index_node'
require 'fs/ntfs/index_record_header'
Expand Down
4 changes: 2 additions & 2 deletions lib/virtfs/ntfs/attrib_volume_name.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'util/miq-unicode'
Copy link
Member

@Fryguy Fryguy Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but you might need a require 'fs/ntfs/utils' here like is done in the other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy Actually, where is this coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy It looks to me like this library assumed manageiq-smartstate was a dependency, but it's not marked as such, and that's a different utils.rb file anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh very interesting...I missed that detail

Copy link
Member

@Fryguy Fryguy Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The virtfs code was expected to be extracted from manageiq-smartstate. In fact, I'd expect you to run into duplicated code. Note that a lot of this code doesn't actually work yet, and was in progress, but has since been abandoned. It is not used at all by the application.

On that note, I think we should abandon this virtfs stuff for now (like completely abandon, archive the repos) @chessbyte

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fryguy I'm all in favor of archiving this if it's not actually being used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as these virt* repos have not been active for awhile and just cause noise (needless PRs and Issues) due to gem and cop conflicts, let's archive them for now. If someone wants to work on them in earnest, we can always un-archive them. /cc @roliveri

require 'fs/ntfs/utils'

module NTFS
#
Expand All @@ -15,7 +15,7 @@ class VolumeName

def initialize(buf)
buf = buf.read(buf.length) if buf.kind_of?(DataRun)
@name = buf.UnicodeToUtf8
@name = NTFS::Utils.UnicodeToUtf8(buf)
end

def to_s
Expand Down
4 changes: 4 additions & 0 deletions lib/virtfs/ntfs/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ def self.validate_signature(signature, expected)
raise "Invalid Signature <#{signature}>"
end
end

def self.UnicodeToUtf8(string)
string.dup.force_encoding('UTF-16LE').encode('UTF-8')
end
end
end