summaryrefslogtreecommitdiff
path: root/source/client
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-09-18 06:52:49 +0000
committerAndrew Tridgell <tridge@samba.org>1997-09-18 06:52:49 +0000
commitd5daf85162e844c9e953cc4dfbb3f1d800747130 (patch)
tree9bdc23b770ee0c102b81a95a26a0a041a848a904 /source/client
parent0b859fdfac07322f021dbb74791914e22f6b9884 (diff)
downloadsamba-d5daf85162e844c9e953cc4dfbb3f1d800747130.tar.gz
John asked the other day about using the tar feature in smbclient to
handle file paths longer than 100 characters (the limit of the normal tar format). This patch adds support for producing GNU tar files (which have no real limit on the path length) in smbclient. Note that I have only added support for producing GNU tar files, I haven't added support for accepting them when restoring. I thought I'd leave that up to John :-)
Diffstat (limited to 'source/client')
-rw-r--r--source/client/clitar.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/client/clitar.c b/source/client/clitar.c
index a30f6c2960f..344263967fd 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -90,7 +90,7 @@ static void unfixtarname();
Write a tar header to buffer
****************************************************************************/
static void writetarheader(int f, char *aname, int size, time_t mtime,
- char *amode)
+ char *amode)
{
union hblock hb;
int i, chk, l;
@@ -99,10 +99,21 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
memset(hb.dummy, 0, sizeof(hb.dummy));
l=strlen(aname);
- if (l >= NAMSIZ)
- {
- DEBUG(0, ("tar file %s name length exceeds NAMSIZ\n", aname));
- }
+ if (l >= NAMSIZ) {
+ /* write a GNU tar style long header */
+ char *b;
+ b = (char *)malloc(l+TBLOCK+100);
+ if (!b) {
+ DEBUG(0,("out of memory\n"));
+ exit(1);
+ }
+ writetarheader(f, "/./@LongLink", l+1, 0, " 0 \0");
+ memset(b, 0, l+TBLOCK+100);
+ fixtarname(b, aname, l+1);
+ i = strlen(b)+1;
+ dotarbuf(f, b, TBLOCK*((i+(TBLOCK-1)/TBLOCK)));
+ free(b);
+ }
/* use l + 1 to do the null too */
fixtarname(hb.dbuf.name, aname, (l >= NAMSIZ) ? NAMSIZ : l + 1);
@@ -119,8 +130,13 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
oct_it((long) size, 13, hb.dbuf.size);
oct_it((long) mtime, 13, hb.dbuf.mtime);
memcpy(hb.dbuf.chksum, " ", sizeof(hb.dbuf.chksum));
- hb.dbuf.linkflag='0';
memset(hb.dbuf.linkname, 0, NAMSIZ);
+ if (strcmp("/./@LongLink", aname) == 0) {
+ /* we're doing a GNU tar long filename */
+ hb.dbuf.linkflag='L';
+ } else {
+ hb.dbuf.linkflag='0';
+ }
for (chk=0, i=sizeof(hb.dummy), jp=hb.dummy; --i>=0;) chk+=(0xFF & *jp++);