diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-09-18 06:52:49 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-09-18 06:52:49 +0000 |
commit | 102fb715376349d47491fc56f823188b036bc2f3 (patch) | |
tree | aa4a906dfa7532019c15f88b37ca4e3ff5b4c113 /source3/client | |
parent | 1c7df3203c334af38c6d4311ea673f9a9b7da4b7 (diff) | |
download | samba-102fb715376349d47491fc56f823188b036bc2f3.tar.gz samba-102fb715376349d47491fc56f823188b036bc2f3.tar.bz2 samba-102fb715376349d47491fc56f823188b036bc2f3.zip |
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 :-)
(This used to be commit d5daf85162e844c9e953cc4dfbb3f1d800747130)
Diffstat (limited to 'source3/client')
-rw-r--r-- | source3/client/clitar.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c index a30f6c2960..344263967f 100644 --- a/source3/client/clitar.c +++ b/source3/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++); |