summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/util/windows/volume.rb6
-rw-r--r--lib/chef/win32/api/file.rb6
-rw-r--r--lib/chef/win32/file.rb7
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/chef/util/windows/volume.rb b/lib/chef/util/windows/volume.rb
index 15780d61a1..e28a5091ac 100644
--- a/lib/chef/util/windows/volume.rb
+++ b/lib/chef/util/windows/volume.rb
@@ -52,8 +52,10 @@ class Chef::Util::Windows::Volume < Chef::Util::Windows
end
def add(args)
- unless SetVolumeMountPoint(@name, args[:remote])
- raise ArgumentError, get_last_error
+ begin
+ Chef::ReservedNames::Win32::File.set_volume_mount_point(@name, args[:remote])
+ rescue Chef::Exceptions::Win32APIError => e
+ raise ArgumentError, e
end
end
end
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index 4ea07ad39b..c48e992882 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -456,6 +456,12 @@ BOOL WINAPI DeviceIoControl(
#);
safe_attach_function :DeleteVolumeMountPointW, [:LPCTSTR], :BOOL
+#BOOL WINAPI SetVolumeMountPoint(
+ #_In_ LPCTSTR lpszVolumeMountPoint,
+ #_In_ LPCTSTR lpszVolumeName
+#);
+ safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL
+
###############################################
# Helpers
###############################################
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index a577f04acc..f62f9333f5 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -186,6 +186,13 @@ class Chef
end
end
+ def self.set_volume_mount_point(mount_point, name)
+ unless SetVolumeMountPointW(wstring(mount_point), wstring(name))
+ Chef::ReservedNames::Win32::Error.raise!
+ end
+ end
+
+
# ::File compat
class << self
alias :stat :info