tools/hv: Fix /var subdirectory
authorTomas Hozza <thozza@redhat.com>
Tue, 27 Nov 2012 07:56:33 +0000 (08:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 18:41:46 +0000 (10:41 -0800)
Initial patch by Ben Hutchings <ben@decadent.org.uk>

We will install this in /usr, so it must use /var/lib for its state.
Only programs installed under /opt should use /var/opt.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/hv/hv_kvp_daemon.c

index d25a469..5c052db 100644 (file)
@@ -97,7 +97,7 @@ static struct utsname uts_buf;
  * The location of the interface configuration file.
  */
 
-#define KVP_CONFIG_LOC "/var/opt/"
+#define KVP_CONFIG_LOC "/var/lib/hyperv"
 
 #define MAX_FILE_NAME 100
 #define ENTRIES_PER_BLOCK 50
@@ -234,9 +234,9 @@ static int kvp_file_init(void)
        int i;
        int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK;
 
-       if (access("/var/opt/hyperv", F_OK)) {
-               if (mkdir("/var/opt/hyperv", S_IRUSR | S_IWUSR | S_IROTH)) {
-                       syslog(LOG_ERR, " Failed to create /var/opt/hyperv");
+       if (access(KVP_CONFIG_LOC, F_OK)) {
+               if (mkdir(KVP_CONFIG_LOC, S_IRUSR | S_IWUSR | S_IROTH)) {
+                       syslog(LOG_ERR, " Failed to create %s", KVP_CONFIG_LOC);
                        exit(EXIT_FAILURE);
                }
        }
@@ -245,7 +245,7 @@ static int kvp_file_init(void)
                fname = kvp_file_info[i].fname;
                records_read = 0;
                num_blocks = 1;
-               sprintf(fname, "/var/opt/hyperv/.kvp_pool_%d", i);
+               sprintf(fname, "%s/.kvp_pool_%d", KVP_CONFIG_LOC, i);
                fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH);
 
                if (fd == -1)
@@ -1271,7 +1271,7 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
         */
 
        snprintf(if_file, sizeof(if_file), "%s%s%s", KVP_CONFIG_LOC,
-               "hyperv/ifcfg-", if_name);
+               "/ifcfg-", if_name);
 
        file = fopen(if_file, "w");