From 391fab8f85d0ebd6ed14e521de19f420dae41c0f Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sat, 16 Jan 2010 21:01:53 +0000
Subject: [PATCH] Windows: Print warning if admin rights are missing.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3038 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG    | 2 ++
 smartmontools/os_win32.cpp | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index fc32ae97d..25da9563e 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,8 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Windows: Print warning if admin rights are missing.
+
   [CF] Replace some 'EXIT(status)' calls by 'return status'.
        Remove unnecessary casts from 'nonempty()' calls.
 
diff --git a/smartmontools/os_win32.cpp b/smartmontools/os_win32.cpp
index 23c11d869..5cd7f96f5 100644
--- a/smartmontools/os_win32.cpp
+++ b/smartmontools/os_win32.cpp
@@ -2368,6 +2368,15 @@ bool win_ata_device::open(int phydrive, int logdrive, const char * options, int
   }
   set_fh(h);
 
+  // Warn once if admin rights are missing
+  if (!m_admin) {
+    static bool noadmin_warning = false;
+    if (!noadmin_warning) {
+      pout("Warning: Limited functionality due to missing admin rights\n");
+      noadmin_warning = true;
+    }
+  }
+
   if (con->reportataioctl > 1)
     pout("%s: successfully opened%s\n", devpath, (!m_admin ? " (without admin rights)" :""));
 
-- 
GitLab