Module Name: othersrc
Committed By: stacktic
Date: Tue Apr 14 20:12:51 UTC 2009
Modified Files:
othersrc/bin/fsu_ecp: fsu_ecp.c
Log Message:
Fixed symlink following
Set default to no follow symlink
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 othersrc/bin/fsu_ecp/fsu_ecp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/bin/fsu_ecp/fsu_ecp.c
diff -u othersrc/bin/fsu_ecp/fsu_ecp.c:1.6 othersrc/bin/fsu_ecp/fsu_ecp.c:1.7
--- othersrc/bin/fsu_ecp/fsu_ecp.c:1.6 Tue Apr 14 18:36:53 2009
+++ othersrc/bin/fsu_ecp/fsu_ecp.c Tue Apr 14 20:12:51 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fsu_ecp.c,v 1.6 2009/04/14 18:36:53 stacktic Exp $ */
+/* $NetBSD: fsu_ecp.c,v 1.7 2009/04/14 20:12:51 stacktic Exp $ */
/*
* Copyright (c) 2008 Arnaud Ysmal. All Rights Reserved.
@@ -44,8 +44,8 @@
#include "fsu_flist.h"
-#define FSU_ECP_COPY_LINK (0x01)
-#define FSU_ECP_RECURSIVE (FSU_ECP_COPY_LINK<<1)
+#define FSU_ECP_NO_COPY_LINK (0x01)
+#define FSU_ECP_RECURSIVE (FSU_ECP_NO_COPY_LINK<<1)
#define FSU_ECP_VERBOSE (FSU_ECP_RECURSIVE<<1)
#define FSU_ECP_GET (FSU_ECP_VERBOSE<<1)
#define FSU_ECP_PUT (FSU_ECP_GET<<1)
@@ -117,14 +117,14 @@
strcmp(progname, "fsu_put") == 0)
flags |= FSU_ECP_PUT;
- while ((rv = getopt(*argc, *argv, "gPpRv")) != -1) {
+ while ((rv = getopt(*argc, *argv, "gLpRv")) != -1) {
switch (rv) {
case 'g':
flags |= FSU_ECP_GET;
flags &= ~FSU_ECP_PUT;
break;
- case 'P':
- flags |= FSU_ECP_COPY_LINK;
+ case 'L':
+ flags |= FSU_ECP_NO_COPY_LINK;
break;
case 'p':
flags |= FSU_ECP_PUT;
@@ -240,6 +240,7 @@
{
FSU_FENT *root, *cur, *cur2, *nextelt;
fsu_flist *flist;
+ struct stat sb;
size_t len;
int flist_options, res, rv, off, hl_supported, curlink;
struct hardlink_s *new;
@@ -250,10 +251,10 @@
curlink = res = 0;
hl_supported = 1;
- if (flags & FSU_ECP_COPY_LINK)
- flist_options = FSU_FLIST_STATLINK;
- else
+ if (flags & FSU_ECP_NO_COPY_LINK)
flist_options = 0;
+ else
+ flist_options = FSU_FLIST_STATLINK;
if (flags & FSU_ECP_RECURSIVE)
flist_options |= FSU_FLIST_RECURSIVE;
@@ -290,7 +291,17 @@
for (curlink = 0, cur2 = cur; LIST_NEXT(cur2, next) != NULL;) {
nextelt = LIST_NEXT(cur2, next);
- if (nextelt->sb.st_nlink == 1) {
+ if (S_ISDIR(nextelt->sb.st_mode) ||
+ nextelt->sb.st_nlink == 1) {
+ cur2 = nextelt;
+ continue;
+ }
+ if (flags & FSU_ECP_GET)
+ ukfs_lstat(fs, nextelt->path, &sb);
+ else if (flags & FSU_ECP_PUT)
+ lstat(nextelt->path, &sb);
+
+ if (S_ISLNK(sb.st_mode)) {
cur2 = nextelt;
continue;
}
@@ -452,7 +463,7 @@
rv = copy_fifo(fs, from, to, flags);
break;
case S_IFLNK:
- if (flags & FSU_ECP_COPY_LINK)
+ if (!(flags & FSU_ECP_NO_COPY_LINK))
rv = copy_link(fs, from, to, flags);
else
rv = copy_file(fs, from, to, flags);
@@ -475,7 +486,7 @@
if (flags & FSU_ECP_GET)
return rv;
- if (flags & FSU_ECP_COPY_LINK)
+ if (!(flags & FSU_ECP_NO_COPY_LINK))
rv = ukfs_lchown(fs, to, frstat->st_uid, frstat->st_gid);
else
rv = ukfs_chown(fs, to, frstat->st_uid, frstat->st_gid);