summaryrefslogtreecommitdiff
path: root/install-from-cwd.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:39 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:39 -0800
commit7fd526bcfb5cc2d43230f5845b91fa92c819a66c (patch)
treea514e04e4fe9f1908144c6603149cecd986f2d7e /install-from-cwd.c
parent46eb90bcd7f3a3e9e7a5e5b2059bc1d6a3a87dca (diff)
100.14.19100.14.19
Diffstat (limited to 'install-from-cwd.c')
-rw-r--r--install-from-cwd.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/install-from-cwd.c b/install-from-cwd.c
index 17b8ac2..f32efcc 100644
--- a/install-from-cwd.c
+++ b/install-from-cwd.c
@@ -484,7 +484,7 @@ static Package *parse_manifest (Options *op)
char *buf, *c, *flag , *tmpstr;
int done, n, line;
int fd, ret, len = 0;
- struct stat stat_buf;
+ struct stat stat_buf, entry_stat_buf;
Package *p;
char *manifest = MAP_FAILED, *ptr;
@@ -760,7 +760,21 @@ static Package *parse_manifest (Options *op)
if (p->entries[n].name) p->entries[n].name++;
if (!p->entries[n].name) p->entries[n].name = p->entries[n].file;
-
+
+ /*
+ * store the inode and device information, so that we can
+ * later recognize it, to avoid accidentally moving it as
+ * part of the 'find_conflicting_files' path
+ */
+
+ if (stat(p->entries[n].file, &entry_stat_buf) != -1) {
+ p->entries[n].inode = entry_stat_buf.st_ino;
+ p->entries[n].device = entry_stat_buf.st_dev;
+ } else {
+ p->entries[n].inode = 0;
+ p->entries[n].device = 0;
+ }
+
/* free the line */
free(buf);
@@ -796,6 +810,50 @@ static Package *parse_manifest (Options *op)
/*
+ * add_package_entry() - add a PackageEntry to the package's entries
+ * array.
+ */
+
+void add_package_entry(Package *p,
+ char *file,
+ char *path,
+ char *name,
+ char *target,
+ char *dst,
+ unsigned int flags,
+ mode_t mode)
+{
+ int n;
+ struct stat stat_buf;
+
+ n = p->num_entries;
+
+ p->entries =
+ (PackageEntry *) nvrealloc(p->entries, (n + 1) * sizeof(PackageEntry));
+
+ p->entries[n].file = file;
+ p->entries[n].path = path;
+ p->entries[n].name = name;
+ p->entries[n].target = target;
+ p->entries[n].dst = dst;
+ p->entries[n].flags = flags;
+ p->entries[n].mode = mode;
+
+ if (stat(p->entries[n].file, &stat_buf) != -1) {
+ p->entries[n].inode = stat_buf.st_ino;
+ p->entries[n].device = stat_buf.st_dev;
+ } else {
+ p->entries[n].inode = 0;
+ p->entries[n].device = 0;
+ }
+
+ p->num_entries++;
+
+} /* add_package_entry() */
+
+
+
+/*
* free_package() - free the Package data structure
*/