/* Define to 1 if you have the `readdir_r' function. */
#undef HAVE_READDIR_R
+/* Define to 1 if you have the <regex.h> header file. */
+#undef HAVE_REGEX_H
+
/* Define to 1 if you have the <resolv.h> header file. */
#undef HAVE_RESOLV_H
# Minimal stuff for readline Makefile configuration
MAKE_SHELL=/bin/sh
AC_SUBST(MAKE_SHELL)
-
AC_HEADER_STAT
AC_HEADER_DIRENT
-
AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat lchown)
AC_CHECK_FUNCS(nanosleep nl_langinfo)
-
AC_CHECK_HEADERS(varargs.h)
# End of readline/conio stuff
resolv.h \
mtio.h \
sys/mtio.h \
+ regex.h \
)
AC_HEADER_STDC
AC_HEADER_MAJOR
dnl# --------------------------------------------------------------------------
-dnl# CHECKING FOR LIBRARY FUNCTIONS
+dnl# CHECKING FOR REQUIRED LIBRARY FUNCTIONS
dnl# --------------------------------------------------------------------------
AC_CHECK_FUNCS( \
fork \
src/win32/console/bconsole.conf \
src/win32/wx-console/wx-console.conf \
$PFILES ],
- [(echo "Doing make of dependencies"; make depend;) ]
+ [(echo "Doing make of dependencies"; ${MAKE:-make} depend;) ]
)
cd scripts
# Minimal stuff for readline Makefile configuration
MAKE_SHELL=/bin/sh
-
echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5
echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6
if test "${ac_cv_header_stat_broken+set}" = set; then
-
for ac_func in strcasecmp select setenv putenv tcgetattr setlocale lstat lchown
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
done
-
for ac_header in varargs.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+
for ac_header in \
resolv.h \
mtio.h \
sys/mtio.h \
+ regex.h \
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ echo "$as_me:$LINENO: executing $ac_dest commands" >&5
echo "$as_me: executing $ac_dest commands" >&6;}
case $ac_dest in
- default ) (echo "Doing make of dependencies"; make depend;)
+ default ) (echo "Doing make of dependencies"; ${MAKE:-make} depend;)
;;
esac
done
Kern's ToDo List
- 26 June 2004
+ 01 July 2004
1.35 Items to do:
- Make btape release the drive during the "test" append.
you lost/broke the Catalog -- do the same for "I know my
file is there how do I get it back?".
- When restore started from console, report jobid.
-- Win32 inc problem when new directory added.
+- Look at Win32 inc problem when new directory added files not saved???
- Make FD run on Win95 if possible:
The error I when I installed 1.34.2 clients:
The BACULA-FD file is
user to the doc.
- Make Verify jobs require exclusive use of Volume as Restore
jobs do.
-- Add regular expressions to FileSets.
- Perhaps add read/write programs and/or plugins to FileSets.
- Look at adding Client run command that will use the
port opened by the client.
-- Test new I/O error despooling code.
Documentation to do: (any release a little bit at a time)
- Document query file format.
- Add InChanger to "list media"
- Implement second cut of SIGHUP in Dir
(Implement resources on a single pointer)
+- Add regular expressions to FileSets.
+- Test new I/O error despooling code.
+
#define nl_langinfo(x) ("ANSI_X3.4-1968")
#endif
+/* Fake entry points if regex does not exist */
+#ifndef HAVE_REGEX_H
+#define regcomp(x, y, z) 1
+#define regfree(x)
+#define regerror(rc, preg, prbuf, len) bstrncpy(prbuf, "REGEX not available on this system.", len)
+#define regex_t int
+#define regmatch_t char
+#endif
+
#endif /* _BACONFIG_H */
char dummy;
};
-#define IS_NUM(x) ((x) == 1)
-#define IS_NOT_NULL(x) ((x) == 1)
+#define IS_NUM(x) ((x) == 1)
+#define IS_NOT_NULL(x) ((x) == 1)
typedef struct s_sql_field {
- char *name; /* name of column */
- int length; /* length */
- int max_length; /* max length */
- uint32_t type; /* type */
- uint32_t flags; /* flags */
+ char *name; /* name of column */
+ int length; /* length */
+ int max_length; /* max length */
+ uint32_t type; /* type */
+ uint32_t flags; /* flags */
} SQL_FIELD;
/*
* This is the "real" definition that should only be
* used inside sql.c and associated database interface
* subroutines.
- * S Q L I T E
+ * S Q L I T E
*/
typedef struct s_db {
- BQUEUE bq; /* queue control */
- brwlock_t lock; /* transaction lock */
+ BQUEUE bq; /* queue control */
+ brwlock_t lock; /* transaction lock */
struct sqlite *db;
char **result;
int status;
- int nrow; /* nrow returned from sqlite */
- int ncolumn; /* ncolum returned from sqlite */
- int num_rows; /* used by code */
- int row; /* seek row */
- int have_insert_id; /* do not have insert id */
- int fields_defined; /* set when fields defined */
- int field; /* seek field */
- SQL_FIELD **fields; /* defined fields */
+ int nrow; /* nrow returned from sqlite */
+ int ncolumn; /* ncolum returned from sqlite */
+ int num_rows; /* used by code */
+ int row; /* seek row */
+ int field; /* seek field */
+ SQL_FIELD **fields; /* defined fields */
int ref_count;
char *db_name;
char *db_user;
- char *db_address; /* host name address */
- char *db_socket; /* socket for local access */
+ char *db_address; /* host name address */
+ char *db_socket; /* socket for local access */
char *db_password;
- int db_port; /* port for host name address */
- bool connected; /* connection made to db */
- char *sqlite_errmsg; /* error message returned by sqlite */
- POOLMEM *errmsg; /* nicely edited error message */
- POOLMEM *cmd; /* SQL command string */
- POOLMEM *cached_path; /* cached path name */
- int cached_path_len; /* length of cached path */
- uint32_t cached_path_id; /* cached path id */
- int transaction; /* transaction started */
- int changes; /* changes during transaction */
- POOLMEM *fname; /* Filename only */
- POOLMEM *path; /* Path only */
- POOLMEM *esc_name; /* Escaped file/path name */
- int fnl; /* file name length */
- int pnl; /* path name length */
+ int db_port; /* port for host name address */
+ bool connected; /* connection made to db */
+ bool have_insert_id; /* do not have insert id */
+ bool fields_defined; /* set when fields defined */
+ char *sqlite_errmsg; /* error message returned by sqlite */
+ POOLMEM *errmsg; /* nicely edited error message */
+ POOLMEM *cmd; /* SQL command string */
+ POOLMEM *cached_path; /* cached path name */
+ int cached_path_len; /* length of cached path */
+ uint32_t cached_path_id; /* cached path id */
+ int transaction; /* transaction started */
+ int changes; /* changes during transaction */
+ POOLMEM *fname; /* Filename only */
+ POOLMEM *path; /* Path only */
+ POOLMEM *esc_name; /* Escaped file/path name */
+ int fnl; /* file name length */
+ int pnl; /* path name length */
} B_DB;
/*
* "Generic" names for easier conversion
*
- * S Q L I T E
+ * S Q L I T E
*/
#define sql_store_result(x) (x)->result
#define sql_free_result(x) my_sqlite_free_table(x)
#define sql_fetch_row(x) my_sqlite_fetch_row(x)
#define sql_query(x, y) my_sqlite_query((x), (y))
-#define sql_close(x) sqlite_close((x)->db)
+#define sql_close(x) sqlite_close((x)->db)
#define sql_strerror(x) (x)->sqlite_errmsg?(x)->sqlite_errmsg:"unknown"
#define sql_num_rows(x) (x)->nrow
#define sql_data_seek(x, i) (x)->row = (i)
#define sql_field_seek(x, y) my_sqlite_field_seek((x), (y))
#define sql_fetch_field(x) my_sqlite_fetch_field(x)
#define sql_num_fields(x) ((x)->ncolumn)
-#define SQL_ROW char**
+#define SQL_ROW char**
/* In cats/sqlite.c */
-void my_sqlite_free_table(B_DB *mdb);
+void my_sqlite_free_table(B_DB *mdb);
SQL_ROW my_sqlite_fetch_row(B_DB *mdb);
-int my_sqlite_query(B_DB *mdb, char *cmd);
-void my_sqlite_field_seek(B_DB *mdb, int field);
+int my_sqlite_query(B_DB *mdb, char *cmd);
+void my_sqlite_field_seek(B_DB *mdb, int field);
SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
* used inside sql.c and associated database interface
* subroutines.
*
- * M Y S Q L
+ * M Y S Q L
*/
typedef struct s_db {
- BQUEUE bq; /* queue control */
- brwlock_t lock; /* transaction lock */
+ BQUEUE bq; /* queue control */
+ brwlock_t lock; /* transaction lock */
MYSQL mysql;
MYSQL *db;
MYSQL_RES *result;
char *db_name;
char *db_user;
char *db_password;
- char *db_address; /* host address */
- char *db_socket; /* socket for local access */
- int db_port; /* port of host address */
- int have_insert_id; /* do have insert_id() */
+ char *db_address; /* host address */
+ char *db_socket; /* socket for local access */
+ int db_port; /* port of host address */
+ int have_insert_id; /* do have insert_id() */
bool connected;
- POOLMEM *errmsg; /* nicely edited error message */
- POOLMEM *cmd; /* SQL command string */
+ POOLMEM *errmsg; /* nicely edited error message */
+ POOLMEM *cmd; /* SQL command string */
POOLMEM *cached_path;
- int cached_path_len; /* length of cached path */
+ int cached_path_len; /* length of cached path */
uint32_t cached_path_id;
- int changes; /* changes made to db */
- POOLMEM *fname; /* Filename only */
- POOLMEM *path; /* Path only */
- POOLMEM *esc_name; /* Escaped file/path name */
- int fnl; /* file name length */
- int pnl; /* path name length */
+ int changes; /* changes made to db */
+ POOLMEM *fname; /* Filename only */
+ POOLMEM *path; /* Path only */
+ POOLMEM *esc_name; /* Escaped file/path name */
+ int fnl; /* file name length */
+ int pnl; /* path name length */
} B_DB;
#define DB_STATUS int
#define sql_free_result(x) mysql_free_result((x)->result)
#define sql_fetch_row(x) mysql_fetch_row((x)->result)
#define sql_query(x, y) mysql_query((x)->db, (y))
-#define sql_close(x) mysql_close((x)->db)
+#define sql_close(x) mysql_close((x)->db)
#define sql_strerror(x) mysql_error((x)->db)
#define sql_num_rows(x) mysql_num_rows((x)->result)
#define sql_data_seek(x, i) mysql_data_seek((x)->result, (i))
#define sql_field_seek(x, y) mysql_field_seek((x)->result, (y))
#define sql_fetch_field(x) mysql_fetch_field((x)->result)
#define sql_num_fields(x) (int)mysql_num_fields((x)->result)
-#define SQL_ROW MYSQL_ROW
-#define SQL_FIELD MYSQL_FIELD
+#define SQL_ROW MYSQL_ROW
+#define SQL_FIELD MYSQL_FIELD
#else
#include <libpq-fe.h>
/* TEMP: the following is taken from select OID, typname from pg_type; */
-#define IS_NUM(x) ((x) == 20 || (x) == 21 || (x) == 23 || (x) == 700 || (x) == 701)
-#define IS_NOT_NULL(x) ((x) == 1)
+#define IS_NUM(x) ((x) == 20 || (x) == 21 || (x) == 23 || (x) == 700 || (x) == 701)
+#define IS_NOT_NULL(x) ((x) == 1)
typedef char **POSTGRESQL_ROW;
typedef struct pg_field {
- char *name;
- int max_length;
- unsigned int type;
- unsigned int flags; // 1 == not null
+ char *name;
+ int max_length;
+ unsigned int type;
+ unsigned int flags; // 1 == not null
} POSTGRESQL_FIELD;
* used inside sql.c and associated database interface
* subroutines.
*
- * P O S T G R E S Q L
+ * P O S T G R E S Q L
*/
typedef struct s_db {
- BQUEUE bq; /* queue control */
- brwlock_t lock; /* transaction lock */
+ BQUEUE bq; /* queue control */
+ brwlock_t lock; /* transaction lock */
PGconn *db;
PGresult *result;
int status;
POSTGRESQL_FIELD *fields;
int num_rows;
int num_fields;
- int row_number; /* what row number did we get via my_postgresql_data_seek? */
- int field_number; /* what field number did we get via my_postgresql_field_seek? */
+ int row_number; /* what row number did we get via my_postgresql_data_seek? */
+ int field_number; /* what field number did we get via my_postgresql_field_seek? */
int ref_count;
char *db_name;
char *db_user;
char *db_password;
- char *db_address; /* host address */
- char *db_socket; /* socket for local access */
- int db_port; /* port of host address */
- int have_insert_id; /* do have insert_id() */
+ char *db_address; /* host address */
+ char *db_socket; /* socket for local access */
+ int db_port; /* port of host address */
+ int have_insert_id; /* do have insert_id() */
bool connected;
- POOLMEM *errmsg; /* nicely edited error message */
- POOLMEM *cmd; /* SQL command string */
+ POOLMEM *errmsg; /* nicely edited error message */
+ POOLMEM *cmd; /* SQL command string */
POOLMEM *cached_path;
- int cached_path_len; /* length of cached path */
+ int cached_path_len; /* length of cached path */
uint32_t cached_path_id;
- int transaction; /* transaction started */
- int changes; /* changes made to db */
- POOLMEM *fname; /* Filename only */
- POOLMEM *path; /* Path only */
- POOLMEM *esc_name; /* Escaped file/path name */
- int fnl; /* file name length */
- int pnl; /* path name length */
+ int transaction; /* transaction started */
+ int changes; /* changes made to db */
+ POOLMEM *fname; /* Filename only */
+ POOLMEM *path; /* Path only */
+ POOLMEM *esc_name; /* Escaped file/path name */
+ int fnl; /* file name length */
+ int pnl; /* path name length */
} B_DB;
-void my_postgresql_free_result(B_DB *mdb);
-POSTGRESQL_ROW my_postgresql_fetch_row (B_DB *mdb);
-int my_postgresql_query (B_DB *mdb, char *query);
-void my_postgresql_data_seek (B_DB *mdb, int row);
-int my_postgresql_currval (B_DB *mdb, char *table_name);
-void my_postgresql_field_seek (B_DB *mdb, int row);
+void my_postgresql_free_result(B_DB *mdb);
+POSTGRESQL_ROW my_postgresql_fetch_row (B_DB *mdb);
+int my_postgresql_query (B_DB *mdb, char *query);
+void my_postgresql_data_seek (B_DB *mdb, int row);
+int my_postgresql_currval (B_DB *mdb, char *table_name);
+void my_postgresql_field_seek (B_DB *mdb, int row);
POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
#define sql_free_result(x) my_postgresql_free_result(x)
#define sql_fetch_row(x) my_postgresql_fetch_row(x)
#define sql_query(x, y) my_postgresql_query((x), (y))
-#define sql_close(x) PQfinish((x)->db)
+#define sql_close(x) PQfinish((x)->db)
#define sql_strerror(x) PQresultErrorMessage((x)->result)
#define sql_num_rows(x) ((unsigned) PQntuples((x)->result))
#define sql_data_seek(x, i) my_postgresql_data_seek((x), (i))
#define sql_field_seek(x, y) my_postgresql_field_seek((x), (y))
#define sql_fetch_field(x) my_postgresql_fetch_field(x)
#define sql_num_fields(x) ((x)->num_fields)
-#define SQL_ROW POSTGRESQL_ROW
-#define SQL_FIELD POSTGRESQL_FIELD
+#define SQL_ROW POSTGRESQL_ROW
+#define SQL_FIELD POSTGRESQL_FIELD
#else /* USE BACULA DB routines */
/* Change this each time there is some incompatible
* file format change!!!!
*/
-#define BDB_VERSION 12 /* file version number */
+#define BDB_VERSION 12 /* file version number */
struct s_control {
- int bdb_version; /* Version number */
- uint32_t JobId; /* next Job Id */
- uint32_t PoolId; /* next Pool Id */
- uint32_t MediaId; /* next Media Id */
- uint32_t JobMediaId; /* next JobMedia Id */
- uint32_t ClientId; /* next Client Id */
- uint32_t FileSetId; /* nest FileSet Id */
- time_t time; /* time file written */
+ int bdb_version; /* Version number */
+ uint32_t JobId; /* next Job Id */
+ uint32_t PoolId; /* next Pool Id */
+ uint32_t MediaId; /* next Media Id */
+ uint32_t JobMediaId; /* next JobMedia Id */
+ uint32_t ClientId; /* next Client Id */
+ uint32_t FileSetId; /* nest FileSet Id */
+ time_t time; /* time file written */
};
* Bacula internal DB
*/
typedef struct s_db {
- BQUEUE bq; /* queue control */
-/* pthread_mutex_t mutex; */ /* single thread lock */
- brwlock_t lock; /* transaction lock */
- int ref_count; /* number of times opened */
- struct s_control control; /* control file structure */
- int cfd; /* control file device */
- FILE *jobfd; /* Jobs records file descriptor */
- FILE *poolfd; /* Pool records fd */
- FILE *mediafd; /* Media records fd */
- FILE *jobmediafd; /* JobMedia records fd */
- FILE *clientfd; /* Client records fd */
- FILE *filesetfd; /* FileSet records fd */
- char *db_name; /* name of database */
- POOLMEM *errmsg; /* nicely edited error message */
- POOLMEM *cmd; /* Command string */
+ BQUEUE bq; /* queue control */
+/* pthread_mutex_t mutex; */ /* single thread lock */
+ brwlock_t lock; /* transaction lock */
+ int ref_count; /* number of times opened */
+ struct s_control control; /* control file structure */
+ int cfd; /* control file device */
+ FILE *jobfd; /* Jobs records file descriptor */
+ FILE *poolfd; /* Pool records fd */
+ FILE *mediafd; /* Media records fd */
+ FILE *jobmediafd; /* JobMedia records fd */
+ FILE *clientfd; /* Client records fd */
+ FILE *filesetfd; /* FileSet records fd */
+ char *db_name; /* name of database */
+ POOLMEM *errmsg; /* nicely edited error message */
+ POOLMEM *cmd; /* Command string */
POOLMEM *cached_path;
- int cached_path_len; /* length of cached path */
+ int cached_path_len; /* length of cached path */
uint32_t cached_path_id;
} B_DB;
#define DELETE_DB(jcr, db, cmd) DeleteDB(__FILE__, __LINE__, jcr, db, cmd)
-#else /* not __SQL_C */
+#else /* not __SQL_C */
/* This is a "dummy" definition for use outside of sql.c
*/
-typedef struct s_db {
- int dummy; /* for SunOS compiler */
+typedef struct s_db {
+ int dummy; /* for SunOS compiler */
} B_DB;
#endif /* __SQL_C */
* but at the current time, this breaks MySQL.
*/
typedef uint32_t FileId_t;
-typedef uint32_t DBId_t; /* general DB id type */
+typedef uint32_t DBId_t; /* general DB id type */
typedef uint32_t JobId_t;
#define faddr_t long
/* Job record */
struct JOB_DBR {
JobId_t JobId;
- char Job[MAX_NAME_LENGTH]; /* Job unique name */
- char Name[MAX_NAME_LENGTH]; /* Job base name */
- int JobType; /* actually char(1) */
- int JobLevel; /* actually char(1) */
- int JobStatus; /* actually char(1) */
- DBId_t ClientId; /* Id of client */
- DBId_t PoolId; /* Id of pool */
- DBId_t FileSetId; /* Id of FileSet */
- time_t SchedTime; /* Time job scheduled */
- time_t StartTime; /* Job start time */
- time_t EndTime; /* Job termination time */
- utime_t JobTDate; /* Backup time/date in seconds */
+ char Job[MAX_NAME_LENGTH]; /* Job unique name */
+ char Name[MAX_NAME_LENGTH]; /* Job base name */
+ int JobType; /* actually char(1) */
+ int JobLevel; /* actually char(1) */
+ int JobStatus; /* actually char(1) */
+ DBId_t ClientId; /* Id of client */
+ DBId_t PoolId; /* Id of pool */
+ DBId_t FileSetId; /* Id of FileSet */
+ time_t SchedTime; /* Time job scheduled */
+ time_t StartTime; /* Job start time */
+ time_t EndTime; /* Job termination time */
+ utime_t JobTDate; /* Backup time/date in seconds */
uint32_t VolSessionId;
uint32_t VolSessionTime;
uint32_t JobFiles;
/* Note, FirstIndex, LastIndex, Start/End File and Block
* are only used in the JobMedia record.
*/
- uint32_t FirstIndex; /* First index this Volume */
- uint32_t LastIndex; /* Last index this Volume */
+ uint32_t FirstIndex; /* First index this Volume */
+ uint32_t LastIndex; /* Last index this Volume */
uint32_t StartFile;
uint32_t EndFile;
uint32_t StartBlock;
*/
/* JobMedia record */
struct JOBMEDIA_DBR {
- DBId_t JobMediaId; /* record id */
- JobId_t JobId; /* JobId */
- DBId_t MediaId; /* MediaId */
- uint32_t FirstIndex; /* First index this Volume */
- uint32_t LastIndex; /* Last index this Volume */
- uint32_t StartFile; /* File for start of data */
- uint32_t EndFile; /* End file on Volume */
- uint32_t StartBlock; /* start block on tape */
- uint32_t EndBlock; /* last block */
+ DBId_t JobMediaId; /* record id */
+ JobId_t JobId; /* JobId */
+ DBId_t MediaId; /* MediaId */
+ uint32_t FirstIndex; /* First index this Volume */
+ uint32_t LastIndex; /* Last index this Volume */
+ uint32_t StartFile; /* File for start of data */
+ uint32_t EndFile; /* End file on Volume */
+ uint32_t StartBlock; /* start block on tape */
+ uint32_t EndBlock; /* last block */
};
/* Volume Parameter structure */
struct VOL_PARAMS {
char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
- uint32_t VolIndex; /* Volume seqence no. */
- uint32_t FirstIndex; /* First index this Volume */
- uint32_t LastIndex; /* Last index this Volume */
- uint32_t StartFile; /* File for start of data */
- uint32_t EndFile; /* End file on Volume */
- uint32_t StartBlock; /* start block on tape */
- uint32_t EndBlock; /* last block */
+ uint32_t VolIndex; /* Volume seqence no. */
+ uint32_t FirstIndex; /* First index this Volume */
+ uint32_t LastIndex; /* Last index this Volume */
+ uint32_t StartFile; /* File for start of data */
+ uint32_t EndFile; /* End file on Volume */
+ uint32_t StartBlock; /* start block on tape */
+ uint32_t EndBlock; /* last block */
};
* records (e.g. pathname, filename, fileattributes).
*/
struct ATTR_DBR {
- char *fname; /* full path & filename */
- char *link; /* link if any */
- char *attr; /* attributes statp */
+ char *fname; /* full path & filename */
+ char *link; /* link if any */
+ char *attr; /* attributes statp */
uint32_t FileIndex;
uint32_t Stream;
JobId_t JobId;
char LStat[256];
/* int Status; */
char SIG[50];
- int SigType; /* NO_SIG/MD5_SIG/SHA1_SIG */
+ int SigType; /* NO_SIG/MD5_SIG/SHA1_SIG */
};
/* Pool record -- same format as database */
struct POOL_DBR {
DBId_t PoolId;
- char Name[MAX_NAME_LENGTH]; /* Pool name */
- uint32_t NumVols; /* total number of volumes */
- uint32_t MaxVols; /* max allowed volumes */
- int32_t UseOnce; /* set to use once only */
- int32_t UseCatalog; /* set to use catalog */
- int32_t AcceptAnyVolume; /* set to accept any volume sequence */
- int32_t AutoPrune; /* set to prune automatically */
- int32_t Recycle; /* default Vol recycle flag */
- utime_t VolRetention; /* retention period in seconds */
- utime_t VolUseDuration; /* time in secs volume can be used */
- uint32_t MaxVolJobs; /* Max Jobs on Volume */
- uint32_t MaxVolFiles; /* Max files on Volume */
- uint64_t MaxVolBytes; /* Max bytes on Volume */
- char PoolType[MAX_NAME_LENGTH];
+ char Name[MAX_NAME_LENGTH]; /* Pool name */
+ uint32_t NumVols; /* total number of volumes */
+ uint32_t MaxVols; /* max allowed volumes */
+ int32_t UseOnce; /* set to use once only */
+ int32_t UseCatalog; /* set to use catalog */
+ int32_t AcceptAnyVolume; /* set to accept any volume sequence */
+ int32_t AutoPrune; /* set to prune automatically */
+ int32_t Recycle; /* default Vol recycle flag */
+ utime_t VolRetention; /* retention period in seconds */
+ utime_t VolUseDuration; /* time in secs volume can be used */
+ uint32_t MaxVolJobs; /* Max Jobs on Volume */
+ uint32_t MaxVolFiles; /* Max files on Volume */
+ uint64_t MaxVolBytes; /* Max bytes on Volume */
+ char PoolType[MAX_NAME_LENGTH];
char LabelFormat[MAX_NAME_LENGTH];
/* Extra stuff not in DB */
faddr_t rec_addr;
/* Media record -- same as the database */
struct MEDIA_DBR {
- DBId_t MediaId; /* Unique volume id */
+ DBId_t MediaId; /* Unique volume id */
char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
char MediaType[MAX_NAME_LENGTH]; /* Media type */
- DBId_t PoolId; /* Pool id */
- time_t FirstWritten; /* Time Volume first written */
- time_t LastWritten; /* Time Volume last written */
- time_t LabelDate; /* Date/Time Volume labeled */
- uint32_t VolJobs; /* number of jobs on this medium */
- uint32_t VolFiles; /* Number of files */
- uint32_t VolBlocks; /* Number of blocks */
- uint32_t VolMounts; /* Number of times mounted */
- uint32_t VolErrors; /* Number of read/write errors */
- uint32_t VolWrites; /* Number of writes */
- uint32_t VolReads; /* Number of reads */
- uint64_t VolBytes; /* Number of bytes written */
- uint64_t MaxVolBytes; /* Max bytes to write to Volume */
- uint64_t VolCapacityBytes; /* capacity estimate */
- uint64_t VolReadTime; /* time spent reading volume */
- uint64_t VolWriteTime; /* time spent writing volume */
- utime_t VolRetention; /* Volume retention in seconds */
- utime_t VolUseDuration; /* time in secs volume can be used */
- uint32_t MaxVolJobs; /* Max Jobs on Volume */
- uint32_t MaxVolFiles; /* Max files on Volume */
- int32_t Recycle; /* recycle yes/no */
- int32_t Slot; /* slot in changer */
- int32_t InChanger; /* Volume currently in changer */
- char VolStatus[20]; /* Volume status */
+ DBId_t PoolId; /* Pool id */
+ time_t FirstWritten; /* Time Volume first written */
+ time_t LastWritten; /* Time Volume last written */
+ time_t LabelDate; /* Date/Time Volume labeled */
+ uint32_t VolJobs; /* number of jobs on this medium */
+ uint32_t VolFiles; /* Number of files */
+ uint32_t VolBlocks; /* Number of blocks */
+ uint32_t VolMounts; /* Number of times mounted */
+ uint32_t VolErrors; /* Number of read/write errors */
+ uint32_t VolWrites; /* Number of writes */
+ uint32_t VolReads; /* Number of reads */
+ uint64_t VolBytes; /* Number of bytes written */
+ uint64_t MaxVolBytes; /* Max bytes to write to Volume */
+ uint64_t VolCapacityBytes; /* capacity estimate */
+ uint64_t VolReadTime; /* time spent reading volume */
+ uint64_t VolWriteTime; /* time spent writing volume */
+ utime_t VolRetention; /* Volume retention in seconds */
+ utime_t VolUseDuration; /* time in secs volume can be used */
+ uint32_t MaxVolJobs; /* Max Jobs on Volume */
+ uint32_t MaxVolFiles; /* Max files on Volume */
+ int32_t Recycle; /* recycle yes/no */
+ int32_t Slot; /* slot in changer */
+ int32_t InChanger; /* Volume currently in changer */
+ char VolStatus[20]; /* Volume status */
/* Extra stuff not in DB */
- faddr_t rec_addr; /* found record address */
+ faddr_t rec_addr; /* found record address */
/* Since the database returns times as strings, this is how we pass
- * them back.
+ * them back.
*/
char cFirstWritten[MAX_TIME_LENGTH]; /* FirstWritten returned from DB */
char cLastWritten[MAX_TIME_LENGTH]; /* LastWritten returned from DB */
/* Client record -- same as the database */
struct CLIENT_DBR {
- DBId_t ClientId; /* Unique Client id */
+ DBId_t ClientId; /* Unique Client id */
int AutoPrune;
utime_t FileRetention;
utime_t JobRetention;
- char Name[MAX_NAME_LENGTH]; /* Client name */
- char Uname[256]; /* Uname for client */
+ char Name[MAX_NAME_LENGTH]; /* Client name */
+ char Uname[256]; /* Uname for client */
};
/* Counter record as in database */
/* FileSet record -- same as the database */
struct FILESET_DBR {
- DBId_t FileSetId; /* Unique FileSet id */
+ DBId_t FileSetId; /* Unique FileSet id */
char FileSet[MAX_NAME_LENGTH]; /* FileSet name */
- char MD5[50]; /* MD5 signature of include/exclude */
- time_t CreateTime; /* date created */
+ char MD5[50]; /* MD5 signature of include/exclude */
+ time_t CreateTime; /* date created */
/*
* This is where we return CreateTime
*/
char cCreateTime[MAX_TIME_LENGTH]; /* CreateTime as returned from DB */
/* Not in DB but returned by db_create_fileset() */
- bool created; /* set when record newly created */
+ bool created; /* set when record newly created */
};
#endif
mysql_init(&(mdb->mysql));
Dmsg0(50, "mysql_init done\n");
- mdb->db = mysql_real_connect(
- &(mdb->mysql), /* db */
- mdb->db_address, /* default = localhost */
- mdb->db_user, /* login name */
- mdb->db_password, /* password */
- mdb->db_name, /* database name */
- mdb->db_port, /* default port */
- mdb->db_socket, /* default = socket */
- CLIENT_FOUND_ROWS); /* flags */
-
- /* If no connect, try once more in case it is a timing problem */
- if (mdb->db == NULL) {
+ /* If connection fails, try at 5 sec intervals for 30 seconds. */
+ for (int return=0; retry < 6; retry++) {
mdb->db = mysql_real_connect(
&(mdb->mysql), /* db */
mdb->db_address, /* default = localhost */
mdb->db_port, /* default port */
mdb->db_socket, /* default = socket */
CLIENT_FOUND_ROWS); /* flags */
+
+ /* If no connect, try once more in case it is a timing problem */
+ if (mdb->db != NULL) {
+ break;
+ }
+ bmicrosleep(5,0);
}
Dmsg0(50, "mysql_real_connect done\n");
V(mutex);
return 1;
}
- mdb->connected = FALSE;
+ mdb->connected = false;
if ((errstat=rwl_init(&mdb->lock)) != 0) {
Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"),
} else {
port = NULL;
}
- /* connect to the database */
- mdb->db = PQsetdbLogin(
- mdb->db_address, /* default = localhost */
- port, /* default port */
- NULL, /* pg options */
- NULL, /* tty, ignored */
- mdb->db_name, /* database name */
- mdb->db_user, /* login name */
- mdb->db_password); /* password */
-
- /* If no connect, try once more in case it is a timing problem */
- if (PQstatus(mdb->db) != CONNECTION_OK) {
- mdb->db = PQsetdbLogin(
- mdb->db_address, /* default = localhost */
- port, /* default port */
- NULL, /* pg options */
- NULL, /* tty, ignored */
- mdb->db_name, /* database name */
- mdb->db_user, /* login name */
- mdb->db_password); /* password */
+
+ /* If connection fails, try at 5 sec intervals for 30 seconds. */
+ for (int retry=0; retry < 6; retry++) {
+ /* connect to the database */
+ mdb->db = PQsetdbLogin(
+ mdb->db_address, /* default = localhost */
+ port, /* default port */
+ NULL, /* pg options */
+ NULL, /* tty, ignored */
+ mdb->db_name, /* database name */
+ mdb->db_user, /* login name */
+ mdb->db_password); /* password */
+
+ /* If no connect, try once more in case it is a timing problem */
+ if (PQstatus(mdb->db) == CONNECTION_OK) {
+ break;
+ }
+ bmicrosleep(5, 0);
}
-
+
Dmsg0(50, "pg_real_connect done\n");
Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name,
mdb->db_password==NULL?"(NULL)":mdb->db_password);
return 0;
}
- mdb->connected = TRUE;
+ mdb->connected = true;
V(mutex);
return 1;
}
if (mdb->db_socket) {
free(mdb->db_socket);
}
+ my_postgresql_free_result(mdb);
free(mdb);
}
V(mutex);
POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
{
- int j;
+ int j;
POSTGRESQL_ROW row = NULL; // by default, return NULL
Dmsg0(500, "my_postgresql_fetch_row start\n");
Dmsg1(500, "we have need space of %d bytes\n", sizeof(char *) * mdb->num_fields);
if (mdb->row != NULL) {
- Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
- free(mdb->row);
- mdb->row = NULL;
+ Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
+ free(mdb->row);
+ mdb->row = NULL;
}
mdb->row = (POSTGRESQL_ROW) malloc(sizeof(char *) * mdb->num_fields);
Dmsg2(500, "my_postgresql_fetch_row row number '%d' is acceptable (0..%d)\n", mdb->row_number, mdb->num_rows);
// get each value from this row
for (j = 0; j < mdb->num_fields; j++) {
- mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j);
- Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
+ mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j);
+ Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
}
// increment the row number for the next call
mdb->row_number++;
//
// for a given column, find the max length
//
- int max_length;
+ int max_length;
int i;
- int this_length;
+ int this_length;
max_length = 0;
for (i = 0; i < mdb->num_rows; i++) {
mdb->field_number = field;
}
+/*
+ * Note, if this routine returns 1 (failure), Bacula expects
+ * that no result has been stored.
+ */
int my_postgresql_query(B_DB *mdb, char *query) {
Dmsg0(500, "my_postgresql_query started\n");
// We are starting a new query. reset everything.
mdb->row_number = -1;
mdb->field_number = -1;
+ if (mdb->result != NULL) {
+ PQclear(mdb->result); /* hmm, someone forgot to free?? */
+ }
Dmsg1(500, "my_postgresql_query starts with '%s'\n", query);
mdb->result = PQexec(mdb->db, query);
{
if (mdb->result) {
PQclear(mdb->result);
+ mdb->result = NULL;
}
if (mdb->row) {
Dmsg1(200, "selectpool: %s\n", mdb->cmd);
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
mdb->num_rows = sql_num_rows(mdb);
-
if (mdb->num_rows > 0) {
Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name);
sql_free_result(mdb);
cr->ClientId = 0;
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
mdb->num_rows = sql_num_rows(mdb);
-
/* If more than one, report error, but return first row */
if (mdb->num_rows > 1) {
Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows));
fsr->FileSetId = 0;
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
mdb->num_rows = sql_num_rows(mdb);
-
if (mdb->num_rows > 1) {
Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows));
Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
ASSERT(ar->PathId);
return 1;
}
-
sql_free_result(mdb);
}
}
if ((row = sql_fetch_row(mdb)) == NULL) {
sql_free_result(mdb);
- Mmsg(&mdb->errmsg, _("No prior Full backup Job record found.\n"));
+ Mmsg(&mdb->errmsg, _("No prior Full backup Job record found.\n"));
db_unlock(mdb);
return 0;
}
Dmsg1(100, "Query=%s\n", mdb->cmd);
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
mdb->num_rows = sql_num_rows(mdb);
Dmsg1(050, "get_file_record num_rows=%d\n", (int)mdb->num_rows);
-
if (mdb->num_rows > 1) {
Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"),
mdb->num_rows);
Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
char ed1[30];
-
mdb->num_rows = sql_num_rows(mdb);
-
if (mdb->num_rows > 1) {
Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"),
edit_uint64(mdb->num_rows, ed1), mdb->fname);
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
char ed1[30];
mdb->num_rows = sql_num_rows(mdb);
-
if (mdb->num_rows > 1) {
Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"),
edit_uint64(mdb->num_rows, ed1), mdb->path);
"FROM Counters WHERE Counter='%s'", cr->Counter);
if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
mdb->num_rows = sql_num_rows(mdb);
/* If more than one, report error, but return first row */
free(mdb->fields[i]);
}
free(mdb->fields);
- mdb->fields_defined = FALSE;
+ mdb->fields_defined = false;
}
sqlite_free_table(mdb->result);
mdb->nrow = mdb->ncolumn = 0;
#include "bacula.h"
#include "dird.h"
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
/* Forward referenced subroutines */
/* Store regex info */
static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
{
- int token;
+ int token, rc;
+ regex_t preg;
+ char prbuf[500];
if (pass == 1) {
/* Pickup regex string
case T_IDENTIFIER:
case T_UNQUOTED_STRING:
case T_QUOTED_STRING:
+ rc = regcomp(&preg, lc->str, REG_EXTENDED);
+ if (rc != 0) {
+ regerror(rc, &preg, prbuf, sizeof(prbuf));
+ regfree(&preg);
+ scan_err1(lc, _("Regex compile error. ERR=%s\n"), prbuf);
+ break;
+ }
+ regfree(&preg);
res_incexe.current_opts->regex.append(bstrdup(lc->str));
Dmsg3(900, "set regex %p size=%d %s\n",
res_incexe.current_opts, res_incexe.current_opts->regex.size(),lc->str);
#ifdef HAVE_ACL
/* ACL stream */
- if(ff_pkt->flags & FO_ACL) {
+ if (ff_pkt->flags & FO_ACL) {
char *acl_text;
/* Read ACLs for files, dirs and links */
- if(ff_pkt->type == FT_DIREND) {
+ if (ff_pkt->type == FT_DIREND) {
/* Directory: Try for default ACL*/
acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_DEFAULT);
- if(!myAcl) {
+ if (!myAcl) {
Dmsg1(200, "No default ACL defined for directory: %s!\n", ff_pkt->fname);
/* If there is no default ACL get standard ACL */
myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
- if(!myAcl) {
+ if (!myAcl) {
Emsg1(M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname);
}
}
} else {
/* Files or links */
acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
- if(!myAcl) {
+ if (!myAcl) {
Emsg1(M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname);
acl_free(myAcl);
}
acl_free(myAcl);
}
- /* Send stream to server */
- sd = jcr->store_bsock;
+ /* If there is an ACL, send it to the Storage daemon */
+ if (acl_text) {
+ sd = jcr->store_bsock;
+ pm_strcpy(&jcr->last_fname, ff_pkt->fname);
- msgsave = sd->msg;
-
- pm_strcpy(&jcr->last_fname, ff_pkt->fname);
-
- /*
- * Send ACL header
- *
- */
- if(!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACL)) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- return 0;
- }
+ /*
+ * Send ACL header
+ *
+ */
+ if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACL)) {
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
+ return 0;
+ }
- /* Send the buffer to the storage deamon */
- sd->msg = acl_text;
- sd->msglen = strlen(acl_text) + 1;
- if(!bnet_send(sd)) {
- sd->msg = msgsave;
- sd->msglen = 0;
- bclose(&ff_pkt->bfd);
- set_jcr_job_status(jcr, JS_ErrorTerminated);
- Emsg1(M_WARNING, 0, "Error while trying to send ACL of %s to SD!\n", ff_pkt->fname);
- } else {
- jcr->JobBytes += sd->msglen;
- sd->msg = msgsave;
- bclose(&ff_pkt->bfd);
- if(!bnet_sig(sd, BNET_EOD)) {
+ /* Send the buffer to the storage deamon */
+ msgsave = sd->msg;
+ sd->msg = acl_text;
+ sd->msglen = strlen(acl_text) + 1;
+ if (!bnet_send(sd)) {
+ sd->msg = msgsave;
+ sd->msglen = 0;
+ bclose(&ff_pkt->bfd);
set_jcr_job_status(jcr, JS_ErrorTerminated);
+ Emsg1(M_WARNING, 0, "Error while trying to send ACL of %s to SD!\n", ff_pkt->fname);
} else {
- Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
- }
- }
+ jcr->JobBytes += sd->msglen;
+ sd->msg = msgsave;
+ bclose(&ff_pkt->bfd);
+ if (!bnet_sig(sd, BNET_EOD)) {
+ set_jcr_job_status(jcr, JS_ErrorTerminated);
+ } else {
+ Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
+ }
+ }
+ }
}
#endif
FDport = @fd_port@ # where we listen for the director
WorkingDirectory = @working_dir@
Pid Directory = @piddir@
+ Maximum Concurrent Jobs = 1
}
# Send all messages except skipped files back to Director
/* Imported Functions */
extern void *handle_client_request(void *dir_sock);
+/* Imported Variables */
+extern time_t watchdog_sleep_time;
+
/* Forward referenced functions */
void terminate_filed(int sig);
char OK_msg[] = "2000 OK\n";
char TERM_msg[] = "2999 Terminate\n";
-
#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
const int win32_client = 1;
#else
#define CONFIG_FILE "./bacula-fd.conf" /* default config file */
static char *configfile = NULL;
-static int foreground = 0;
-static int inetd_request = 0;
+static bool foreground = false;
+static bool inetd_request = false;
static workq_t dir_workq; /* queue of work from Director */
static pthread_t server_tid;
int main (int argc, char *argv[])
{
int ch;
- int no_signals = FALSE;
- int test_config = FALSE;
+ bool no_signals = false;
+ bool test_config = false;
DIRRES *director;
char *uid = NULL;
char *gid = NULL;
break;
case 'f': /* run in foreground */
- foreground = TRUE;
+ foreground = true;
break;
case 'g': /* set group */
break;
case 'i':
- inetd_request = TRUE;
+ inetd_request = true;
break;
case 's':
- no_signals = TRUE;
+ no_signals = true;
break;
case 't':
- test_config = TRUE;
+ test_config = true;
break;
case 'u': /* set userid */
if (!no_signals) {
init_signals(terminate_filed);
+ } else {
+ /* This reduces the number of signals facilitating debugging */
+ watchdog_sleep_time = 120; /* long timeout for debugging */
}
if (configfile == NULL) {
set_thread_concurrency(10);
- start_watchdog(); /* start watchdog thread */
-
- init_jcr_subsystem(); /* start JCR watchdogs etc. */
+ if (!no_signals) {
+ start_watchdog(); /* start watchdog thread */
+ init_jcr_subsystem(); /* start JCR watchdogs etc. */
+ }
server_tid = pthread_self();
if (inetd_request) {
FF_PKT *ff = (FF_PKT *)jcr->ff;
findFILESET *fileset = ff->fileset;
if (fileset) {
- int i, j;
+ int i, j, k;
/* Delete FileSet Include lists */
for (i=0; i<fileset->include_list.size(); i++) {
findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
for (j=0; j<incexe->opts_list.size(); j++) {
findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
+ for (k=0; k<fo->regex.size(); k++) {
+ regfree((regex_t *)fo->regex.get(k));
+ }
fo->regex.destroy();
fo->wild.destroy();
fo->base.destroy();
break;
case 'R':
current_opts = start_options(ff);
- current_opts->regex.append(bstrdup(item));
+ regex_t *preg;
+ int rc;
+ char prbuf[500];
+ preg = (regex_t *)malloc(sizeof(regex_t));
+ rc = regcomp(preg, item, REG_EXTENDED);
+ if (rc != 0) {
+ regerror(rc, preg, prbuf, sizeof(prbuf));
+ regfree(preg);
+ free(preg);
+ Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
+ state = state_error;
+ break;
+ }
+ current_opts->regex.append(preg);
state = state_options;
break;
case 'B':
#endif
break;
-#ifdef HAVE_ACL
case STREAM_UNIX_ATTRIBUTES_ACL:
+#ifdef HAVE_ACL
/* Recover ACL from stream and check it */
acl = acl_from_text(sd->msg);
- if(acl_valid(acl) != 0) {
+ if (acl_valid(acl) != 0) {
Emsg1(M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
acl_free(acl);
}
/* Try to restore ACL */
- if(attr->type == FT_DIREND) {
+ if (attr->type == FT_DIREND) {
/* Directory */
- if(acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0) {
- if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
- Emsg1(M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
- }
- }
- } else {
- /* File or Link */
- if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
- Emsg1(M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+ if (acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0 &&
+ acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+ Emsg1(M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
}
+ /* File or Link */
+ } else if (acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+ Emsg1(M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
}
acl_free(acl);
Dmsg1(200, "ACL of file: %s successfully restored!", jcr->last_fname);
break;
#else
- case STREAM_UNIX_ATTRIBUTES_ACL:
non_support_acl++;
break; /* unconfigured, ignore */
#endif
#include "bacula.h"
#include "find.h"
-
int32_t name_max; /* filename max length */
int32_t path_max; /* path name max length */
return true; /* accept file */
}
}
+ for (k=0; k<fo->regex.size(); k++) {
+ const int nmatch = 30;
+ regmatch_t pmatch[nmatch];
+ if (regexec((regex_t *)fo->regex.get(k), ff->fname, nmatch, pmatch, 0) == 0) {
+ ff->flags = fo->flags;
+ ff->GZIP_level = fo->GZIP_level;
+ if (ff->flags & FO_EXCLUDE) {
+ return false; /* reject file */
+ }
+ return true; /* accept file */
+ }
+ }
}
for (i=0; i<fileset->exclude_list.size(); i++) {
#include "lib/fnmatch.h"
#endif
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
+
#include "save-cwd.h"
#ifndef HAVE_READDIR_R
* Status codes returned by create_file()
*/
enum {
- CF_SKIP = 1, /* skip file (not newer or something) */
- CF_ERROR, /* error creating file */
- CF_EXTRACT, /* file created, data to extract */
- CF_CREATED /* file created, no data to extract */
+ CF_SKIP = 1, /* skip file (not newer or something) */
+ CF_ERROR, /* error creating file */
+ CF_EXTRACT, /* file created, data to extract */
+ CF_CREATED /* file created, no data to extract */
};
/* Options saved int "options" of the include/exclude lists.
* They are directly jammed ito "flag" of ff packet
*/
-#define FO_MD5 (1<<1) /* Do MD5 checksum */
-#define FO_GZIP (1<<2) /* Do Zlib compression */
-#define FO_NO_RECURSION (1<<3) /* no recursion in directories */
-#define FO_MULTIFS (1<<4) /* multiple file systems */
-#define FO_SPARSE (1<<5) /* do sparse file checking */
-#define FO_IF_NEWER (1<<6) /* replace if newer */
-#define FO_NOREPLACE (1<<7) /* never replace */
-#define FO_READFIFO (1<<8) /* read data from fifo */
-#define FO_SHA1 (1<<9) /* Do SHA1 checksum */
-#define FO_PORTABLE (1<<10) /* Use portable data format -- no BackupWrite */
-#define FO_MTIMEONLY (1<<11) /* Use mtime rather than mtime & ctime */
-#define FO_KEEPATIME (1<<12) /* Reset access time */
-#define FO_EXCLUDE (1<<13) /* Exclude file */
-#define FO_ACL (1<<14) /* Backup ACLs */
+#define FO_MD5 (1<<1) /* Do MD5 checksum */
+#define FO_GZIP (1<<2) /* Do Zlib compression */
+#define FO_NO_RECURSION (1<<3) /* no recursion in directories */
+#define FO_MULTIFS (1<<4) /* multiple file systems */
+#define FO_SPARSE (1<<5) /* do sparse file checking */
+#define FO_IF_NEWER (1<<6) /* replace if newer */
+#define FO_NOREPLACE (1<<7) /* never replace */
+#define FO_READFIFO (1<<8) /* read data from fifo */
+#define FO_SHA1 (1<<9) /* Do SHA1 checksum */
+#define FO_PORTABLE (1<<10) /* Use portable data format -- no BackupWrite */
+#define FO_MTIMEONLY (1<<11) /* Use mtime rather than mtime & ctime */
+#define FO_KEEPATIME (1<<12) /* Reset access time */
+#define FO_EXCLUDE (1<<13) /* Exclude file */
+#define FO_ACL (1<<14) /* Backup ACLs */
struct s_included_file {
struct s_included_file *next;
- uint32_t options; /* backup options */
- int level; /* compression level */
- int len; /* length of fname */
- int pattern; /* set if wild card pattern */
- char VerifyOpts[20]; /* Options for verify */
+ uint32_t options; /* backup options */
+ int level; /* compression level */
+ int len; /* length of fname */
+ int pattern; /* set if wild card pattern */
+ char VerifyOpts[20]; /* Options for verify */
char fname[1];
};
* of the structure are passed by the Director to the
* File daemon and recompiled back into this structure
*/
-#undef MAX_FOPTS
+#undef MAX_FOPTS
#define MAX_FOPTS 30
enum {
/* File options structure */
struct findFOPTS {
- uint32_t flags; /* options in bits */
- int GZIP_level; /* GZIP level */
- char VerifyOpts[MAX_FOPTS]; /* verify options */
- alist regex; /* regex string(s) */
- alist wild; /* wild card strings */
- alist base; /* list of base names */
+ uint32_t flags; /* options in bits */
+ int GZIP_level; /* GZIP level */
+ char VerifyOpts[MAX_FOPTS]; /* verify options */
+ alist regex; /* regex string(s) */
+ alist wild; /* wild card strings */
+ alist base; /* list of base names */
};
/* This is either an include item or an exclude item */
struct findINCEXE {
- findFOPTS *current_opts; /* points to current options structure */
- alist opts_list; /* options list */
- alist name_list; /* filename list -- holds char * */
+ findFOPTS *current_opts; /* points to current options structure */
+ alist opts_list; /* options list */
+ alist name_list; /* filename list -- holds char * */
};
/*
*/
struct findFILESET {
int state;
- findINCEXE *incexe; /* current item */
+ findINCEXE *incexe; /* current item */
alist include_list;
alist exclude_list;
};
* first argument to the find_files callback subroutine.
*/
struct FF_PKT {
- char *fname; /* filename */
- char *link; /* link if file linked */
- POOLMEM *sys_fname; /* system filename */
- struct stat statp; /* stat packet */
- int32_t FileIndex; /* FileIndex of this file */
- int32_t LinkFI; /* FileIndex of main hard linked file */
- struct f_link *linked; /* Set if this file is hard linked */
- int type; /* FT_ type from above */
- uint32_t flags; /* backup options */
- int ff_errno; /* errno */
- BFILE bfd; /* Bacula file descriptor */
- time_t save_time; /* start of incremental time */
- bool dereference; /* follow links (not implemented) */
- bool null_output_device; /* using null output device */
- bool incremental; /* incremental save */
- int GZIP_level; /* compression level */
+ char *fname; /* filename */
+ char *link; /* link if file linked */
+ POOLMEM *sys_fname; /* system filename */
+ struct stat statp; /* stat packet */
+ int32_t FileIndex; /* FileIndex of this file */
+ int32_t LinkFI; /* FileIndex of main hard linked file */
+ struct f_link *linked; /* Set if this file is hard linked */
+ int type; /* FT_ type from above */
+ uint32_t flags; /* backup options */
+ int ff_errno; /* errno */
+ BFILE bfd; /* Bacula file descriptor */
+ time_t save_time; /* start of incremental time */
+ bool dereference; /* follow links (not implemented) */
+ bool null_output_device; /* using null output device */
+ bool incremental; /* incremental save */
+ int GZIP_level; /* compression level */
char VerifyOpts[20];
struct s_included_file *included_files_list;
struct s_excluded_file *excluded_files_list;
int (*callback)(FF_PKT *, void *); /* User's callback */
/* List of all hard linked files found */
- struct f_link *linklist; /* hard linked files */
+ struct f_link *linklist; /* hard linked files */
};
extern time_t watchdog_time;
#ifndef INADDR_NONE
-#define INADDR_NONE -1
+#define INADDR_NONE -1
#endif
-#ifndef ENODATA /* not defined on BSD systems */
+#ifndef ENODATA /* not defined on BSD systems */
#define ENODATA EPIPE
#endif
#ifdef HAVE_WIN32
#define socketRead(fd, buf, len) recv(fd, buf, len, 0)
#define socketWrite(fd, buf, len) send(fd, buf, len, 0)
-#define socketClose(fd) closesocket(fd)
+#define socketClose(fd) closesocket(fd)
#else
#define socketRead(fd, buf, len) read(fd, buf, len)
#define socketWrite(fd, buf, len) write(fd, buf, len)
-#define socketClose(fd) close(fd)
+#define socketClose(fd) close(fd)
#endif
nleft = nbytes;
while (nleft > 0) {
do {
- errno = 0;
- nread = socketRead(bsock->fd, ptr, nleft);
- if (bsock->timed_out || bsock->terminated) {
- return nread;
- }
+ errno = 0;
+ nread = socketRead(bsock->fd, ptr, nleft);
+ if (bsock->timed_out || bsock->terminated) {
+ return nread;
+ }
} while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread <= 0) {
- return nread; /* error, or EOF */
+ return nread; /* error, or EOF */
}
nleft -= nread;
ptr += nread;
}
- return nbytes - nleft; /* return >= 0 */
+ return nbytes - nleft; /* return >= 0 */
}
/*
if (nwritten != nbytes) {
Qmsg1(bsock->jcr, M_FATAL, 0, _("Attr spool write error. ERR=%s\n"), strerror(errno));
Dmsg2(400, "nwritten=%d nbytes=%d.\n", nwritten, nbytes);
- return -1;
+ return -1;
}
return nbytes;
}
nleft = nbytes;
while (nleft > 0) {
do {
- errno = 0;
- nwritten = socketWrite(bsock->fd, ptr, nleft);
- if (bsock->timed_out || bsock->terminated) {
- return nwritten;
- }
+ errno = 0;
+ nwritten = socketWrite(bsock->fd, ptr, nleft);
+ if (bsock->timed_out || bsock->terminated) {
+ return nwritten;
+ }
} while (nwritten == -1 && errno == EINTR);
/*
* If connection is non-blocking, we will get EAGAIN, so
* and try again.
*/
if (nwritten == -1 && errno == EAGAIN) {
- fd_set fdset;
- struct timeval tv;
-
- FD_ZERO(&fdset);
- FD_SET((unsigned)bsock->fd, &fdset);
- tv.tv_sec = 10;
- tv.tv_usec = 0;
- select(bsock->fd + 1, NULL, &fdset, NULL, &tv);
- continue;
+ fd_set fdset;
+ struct timeval tv;
+
+ FD_ZERO(&fdset);
+ FD_SET((unsigned)bsock->fd, &fdset);
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+ select(bsock->fd + 1, NULL, &fdset, NULL, &tv);
+ continue;
}
if (nwritten <= 0) {
- return nwritten; /* error */
+ return nwritten; /* error */
}
nleft -= nwritten;
ptr += nwritten;
* Returns number of bytes read (may return zero)
* Returns -1 on signal (BNET_SIGNAL)
* Returns -2 on hard end of file (BNET_HARDEOF)
- * Returns -3 on error (BNET_ERROR)
+ * Returns -3 on error (BNET_ERROR)
*
* Unfortunately, it is a bit complicated because we have these
* four return types:
* 1. Normal data
* 2. Signal including end of data stream
- * 3. Hard end of file
+ * 3. Hard end of file
* 4. Error
* Using is_bnet_stop() and is_bnet_error() you can figure this all out.
*/
return BNET_HARDEOF;
}
- bsock->read_seqno++; /* bump sequence number */
- bsock->timer_start = watchdog_time; /* set start wait time */
+ bsock->read_seqno++; /* bump sequence number */
+ bsock->timer_start = watchdog_time; /* set start wait time */
bsock->timed_out = 0;
/* get data size -- in int32_t */
if ((nbytes = read_nbytes(bsock, (char *)&pktsiz, sizeof(int32_t))) <= 0) {
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
/* probably pipe broken because client died */
if (errno == 0) {
- bsock->b_errno = ENODATA;
+ bsock->b_errno = ENODATA;
} else {
- bsock->b_errno = errno;
+ bsock->b_errno = errno;
}
bsock->errors++;
- return BNET_HARDEOF; /* assume hard EOF received */
+ return BNET_HARDEOF; /* assume hard EOF received */
}
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
if (nbytes != sizeof(int32_t)) {
bsock->errors++;
bsock->b_errno = EIO;
Qmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"),
- sizeof(int32_t), nbytes, bsock->who, bsock->host, bsock->port);
+ sizeof(int32_t), nbytes, bsock->who, bsock->host, bsock->port);
return BNET_ERROR;
}
- pktsiz = ntohl(pktsiz); /* decode no. of bytes that follow */
+ pktsiz = ntohl(pktsiz); /* decode no. of bytes that follow */
- if (pktsiz == 0) { /* No data transferred */
- bsock->timer_start = 0; /* clear timer */
+ if (pktsiz == 0) { /* No data transferred */
+ bsock->timer_start = 0; /* clear timer */
bsock->in_msg_no++;
bsock->msglen = 0;
- return 0; /* zero bytes read */
+ return 0; /* zero bytes read */
}
/* If signal or packet size too big */
if (pktsiz < 0 || pktsiz > 1000000) {
- if (pktsiz > 0) { /* if packet too big */
- Qmsg3(bsock->jcr, M_FATAL, 0,
+ if (pktsiz > 0) { /* if packet too big */
+ Qmsg3(bsock->jcr, M_FATAL, 0,
_("Packet size too big from \"%s:%s:%d. Terminating connection.\n"),
- bsock->who, bsock->host, bsock->port);
- pktsiz = BNET_TERMINATE; /* hang up */
+ bsock->who, bsock->host, bsock->port);
+ pktsiz = BNET_TERMINATE; /* hang up */
}
if (pktsiz == BNET_TERMINATE) {
- bsock->terminated = 1;
+ bsock->terminated = 1;
}
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
bsock->b_errno = ENODATA;
- bsock->msglen = pktsiz; /* signal code */
- return BNET_SIGNAL; /* signal */
+ bsock->msglen = pktsiz; /* signal code */
+ return BNET_SIGNAL; /* signal */
}
/* Make sure the buffer is big enough + one byte for EOS */
bsock->msg = realloc_pool_memory(bsock->msg, pktsiz + 100);
}
- bsock->timer_start = watchdog_time; /* set start wait time */
+ bsock->timer_start = watchdog_time; /* set start wait time */
bsock->timed_out = 0;
/* now read the actual data */
if ((nbytes = read_nbytes(bsock, mp_chr(bsock->msg), pktsiz)) <= 0) {
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
if (errno == 0) {
- bsock->b_errno = ENODATA;
+ bsock->b_errno = ENODATA;
} else {
- bsock->b_errno = errno;
+ bsock->b_errno = errno;
}
bsock->errors++;
Qmsg4(bsock->jcr, M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"),
- bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
+ bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
return BNET_ERROR;
}
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
bsock->in_msg_no++;
bsock->msglen = nbytes;
if (nbytes != pktsiz) {
bsock->b_errno = EIO;
bsock->errors++;
Qmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes,
- bsock->who, bsock->host, bsock->port);
+ bsock->who, bsock->host, bsock->port);
return BNET_ERROR;
}
/* always add a zero by to properly terminate any
*/
mp_chr(bsock->msg)[nbytes] = 0; /* terminate in case it is a string */
sm_check(__FILE__, __LINE__, false);
- return nbytes; /* return actual length of message */
+ return nbytes; /* return actual length of message */
}
/*
- * Return 1 if there are errors on this bsock or it is closed,
+ * Return 1 if there are errors on this bsock or it is closed,
* i.e. stop communicating on this line.
*/
-int is_bnet_stop(BSOCK *bsock)
+bool is_bnet_stop(BSOCK *bsock)
{
return bsock->errors || bsock->terminated;
}
size += sizeof(int32_t);
bsock->msglen = ntohl(pktsiz);
if (bsock->msglen > 0) {
- if (bsock->msglen > (int32_t)sizeof_pool_memory(bsock->msg)) {
- bsock->msg = realloc_pool_memory(bsock->msg, bsock->msglen + 1);
- }
- nbytes = fread(bsock->msg, 1, bsock->msglen, bsock->spool_fd);
- if (nbytes != (size_t)bsock->msglen) {
+ if (bsock->msglen > (int32_t)sizeof_pool_memory(bsock->msg)) {
+ bsock->msg = realloc_pool_memory(bsock->msg, bsock->msglen + 1);
+ }
+ nbytes = fread(bsock->msg, 1, bsock->msglen, bsock->spool_fd);
+ if (nbytes != (size_t)bsock->msglen) {
Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, bsock->msglen);
Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
- update_attr_spool_size(tsize-last);
- return 0;
- }
- size += nbytes;
- if ((++count & 0x3F) == 0) {
- update_attr_spool_size(size-last);
- last = size;
- }
+ update_attr_spool_size(tsize-last);
+ return 0;
+ }
+ size += nbytes;
+ if ((++count & 0x3F) == 0) {
+ update_attr_spool_size(size-last);
+ last = size;
+ }
}
bnet_send(bsock);
}
* the length of the data packet which follows.
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
-int
+bool
bnet_send(BSOCK *bsock)
{
int32_t rc;
int32_t msglen;
if (bsock->errors || bsock->terminated || bsock->msglen > 1000000) {
- return 0;
+ return false;
}
msglen = bsock->msglen;
pktsiz = htonl((int32_t)bsock->msglen);
/* send int32_t containing size of data packet */
bsock->timer_start = watchdog_time; /* start timer */
- bsock->timed_out = 0;
+ bsock->timed_out = 0;
rc = write_nbytes(bsock, (char *)&pktsiz, sizeof(int32_t));
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
if (rc != sizeof(int32_t)) {
if (bsock->msglen == BNET_TERMINATE) { /* if we were terminating */
- bsock->terminated = 1;
- return 0; /* ignore any errors */
+ bsock->terminated = 1;
+ return false; /* ignore any errors */
}
bsock->errors++;
if (errno == 0) {
- bsock->b_errno = EIO;
+ bsock->b_errno = EIO;
} else {
- bsock->b_errno = errno;
+ bsock->b_errno = errno;
}
if (rc < 0) {
- if (!bsock->suppress_error_msgs && !bsock->timed_out) {
+ if (!bsock->suppress_error_msgs && !bsock->timed_out) {
Qmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"),
- bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
- }
+ bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
+ }
} else {
Qmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"),
- bsock->who, bsock->host, bsock->port, bsock->msglen, rc);
+ bsock->who, bsock->host, bsock->port, bsock->msglen, rc);
}
- return 0;
+ return false;
}
- bsock->out_msg_no++; /* increment message number */
- if (bsock->msglen <= 0) { /* length only? */
- return 1; /* yes, no data */
+ bsock->out_msg_no++; /* increment message number */
+ if (bsock->msglen <= 0) { /* length only? */
+ return true; /* yes, no data */
}
/* send data packet */
bsock->timer_start = watchdog_time; /* start timer */
- bsock->timed_out = 0;
+ bsock->timed_out = 0;
rc = write_nbytes(bsock, mp_chr(bsock->msg), bsock->msglen);
- bsock->timer_start = 0; /* clear timer */
+ bsock->timer_start = 0; /* clear timer */
if (rc != bsock->msglen) {
bsock->errors++;
if (errno == 0) {
- bsock->b_errno = EIO;
+ bsock->b_errno = EIO;
} else {
- bsock->b_errno = errno;
+ bsock->b_errno = errno;
}
if (rc < 0) {
- if (!bsock->suppress_error_msgs) {
+ if (!bsock->suppress_error_msgs) {
Qmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"),
- bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
- }
+ bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
+ }
} else {
Qmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"),
- bsock->msglen, bsock->who, bsock->host, bsock->port, rc);
+ bsock->msglen, bsock->who, bsock->host, bsock->port, rc);
}
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/*
- * Establish an SSL connection -- server side
+ * Establish an SSL connection -- server side
* Codes that ssl_need and ssl_has can take
- * BNET_SSL_NONE I cannot do ssl
- * BNET_SSL_OK I can do ssl, but it is not required on my end
+ * BNET_SSL_NONE I cannot do ssl
+ * BNET_SSL_OK I can do ssl, but it is not required on my end
* BNET_SSL_REQUIRED ssl is required on my end
*/
-int
+int
bnet_ssl_server(BSOCK *bsock, char *password, int ssl_need, int ssl_has)
{
/* Check to see if what we need (ssl_need) corresponds to what he has (ssl_has) */
}
/*
- * Establish an SSL connection -- client side
+ * Establish an SSL connection -- client side
*/
int bnet_ssl_client(BSOCK *bsock, char *password, int ssl_need)
{
* the BSOCK connection.
*
* Returns: 1 if data available
- * 0 if timeout
- * -1 if error
+ * 0 if timeout
+ * -1 if error
*/
int
-bnet_wait_data(BSOCK *bsock, int sec)
+bnet_wait_data(BSOCK *bsock, int sec)
{
fd_set fdset;
struct timeval tv;
tv.tv_usec = 0;
for ( ;; ) {
switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
- case 0: /* timeout */
- bsock->b_errno = 0;
- return 0;
+ case 0: /* timeout */
+ bsock->b_errno = 0;
+ return 0;
case -1:
- bsock->b_errno = errno;
- if (errno == EINTR || errno == EAGAIN) {
- continue;
- }
- return -1; /* error return */
+ bsock->b_errno = errno;
+ if (errno == EINTR || errno == EAGAIN) {
+ continue;
+ }
+ return -1; /* error return */
default:
- bsock->b_errno = 0;
- return 1;
+ bsock->b_errno = 0;
+ return 1;
}
}
}
* As above, but returns on interrupt
*/
int
-bnet_wait_data_intr(BSOCK *bsock, int sec)
+bnet_wait_data_intr(BSOCK *bsock, int sec)
{
fd_set fdset;
struct timeval tv;
tv.tv_usec = 0;
for ( ;; ) {
switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
- case 0: /* timeout */
- bsock->b_errno = 0;
- return 0;
+ case 0: /* timeout */
+ bsock->b_errno = 0;
+ return 0;
case -1:
- bsock->b_errno = errno;
- return -1; /* error return */
+ bsock->b_errno = errno;
+ return -1; /* error return */
default:
- bsock->b_errno = 0;
- return 1;
+ bsock->b_errno = 0;
+ return 1;
}
}
}
#ifndef NETDB_INTERNAL
-#define NETDB_INTERNAL -1 /* See errno. */
+#define NETDB_INTERNAL -1 /* See errno. */
#endif
#ifndef NETDB_SUCCESS
-#define NETDB_SUCCESS 0 /* No problem. */
+#define NETDB_SUCCESS 0 /* No problem. */
#endif
#ifndef HOST_NOT_FOUND
-#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
+#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
#endif
#ifndef TRY_AGAIN
-#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */
+#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL. */
#endif
#ifndef NO_RECOVERY
-#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */
+#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */
#endif
#ifndef NO_DATA
-#define NO_DATA 4 /* Valid name, no data record of requested type. */
+#define NO_DATA 4 /* Valid name, no data record of requested type. */
#endif
/*
static uint32_t *bget_host_ip(JCR *jcr, char *host)
{
struct in_addr inaddr;
- uint32_t *addr_list; /* this really should be struct in_addr */
+ uint32_t *addr_list; /* this really should be struct in_addr */
struct hostent *hp;
char **p;
int i;
P(ip_mutex);
if ((hp = gethostbyname(host)) == NULL) {
Qmsg2(jcr, M_ERROR, 0, "gethostbyname() for host \"%s\" failed: ERR=%s\n",
- host, gethost_strerror());
- V(ip_mutex);
- return NULL;
+ host, gethost_strerror());
+ V(ip_mutex);
+ return NULL;
}
if (hp->h_length != sizeof(inaddr.s_addr) || hp->h_addrtype != AF_INET) {
Qmsg2(jcr, M_ERROR, 0, _("gethostbyname() network address length error.\n\
Wanted %d got %d bytes for s_addr.\n"), sizeof(inaddr.s_addr), hp->h_length);
- V(ip_mutex);
- return NULL;
+ V(ip_mutex);
+ return NULL;
}
i = 0;
for (p = hp->h_addr_list; *p != 0; p++) {
- i++;
+ i++;
}
i++;
addr_list = (uint32_t *)malloc(sizeof(uint32_t) * i);
i = 0;
for (p = hp->h_addr_list; *p != 0; p++) {
- addr_list[i++] = (*(struct in_addr **)p)->s_addr;
+ addr_list[i++] = (*(struct in_addr **)p)->s_addr;
}
addr_list[i] = (uint32_t) -1;
V(ip_mutex);
bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *fatal)
{
int sockfd;
- struct sockaddr_in tcp_serv_addr; /* socket information */
+ struct sockaddr_in tcp_serv_addr; /* socket information */
uint32_t *addr_list;
int i, connected = 0;
int turnon = 1;
/* connect to server */
tcp_serv_addr.sin_addr.s_addr = addr_list[i];
if (connect(sockfd, (struct sockaddr *)&tcp_serv_addr, sizeof(tcp_serv_addr)) < 0) {
- continue;
+ continue;
}
connected = 1;
break;
*/
BSOCK *
bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, const char *name,
- char *host, char *service, int port, int verbose)
+ char *host, char *service, int port, int verbose)
{
int i;
BSOCK *bsock;
for (i=0; (bsock = bnet_open(jcr, name, host, service, port, &fatal)) == NULL; i -= retry_interval) {
if (fatal || (jcr && job_canceled(jcr))) {
- return NULL;
+ return NULL;
}
Dmsg4(100, "Unable to connect to %s on %s:%d. ERR=%s\n",
- name, host, port, strerror(errno));
+ name, host, port, strerror(errno));
if (i < 0) {
- i = 60 * 5; /* complain again in 5 minutes */
- if (verbose)
+ i = 60 * 5; /* complain again in 5 minutes */
+ if (verbose)
Qmsg4(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n\
Retrying ...\n", name, host, port, strerror(errno));
}
max_retry_time -= retry_interval;
if (max_retry_time <= 0) {
Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
- name, host, port, strerror(errno));
- return NULL;
+ name, host, port, strerror(errno));
+ return NULL;
}
}
return bsock;
/*
* Format and send a message
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
-int
+bool
bnet_fsend(BSOCK *bs, const char *fmt, ...)
{
va_list arg_ptr;
int maxlen;
if (bs->errors || bs->terminated) {
- return 0;
+ return false;
}
/* This probably won't work, but we vsnprintf, then if we
* get a negative length or a length greater than our buffer
* Actual size obtained is returned in bs->msglen
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
-int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
+bool bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
{
uint32_t dbuf_size, start_size;
#if defined(IP_TOS) && defined(IPTOS_THROUGHPUT)
start_size = dbuf_size;
if ((bs->msg = realloc_pool_memory(bs->msg, dbuf_size+100)) == NULL) {
Qmsg0(bs->jcr, M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
- return 0;
+ return false;
}
if (rw & BNET_SETBUF_READ) {
while ((dbuf_size > TAPE_BSIZE) &&
- (setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
+ (setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
- dbuf_size -= TAPE_BSIZE;
+ dbuf_size -= TAPE_BSIZE;
}
Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
if (dbuf_size != start_size) {
}
if (dbuf_size % TAPE_BSIZE != 0) {
Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
- dbuf_size);
+ dbuf_size);
}
}
if (size != 0) {
start_size = dbuf_size;
if (rw & BNET_SETBUF_WRITE) {
while ((dbuf_size > TAPE_BSIZE) &&
- (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
+ (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
- dbuf_size -= TAPE_BSIZE;
+ dbuf_size -= TAPE_BSIZE;
}
Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
if (dbuf_size != start_size) {
}
if (dbuf_size % TAPE_BSIZE != 0) {
Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
- dbuf_size);
+ dbuf_size);
}
}
bs->msglen = dbuf_size;
- return 1;
+ return true;
}
/*
* This consists of sending a negative packet length
*
* Returns: 0 on failure
- * 1 on success
+ * 1 on success
*/
-int bnet_sig(BSOCK *bs, int sig)
+bool bnet_sig(BSOCK *bs, int sig)
{
bs->msglen = sig;
return bnet_send(bs);
return "BNET_PROMPT";
default:
sprintf(buf, "Unknown sig %d", bs->msglen);
- return buf;
+ return buf;
}
}
*/
BSOCK *
init_bsock(JCR *jcr, int sockfd, const char *who, const char *host, int port,
- struct sockaddr_in *client_addr)
+ struct sockaddr_in *client_addr)
{
BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
memset(bsock, 0, sizeof(BSOCK));
memcpy(&bsock->client_addr, client_addr, sizeof(bsock->client_addr));
/*
* ****FIXME**** reduce this to a few hours once
- * heartbeats are implemented
+ * heartbeats are implemented
*/
bsock->timeout = 60 * 60 * 6 * 24; /* 6 days timeout */
bsock->jcr = jcr;
for ( ; bsock != NULL; bsock = next) {
next = bsock->next;
if (!bsock->duped) {
- if (bsock->timed_out) {
- shutdown(bsock->fd, 2); /* discard any pending I/O */
- }
- socketClose(bsock->fd); /* normal close */
+ if (bsock->timed_out) {
+ shutdown(bsock->fd, 2); /* discard any pending I/O */
+ }
+ socketClose(bsock->fd); /* normal close */
}
term_bsock(bsock);
}
free_pool_memory(bsock->msg);
bsock->msg = NULL;
} else {
- ASSERT(1==0); /* double close */
+ ASSERT(1==0); /* double close */
}
if (bsock->errmsg) {
free_pool_memory(bsock->errmsg);
/* bnet.c */
int32_t bnet_recv (BSOCK *bsock);
-int bnet_send (BSOCK *bsock);
-int bnet_fsend (BSOCK *bs, const char *fmt, ...);
-int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
-int bnet_sig (BSOCK *bs, int sig);
+bool bnet_send (BSOCK *bsock);
+bool bnet_fsend (BSOCK *bs, const char *fmt, ...);
+bool bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
+bool bnet_sig (BSOCK *bs, int sig);
int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need);
BSOCK * bnet_connect (JCR *jcr, int retry_interval,
int bnet_wait_data (BSOCK *bsock, int sec);
int bnet_wait_data_intr (BSOCK *bsock, int sec);
int bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
-int is_bnet_stop (BSOCK *bsock);
+bool is_bnet_stop (BSOCK *bsock);
int is_bnet_error (BSOCK *bsock);
void bnet_suppress_error_messages(BSOCK *bsock, bool flag);
#include "jcr.h"
/* Exported globals */
-time_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */
+time_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */
+time_t watchdog_sleep_time = 1; /* examine things every second */
-#define SLEEP_TIME 1 /* examine things every second */
/* Forward referenced functions */
extern "C" void *watchdog_thread(void *arg);
/* Static globals */
static bool quit = false;;
static bool wd_is_init = false;
-static brwlock_t lock; /* watchdog lock */
+static brwlock_t lock; /* watchdog lock */
static pthread_t wd_tid;
static dlist *wd_queue;
* Start watchdog thread
*
* Returns: 0 on success
- * errno on failure
+ * errno on failure
*/
int start_watchdog(void)
{
if ((errstat=rwl_init(&lock)) != 0) {
Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"),
- strerror(errstat));
+ strerror(errstat));
}
wd_queue = new dlist(wd_queue, &dummy->link);
wd_inactive = new dlist(wd_inactive, &dummy->link);
* Terminate the watchdog thread
*
* Returns: 0 on success
- * errno on failure
+ * errno on failure
*/
int stop_watchdog(void)
{
return 0;
}
- quit = true; /* notify watchdog thread to stop */
+ quit = true; /* notify watchdog thread to stop */
wd_is_init = false;
stat = pthread_join(wd_tid, NULL);
wd_queue->remove(item);
p = (watchdog_t *)item;
if (p->destructor != NULL) {
- p->destructor(p);
+ p->destructor(p);
}
free(p);
}
wd_inactive->remove(item);
p = (watchdog_t *)item;
if (p->destructor != NULL) {
- p->destructor(p);
+ p->destructor(p);
}
free(p);
}
foreach_dlist(p, wd_queue) {
if (wd == p) {
- wd_queue->remove(wd);
+ wd_queue->remove(wd);
Dmsg1(400, "Unregistered watchdog %p\n", wd);
- return true;
+ return true;
}
}
foreach_dlist(p, wd_inactive) {
if (wd == p) {
- wd_inactive->remove(wd);
+ wd_inactive->remove(wd);
Dmsg1(400, "Unregistered inactive watchdog %p\n", wd);
- return true;
+ return true;
}
}
watchdog_time = time(NULL);
foreach_dlist(p, wd_queue) {
- if (p->next_fire < watchdog_time) {
- /* Run the callback */
- p->callback(p);
+ if (p->next_fire < watchdog_time) {
+ /* Run the callback */
+ p->callback(p);
/* Reschedule (or move to inactive list if it's a one-shot timer) */
- if (p->one_shot) {
- /*
- * Note, when removing an item while walking the list
- * we must get the previous pointer (q) and set the
- * current pointer (p) to this previous pointer after
+ if (p->one_shot) {
+ /*
+ * Note, when removing an item while walking the list
+ * we must get the previous pointer (q) and set the
+ * current pointer (p) to this previous pointer after
* removing the current pointer, otherwise, we won't
- * walk the rest of the list.
- */
- q = (watchdog_t *)wd_queue->prev(p);
- wd_queue->remove(p);
- wd_inactive->append(p);
- p = q;
- } else {
- p->next_fire = watchdog_time + p->interval;
- }
- }
+ * walk the rest of the list.
+ */
+ q = (watchdog_t *)wd_queue->prev(p);
+ wd_queue->remove(p);
+ wd_inactive->append(p);
+ p = q;
+ } else {
+ p->next_fire = watchdog_time + p->interval;
+ }
+ }
}
wd_unlock();
unlock_jcr_chain();
- bmicrosleep(SLEEP_TIME, 0);
+ bmicrosleep(watchdog_sleep_time, 0);
}
Dmsg0(400, "NicB-reworked watchdog thread exited\n");
int errstat;
if ((errstat=rwl_writelock(&lock)) != 0) {
Emsg1(M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
- strerror(errstat));
+ strerror(errstat));
}
}
int errstat;
if ((errstat=rwl_writeunlock(&lock)) != 0) {
Emsg1(M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
- strerror(errstat));
+ strerror(errstat));
}
}
SDPort = @sd_port@ # Director's port
WorkingDirectory = "@working_dir@"
Pid Directory = "@piddir@"
+ Maximum Concurrent Jobs = 1
}
#
#undef VERSION
#define VERSION "1.35.0"
#define VSTRING "1"
-#define BDATE "27 June 2004"
-#define LSMDATE "27Jun04"
+#define BDATE "01 July 2004"
+#define LSMDATE "01Jul04"
/* Debug flags */
#undef DEBUG