2007-12-07 11:28:16 -08:00
/*
2002-01-30 06:08:46 +00:00
Unix SMB / CIFS implementation .
2013-07-03 16:47:05 +02:00
Tar backup command extension
Copyright ( C ) Aurélien Aptel 2013
2007-12-07 11:28:16 -08:00
1996-05-04 07:50:46 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
1996-05-04 07:50:46 +00:00
( at your option ) any later version .
2007-12-07 11:28:16 -08:00
1996-05-04 07:50:46 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2007-12-07 11:28:16 -08:00
1996-05-04 07:50:46 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1996-05-04 07:50:46 +00:00
*/
# include "includes.h"
2011-02-25 23:20:06 +01:00
# include "system/filesys.h"
2004-10-07 04:01:18 +00:00
# include "client/client_proto.h"
2011-05-06 11:47:43 +02:00
# include "libsmb/libsmb.h"
1998-05-08 13:51:17 +00:00
2013-07-03 18:18:25 +02:00
/* XXX: used in client.c, we have to export it for now */
2013-07-03 16:47:05 +02:00
char tar_type = 0 ;
1998-05-08 13:51:17 +00:00
2013-07-03 18:18:25 +02:00
enum tar_type_t {
TAR_INCLUDE , /* I flag, default */
TAR_INCLUDE_FILE , /* F flag */
TAR_EXLUDE , /* X flag */
} ;
2003-08-01 01:03:05 +00:00
typedef struct {
2013-07-03 18:18:25 +02:00
/* include, include from file, exclude */
enum tar_type_t type ;
/* size in bytes of a block in the tar file */
int blocksize ;
/* flags */
struct {
bool hidden ; /* backup hidden file? */
bool system ; /* backup system file? */
bool incremental ; /* backup _only_ archived file? */
bool reset ; /* unset archive bit? */
bool dry ; /* don't write tar file? */
} mode ;
/* path to tar archive name */
char * tar_path ;
/* path to file list (F flag) */
char * list_path
2013-07-03 16:47:05 +02:00
} tar_ctx_t ;
1998-09-18 12:47:46 +00:00
2013-07-03 18:18:25 +02:00
static tar_ctx_t tar_ctx ;
static void tar_set_default ( tar_ctx_t * t )
{
memset ( t , 0 , sizeof ( * t ) ) ;
t - > type = TAR_INCLUDE ;
t - > blocksize = 20 ;
t - > mode . hidden = True ;
t - > mode . system = True ;
t - > mode . incremental = False ;
t - > mode . dry = False ;
}
1996-05-04 07:50:46 +00:00
/****************************************************************************
Blocksize command
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 01:03:05 +00:00
2001-10-09 19:12:18 +00:00
int cmd_block ( void )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
/* XXX: from client.c */
const extern char * cmd_ptr ;
char * buf ;
int size ;
TALLOC_CTX * ctx = talloc_tos ( ) ;
if ( ! next_token_talloc ( ctx , & cmd_ptr , & buf , NULL ) ) {
DEBUG ( 0 , ( " blocksize <n> \n " ) ) ;
return 1 ;
}
size = atoi ( buf ) ;
if ( size < 0 | | size > 65535 ) {
DEBUG ( 0 , ( " blocksize out of range " ) ) ;
return 1 ;
}
tar_ctx . blocksize = size ;
DEBUG ( 2 , ( " blocksize is now %d \n " , size ) ) ;
return 0 ;
1996-05-04 07:50:46 +00:00
}
/****************************************************************************
command to set incremental / reset mode
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 06:29:16 +00:00
2001-10-09 19:12:18 +00:00
int cmd_tarmode ( void )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
return 0 ;
1996-05-04 07:50:46 +00:00
}
/****************************************************************************
Feeble attrib command
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 01:03:05 +00:00
2001-10-09 19:12:18 +00:00
int cmd_setmode ( void )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
return 0 ;
1996-05-04 07:50:46 +00:00
}
2007-12-19 21:59:28 +01:00
1996-05-04 07:50:46 +00:00
/****************************************************************************
Principal command for creating / extracting
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 01:03:05 +00:00
2001-10-09 19:12:18 +00:00
int cmd_tar ( void )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
return 0 ;
1996-05-04 07:50:46 +00:00
}
/****************************************************************************
Command line ( option ) version
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 01:03:05 +00:00
1998-11-09 03:45:49 +00:00
int process_tar ( void )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
return 0 ;
1998-06-17 01:52:57 +00:00
}
1996-05-04 07:50:46 +00:00
/****************************************************************************
Parse tar arguments . Sets tar_type , tar_excl , etc .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-08-01 00:41:57 +00:00
2003-08-12 21:30:28 +00:00
int tar_parseargs ( int argc , char * argv [ ] , const char * Optarg , int Optind )
1996-05-04 07:50:46 +00:00
{
2013-07-03 18:18:25 +02:00
return 0 ;
1996-05-04 07:50:46 +00:00
}