[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 5 of 8] blktap3/vhd: Introduce relative-path.c/relative-path.h



This patch copies from blktap2 functionality that returns a relative path from
one path to another, with changes coming from blktap2.5.

Signed-off-by: Thanos Makatos <thanos.makatos@xxxxxxxxxx>

diff --git a/tools/blktap2/vhd/lib/relative-path.c 
b/tools/blktap3/vhd/lib/relative-path.c
copy from tools/blktap2/vhd/lib/relative-path.c
copy to tools/blktap3/vhd/lib/relative-path.c
--- a/tools/blktap2/vhd/lib/relative-path.c
+++ b/tools/blktap3/vhd/lib/relative-path.c
@@ -1,4 +1,5 @@
 /* Copyright (c) 2008, XenSource Inc.
+ * Copyright (c) 2010, Citrix Systems, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,6 +29,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h>
 
 #include "relative-path.h"
 
@@ -212,7 +214,8 @@ char *
 relative_path_to(char *from, char *to, int *err)
 {
        int from_nodes, common;
-       char *to_absolute, *from_absolute;
+       char *to_absolute, __to_absolute[PATH_MAX];
+       char *from_absolute, __from_absolute[PATH_MAX];
        char *up, *common_target_path, *relative_path;
 
        *err          = 0;
@@ -229,14 +232,14 @@ relative_path_to(char *from, char *to, i
                return NULL;
        }
 
-       to_absolute = realpath(to, NULL);
+       to_absolute = realpath(to, __to_absolute);
        if (!to_absolute) {
                EPRINTF("failed to get absolute path of %s\n", to);
                *err = -errno;
                goto out;
        }
 
-       from_absolute = realpath(from, NULL);
+       from_absolute = realpath(from, __from_absolute);
        if (!from_absolute) {
                EPRINTF("failed to get absolute path of %s\n", from);
                *err = -errno;
@@ -292,8 +295,6 @@ relative_path_to(char *from, char *to, i
 
 out:
        sfree(up);
-       sfree(to_absolute);
-       sfree(from_absolute);
 
        return relative_path;
 }
diff --git a/tools/blktap2/include/relative-path.h 
b/tools/blktap3/vhd/lib/relative-path.h
copy from tools/blktap2/include/relative-path.h
copy to tools/blktap3/vhd/lib/relative-path.h
--- a/tools/blktap2/include/relative-path.h
+++ b/tools/blktap3/vhd/lib/relative-path.h
@@ -1,4 +1,5 @@
 /* Copyright (c) 2008, XenSource Inc.
+ * Copyright (c) 2010, Citrix Systems, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.