#
-# $Id$
+# Version $Id$
#
@MCOMMON@
#
-# $Id$
+# Version $Id$
#
@MCOMMON@
/*
* General header file configurations that apply to
* all daemons. System dependent stuff goes here.
+ *
+ * Version $Id$
*/
/*
- Copyright (C) 2000, 2001 Kern Sibbald and John Walker
+ Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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 the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* bacula.h -- main header file to include in all Bacula source
*
+ * Version $Id$
*/
/*
-
- Copyright (C) 2000, 2001 Kern Sibbald and John Walker
+ Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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 the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
*/
Also, we define types such as file address lengths.
+ Version $Id$
+
*/
/*
-
- Copyright (C) 2000, 2001 Kern Sibbald and John Walker
+ Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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 the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
*/
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
+ *
*/
+
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
*/
/*
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
*/
/*
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
*/
/*
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
*/
/*
* system.
*
* Kern Sibbald, January MMI
+ *
+ * Version $Id$
*/
/*
*
* Kern Sibbald, January MMI
*
- * $Id:
+ *
+ * Version $Id$
*/
/*
/*
* SQL header file
*
+ * by Kern E. Sibbald
+ *
* Anyone who accesses the database will need to include
* this file.
*
* the external world, and definitions destined only
* for the external world. This is control with
* the define __SQL_C, which is defined only in sql.c
+ *
+ * Version $Id$
*/
/*
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 */
- uint32_t length; /* length */
- uint32_t max_length; /* max length */
- uint32_t type; /* type */
- uint32_t flags; /* flags */
+ char *name; /* name of column */
+ uint32_t length; /* length */
+ uint32_t 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 */
+ BQUEUE bq; /* queue control */
pthread_mutex_t mutex;
struct sqlite *db;
char **result;
- 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 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 ref_count;
char *db_name;
char *db_user;
char *db_password;
int connected;
- char *sqlite_errmsg; /* error message returned by sqlite */
- char *errmsg; /* nicely edited error message */
- char *cmd; /* SQL command string */
+ char *sqlite_errmsg; /* error message returned by sqlite */
+ char *errmsg; /* nicely edited error message */
+ char *cmd; /* SQL command string */
} 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) (unsigned)((x)->ncolumn)
-#define SQL_ROW char**
+#define SQL_ROW char**
* 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 */
+ BQUEUE bq; /* queue control */
pthread_mutex_t mutex;
MYSQL mysql;
MYSQL *db;
char *db_name;
char *db_user;
char *db_password;
- int have_insert_id; /* do have insert_id() */
+ int have_insert_id; /* do have insert_id() */
int connected;
- char *errmsg; /* nicely edited error message */
- char *cmd; /* SQL command string */
+ char *errmsg; /* nicely edited error message */
+ char *cmd; /* SQL command string */
} B_DB;
#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) 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 /* USE BACULA DB routines */
/* Change this each time there is some incompatible
* file format change!!!!
*/
-#define BDB_VERSION 8 /* file version number */
+#define BDB_VERSION 8 /* 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 */
- 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 */
- char *errmsg; /* nicely edited error message */
- char *cmd; /* Command string */
+ BQUEUE bq; /* queue control */
+ pthread_mutex_t mutex; /* single thread 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 */
+ char *errmsg; /* nicely edited error message */
+ char *cmd; /* Command string */
} B_DB;
#endif /* HAVE_MYSQL */
#define DELETE_DB(db, cmd) DeleteDB(__FILE__, __LINE__, 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 */
/* ***FIXME*** FileId_t should be uint64_t */
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;
/* Job record */
typedef struct {
JobId_t JobId;
- char Job[MAX_NAME_LENGTH]; /* Job unique name */
- char Name[MAX_NAME_LENGTH]; /* Job base name */
- int Type; /* actually char(1) */
- int Level; /* actually char(1) */
- int JobStatus; /* actually char(1) */
- uint32_t ClientId; /* Id of client */
- uint32_t PoolId; /* Id of pool */
- uint32_t FileSetId; /* Id of FileSet */
- time_t SchedTime; /* Time job scheduled */
- time_t StartTime; /* Job start time */
- time_t EndTime; /* Job termination time */
- btime_t JobTDate; /* Backup time/date in seconds */
+ char Job[MAX_NAME_LENGTH]; /* Job unique name */
+ char Name[MAX_NAME_LENGTH]; /* Job base name */
+ int Type; /* actually char(1) */
+ int Level; /* actually char(1) */
+ int JobStatus; /* actually char(1) */
+ uint32_t ClientId; /* Id of client */
+ uint32_t PoolId; /* Id of pool */
+ uint32_t FileSetId; /* Id of FileSet */
+ time_t SchedTime; /* Time job scheduled */
+ time_t StartTime; /* Job start time */
+ time_t EndTime; /* Job termination time */
+ btime_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 */
typedef struct {
- uint32_t JobMediaId; /* record id */
- JobId_t JobId; /* JobId */
- uint32_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 */
+ uint32_t JobMediaId; /* record id */
+ JobId_t JobId; /* JobId */
+ uint32_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 */
} JOBMEDIA_DBR;
* records (e.g. pathname, filename, fileattributes).
*/
typedef struct {
- 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;
/* Pool record -- same format as database */
typedef struct {
uint32_t PoolId;
- char Name[MAX_NAME_LENGTH]; /* Pool name */
- uint32_t NumVols; /* total number of volumes */
- uint32_t MaxVols; /* max allowed volumes */
- int UseOnce; /* set to use once only */
- int UseCatalog; /* set to use catalog */
- int AcceptAnyVolume; /* set to accept any volume sequence */
- int AutoPrune; /* set to prune automatically */
- int Recycle; /* default Vol recycle flag */
- btime_t VolRetention; /* retention period in seconds */
- 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 */
+ int UseOnce; /* set to use once only */
+ int UseCatalog; /* set to use catalog */
+ int AcceptAnyVolume; /* set to accept any volume sequence */
+ int AutoPrune; /* set to prune automatically */
+ int Recycle; /* default Vol recycle flag */
+ btime_t VolRetention; /* retention period in seconds */
+ 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 */
typedef struct {
- uint32_t MediaId; /* Unique volume id */
+ uint32_t MediaId; /* Unique volume id */
char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
char MediaType[MAX_NAME_LENGTH]; /* Media type */
- uint32_t PoolId; /* Pool id */
- time_t FirstWritten; /* Time Volume first written */
- time_t LastWritten; /* Time Volume last written */
- time_t LabelDate; /* Date/Time Volume labelled */
- 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 VolMaxBytes; /* max bytes to write */
- uint64_t VolCapacityBytes; /* capacity estimate */
- btime_t VolRetention; /* Volume retention in seconds */
- int Recycle; /* recycle yes/no */
- char VolStatus[20]; /* Volume status */
+ uint32_t PoolId; /* Pool id */
+ time_t FirstWritten; /* Time Volume first written */
+ time_t LastWritten; /* Time Volume last written */
+ time_t LabelDate; /* Date/Time Volume labelled */
+ 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 VolMaxBytes; /* max bytes to write */
+ uint64_t VolCapacityBytes; /* capacity estimate */
+ btime_t VolRetention; /* Volume retention in seconds */
+ int Recycle; /* recycle yes/no */
+ char VolStatus[20]; /* Volume status */
/* Extra stuff not in DB */
- faddr_t rec_addr; /* found record address */
+ faddr_t rec_addr; /* found record address */
} MEDIA_DBR;
/* Client record -- same as the database */
typedef struct {
- uint32_t ClientId; /* Unique Client id */
+ uint32_t ClientId; /* Unique Client id */
int AutoPrune;
btime_t FileRetention;
btime_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 */
} CLIENT_DBR;
/* FileSet record -- same as the database */
typedef struct {
- uint32_t FileSetId; /* Unique FileSet id */
+ uint32_t FileSetId; /* Unique FileSet id */
char FileSet[MAX_NAME_LENGTH]; /* FileSet name */
- char MD5[50]; /* MD5 signature of include/exclude */
+ char MD5[50]; /* MD5 signature of include/exclude */
} FILESET_DBR;
* other files are generic.
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
+/*
+ *
+ * Version $Id$
+ */
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
int db_update_job_end_record(B_DB *db, JOB_DBR *jr);
int db_update_pool_record(B_DB *db, POOL_DBR *pr);
int db_update_media_record(B_DB *db, MEDIA_DBR *mr);
-int db_add_MD5_to_file_record(B_DB *mdb, FileId_t FileId, char *MD5);
+int db_add_MD5_to_file_record(B_DB *mdb, FileId_t FileId, char *MD5);
int db_mark_file_record(B_DB *mdb, FileId_t FileId, int JobId);
#endif /* __SQL_PROTOS_H */
* (with a little more work)
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
* Bacula Catalog Database Create record interface routines
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
* Bacula Catalog Database Delete record interface routines
*
* Kern Sibbald, December 2000
+ *
+ * Version $Id$
*/
/*
* request are in get.c
*
* Kern Sibbald, December 2000
+ *
+ * Version $Id$
*/
/*
* should be in find.c
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
* Bacula Catalog Database List records interface routines
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
* Bacula Catalog Database Update record interface routines
*
* Kern Sibbald, March 2000
+ *
+ * Version $Id$
*/
/*
* Bacula Catalog Database routines specific to SQLite
*
* Kern Sibbald, January 2002
+ *
+ * Version $Id$
*/
/*
+#
+# Version $Id$
+#
@MCOMMON@
srcdir = .
* Bacula Console interface to the Director
*
* Kern Sibbald, September MM
+ *
+ * Version $Id$
*/
/*
* Bacula User Agent specific configuration and defines
*
* Kern Sibbald, Sep MM
+ *
+ * Version $Id$
*/
/*
* Resource codes -- they must be sequential for indexing
*/
-#define R_FIRST 1001
+#define R_FIRST 1001
-#define R_CONSOLE 1001
-#define R_DIRECTOR 1002
+#define R_CONSOLE 1001
+#define R_DIRECTOR 1002
-#define R_LAST R_DIRECTOR
+#define R_LAST R_DIRECTOR
/*
* Some resource attributes
*/
-#define R_NAME 1020
-#define R_ADDRESS 1021
-#define R_PASSWORD 1022
-#define R_TYPE 1023
-#define R_BACKUP 1024
+#define R_NAME 1020
+#define R_ADDRESS 1021
+#define R_PASSWORD 1022
+#define R_TYPE 1023
+#define R_BACKUP 1024
/* Definition of the contents of each Resource */
/* Console "globals" */
struct s_res_cons {
- RES hdr;
- char *rc_file; /* startup file */
- char *hist_file; /* command history file */
+ RES hdr;
+ char *rc_file; /* startup file */
+ char *hist_file; /* command history file */
};
typedef struct s_res_cons CONSRES;
/* Director */
struct s_res_dir {
- RES hdr;
- int DIRport; /* UA server port */
- char *address; /* UA server address */
- char *password; /* UA server password */
+ RES hdr;
+ int DIRport; /* UA server port */
+ char *address; /* UA server address */
+ char *password; /* UA server password */
};
typedef struct s_res_dir DIRRES;
* resource structure definitions.
*/
union u_res {
- struct s_res_dir res_dir;
- struct s_res_cons res_cons;
+ struct s_res_dir res_dir;
+ struct s_res_cons res_cons;
RES hdr;
};
#
# Bacula Director Makefile
+#
+# Version $Id$
#
@MCOMMON@
dummy:
#
-SVRSRCS = dird.c authenticate.c backup.c \
+SVRSRCS = dird.c authenticate.c autoprune.c \
+ backup.c \
catreq.c dird_conf.c \
fd_cmds.c getmsg.c job.c \
mountreq.c msgchan.c newvol.c \
ua_purge.c ua_run.c \
ua_select.c ua_server.c \
ua_status.c verify.c
-SVROBJS = dird.o authenticate.o backup.o \
+SVROBJS = dird.o authenticate.o autoprune.o \
+ backup.o \
catreq.o dird_conf.o \
fd_cmds.o getmsg.o job.o \
mountreq.o msgchan.o newvol.o \
*
* This routine runs as a thread and must be thread reentrant.
*
- * Basic tasks done here:
+ * Version $Id$
*
*/
/*
* to do the backup.
* When the File daemon finishes the job, update the DB.
*
+ * Version $Id$
*/
/*
Volume Session Id: %d\n\
Volume Session Time: %d\n\
Volume Bytes: %s\n\
-Termination: %s\n"),
+Termination: %s\n\n"),
edt,
jcr->jr.JobId,
jcr->jr.Job,
* Basic tasks done here:
* Handle Catalog services.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Bacula Director daemon -- this is the main program
*
* Kern Sibbald, March MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Includes specific to the Director
*
* Kern Sibbald, December MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, January MM
*
- * $Id$
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Director specific configuration and defines
*
* Kern Sibbald, Feb MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/* Run structure contained in Schedule Resource */
struct s_run {
struct s_run *next; /* points to next run record */
- int level;
+ int level; /* level override */
int job_type;
+ POOL *pool; /* Pool override */
+ STORE *storage; /* Storage override */
+ MSGS *msgs; /* Messages override */
char *since;
int level_no;
int minute; /* minute to run job */
* Utility functions for sending info to File Daemon.
* These functions are used by both backup and verify.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Requests are any message that does not begin with a digit.
* In affect, they are commands.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Bacula Director Job processing routines
*
* Kern Sibbald, October MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
switch (jcr->JobType) {
case JT_BACKUP:
do_backup(jcr);
+ do_autoprune(jcr);
break;
case JT_VERIFY:
do_verify(jcr);
+ do_autoprune(jcr);
break;
case JT_RESTORE:
do_restore(jcr);
+ do_autoprune(jcr);
break;
case JT_ADMIN:
/* No actual job */
+ do_autoprune(jcr);
break;
default:
Dmsg1(0, "Unimplemented job type: %d\n", jcr->JobType);
* Set some defaults in the JCR necessary to
* run. These items are pulled from the job
* definition as defaults, but can be overridden
- * later.
+ * later either by the Run record in the Schedule resource,
+ * or by the Console program.
*/
void set_jcr_defaults(JCR *jcr, JOB *job)
{
* Basic tasks done here:
* Handle Mount services.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Create a thread to interact with the Storage daemon
* who returns a job status and requests Catalog services, etc.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* This routine runs as a thread and must be thread reentrant.
*
* Basic tasks done here:
- * If possible create a new Media entry
+ * If possible create a new Media entry
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
if (db_get_pool_record(jcr->db, &pr) && pr.LabelFormat[0] &&
pr.LabelFormat[0] != '*') {
if (pr.MaxVols == 0 || pr.NumVols < pr.MaxVols) {
- memset(&mr, 0, sizeof(mr));
- mr.PoolId = jcr->PoolId;
- strcpy(mr.MediaType, jcr->store->media_type);
- strcpy(name, pr.LabelFormat);
+ memset(&mr, 0, sizeof(mr));
+ mr.PoolId = jcr->PoolId;
+ strcpy(mr.MediaType, jcr->store->media_type);
+ strcpy(name, pr.LabelFormat);
strcat(name, "%04d");
- sprintf(mr.VolumeName, name, ++pr.NumVols);
+ sprintf(mr.VolumeName, name, ++pr.NumVols);
strcpy(mr.VolStatus, "Append");
- mr.Recycle = pr.Recycle;
- mr.VolRetention = pr.VolRetention;
- if (db_create_media_record(jcr->db, &mr) &&
- db_update_pool_record(jcr->db, &pr) == 1) {
+ mr.Recycle = pr.Recycle;
+ mr.VolRetention = pr.VolRetention;
+ if (db_create_media_record(jcr->db, &mr) &&
+ db_update_pool_record(jcr->db, &pr) == 1) {
Dmsg1(90, "Created new Volume=%s\n", mr.VolumeName);
- return 1;
- } else {
+ return 1;
+ } else {
Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
- }
+ }
}
}
return 0;
/*
* Director external function prototypes
*
- * $Id:
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
extern int authenticate_file_daemon(JCR *jcr);
extern int authenticate_user_agent(BSOCK *ua);
+/* autoprune.c */
+extern int do_autoprune(JCR *jcr);
+
+
/* catreq.c */
extern void catalog_request(JCR *jcr, BSOCK *bs, char *buf);
extern void catalog_update(JCR *jcr, BSOCK *bs, char *buf);
* to do the restore.
* Update the DB according to what files where restored????
*
+ * Version $Id$
*/
/*
update_job_end_record(jcr);
bstrftime(dt, sizeof(dt), jcr->jr.EndTime);
- Jmsg(jcr, M_INFO, 0, _("%s End Restore Job %s.\n"),
+ Jmsg(jcr, M_INFO, 0, _("%s End Restore Job %s.\n\n"),
dt, jcr->Job);
Dmsg0(20, "Leaving restore_cleanup\n");
* directives, which are part of the Schedule Resource
*
* Kern Sibbald, May MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
return TRUE;
}
+/* Keywords (RHS) permitted in Run records */
+static struct s_kw RunFields[] = {
+ {"pool", 'P'},
+ {"level", 'L'},
+ {"storage", 'S'},
+ {"messages", 'M'},
+ {NULL, 0}
+};
/*
* Store Schedule Run information
*/
void store_run(LEX *lc, struct res_items *item, int index, int pass)
{
- int token, state, state2, i, code, code2;
+ int i, j, found;
+ int token, state, state2, code, code2;
int options = lc->options;
RUN **run = (RUN **)(item->value);
RUN *trun;
char *p;
+ RES *res;
lc->options |= LOPT_NO_IDENT; /* want only "strings" */
memset(&lrun, 0, sizeof(RUN));
/* scan for Job level "full", "incremental", ... */
- token = lex_get_token(lc);
- if (token != T_STRING) {
- scan_err1(lc, _("Expected a Job level identifier, got: %s"), lc->str);
- } else {
- if (strcasecmp(lc->str, "level")) {
- if (lex_get_token(lc) != T_EQUALS) {
- scan_err1(lc, "Expected an equals, got: %s", lc->str);
- }
- token = lex_get_token(lc);
- }
- for (i=0; joblevels[i].level_name; i++) {
- if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
- lrun.level = joblevels[i].level;
- lrun.job_type = joblevels[i].job_type;
- i = 0;
- break;
- }
- }
- if (i != 0) {
- scan_err1(lc, _("Job level field: %s not found in run record"), lc->str);
+ for (found=TRUE; found; ) {
+ found = FALSE;
+ token = lex_get_token(lc);
+ if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
}
- }
+ for (i=0; RunFields[i].name; i++) {
+ if (strcasecmp(lc->str, RunFields[i].name) == 0) {
+ found = TRUE;
+ if (lex_get_token(lc) != T_EQUALS) {
+ scan_err1(lc, "Expected an equals, got: %s", lc->str);
+ }
+ token = lex_get_token(lc);
+ if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
+ }
+ switch (RunFields[i].token) {
+ case 'L': /* level */
+ for (j=0; joblevels[j].level_name; j++) {
+ if (strcasecmp(lc->str, joblevels[j].level_name) == 0) {
+ lrun.level = joblevels[j].level;
+ lrun.job_type = joblevels[j].job_type;
+ j = 0;
+ break;
+ }
+ }
+ if (j != 0) {
+ scan_err1(lc, _("Job level field: %s not found in run record"), lc->str);
+ }
+ break;
+ case 'P': /* Pool */
+ if (pass == 2) {
+ res = GetResWithName(R_POOL, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified Pool Resource: %s",
+ lc->str);
+ }
+ lrun.pool = (POOL *)res;
+ }
+ break;
+ case 'S': /* storage */
+ if (pass == 2) {
+ res = GetResWithName(R_STORAGE, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified Storage Resource: %s",
+ lc->str);
+ }
+ lrun.storage = (STORE *)res;
+ }
+ break;
+ case 'M': /* messages */
+ if (pass == 2) {
+ res = GetResWithName(R_MSGS, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified Messages Resource: %s",
+ lc->str);
+ }
+ lrun.msgs = (MSGS *)res;
+ }
+ break;
+ default:
+ scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
+ break;
+ } /* end switch */
+ } /* end if strcasecmp */
+ } /* end for RunFields */
+ } /* end for found */
+
/*
* Scan schedule times.
break;
}
/* everything else must be a keyword */
- lcase(lc->str);
for (i=0; keyw[i].name; i++) {
- if (strcmp(lc->str, keyw[i].name) == 0) {
+ if (strcasecmp(lc->str, keyw[i].name) == 0) {
state = keyw[i].state;
code = keyw[i].code;
i = 0;
* fire them up.
*
* Kern Sibbald, May MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
runjobs[jobindex].runtime = 0; /* remove from list */
run->last_run = now; /* mark as run */
rem_runjobs--; /* decrement count of remaining jobs */
+
jcr = new_jcr(sizeof(JCR), dird_free_jcr);
set_jcr_defaults(jcr, job);
- jcr->level = run->level; /* override run level */
+ if (run->level) {
+ jcr->level = run->level; /* override run level */
+ }
+ if (run->pool) {
+ jcr->pool = run->pool; /* override pool */
+ }
+ if (run->storage) {
+ jcr->store = run->storage; /* override storage */
+ }
+ if (run->msgs) {
+ jcr->msgs = run->msgs; /* override messages */
+ }
Dmsg0(200, "Leave wait_for_next_job()\n");
return jcr;
}
*
* Kern Sibbald, August MMI
*
- * $Id:
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*/
-#define MAX_ARGS 20
+#define MAX_ARGS 30
typedef struct s_ua_context {
BSOCK *UA_sock;
JCR *jcr;
B_DB *db;
CAT *catalog;
- char *cmd; /* return command/name buffer */
- char *args; /* command line arguments */
- char *argk[MAX_ARGS]; /* argument keywords */
- char *argv[MAX_ARGS]; /* argument values */
- int argc; /* number of arguments */
- char **prompt; /* list of prompts */
- int max_prompts; /* max size of list */
- int num_prompts; /* current number in list */
- int auto_display_messages; /* if set, display messages */
+ POOLMEM *cmd; /* return command/name buffer */
+ POOLMEM *args; /* command line arguments */
+ char *argk[MAX_ARGS]; /* argument keywords */
+ char *argv[MAX_ARGS]; /* argument values */
+ int argc; /* number of arguments */
+ char **prompt; /* list of prompts */
+ int max_prompts; /* max size of list */
+ int num_prompts; /* current number in list */
+ int auto_display_messages; /* if set, display messages */
int user_notified_msg_pending; /* set when user notified */
- int automount; /* if set, mount after label */
- int quit; /* if set, quit */
- int verbose; /* set for normal UA verbosity */
+ int automount; /* if set, mount after label */
+ int quit; /* if set, quit */
+ int verbose; /* set for normal UA verbosity */
} UAContext;
/* ua_cmds.c */
void start_prompt(UAContext *ua, char *msg);
void add_prompt(UAContext *ua, char *prompt);
int do_prompt(UAContext *ua, char *msg, char *prompt);
-CAT *get_catalog_resource(UAContext *ua);
+CAT *get_catalog_resource(UAContext *ua);
STORE *get_storage_resource(UAContext *ua, char *cmd);
int get_media_type(UAContext *ua, char *MediaType);
int get_pool_dbr(UAContext *ua, POOL_DBR *pr);
int find_arg_keyword(UAContext *ua, char **list);
int do_keyword_prompt(UAContext *ua, char *msg, char **list);
int confirm_retention(UAContext *ua, btime_t *ret, char *msg);
+
+/* ua_prune.c */
+int prune_files(UAContext *ua, CLIENT *client);
+int prune_jobs(UAContext *ua, CLIENT *client);
+int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
* Bacula Director -- User Agent Commands
*
* Kern Sibbald, September MM
+ *
+ * Version $Id$
*/
/*
free_jcr(jcr);
return 1;
- case JS_Running:
- case JS_WaitSD:
- case JS_WaitFD:
- case JS_WaitMedia:
- case JS_WaitMount:
- case JS_Blocked:
+ default:
jcr->JobStatus = JS_Cancelled;
/* Cancel File daemon */
bnet_close(sd);
ua->jcr->store_bsock = NULL;
- default:
- bsendmsg(ua, _("JobId %d Job %s Status=%c cannot be cancelled.\n"),
- jcr->JobId, jcr->Job, jcr->JobStatus);
}
free_jcr(jcr);
* returned results are (supposed to be) predictable.
*
* Kern Sibbald, April MMII
+ *
+ * Version $Id$
*/
/*
* Bacula Director -- User Agent Input and scanning code
*
* Kern Sibbald, October MMI
+ *
+ * Version $Id$
*/
/*
* I.e. messages, listing database, showing resources, ...
*
* Kern Sibbald, September MM
+ *
+ * Version $Id$
*/
/*
*
* Kern Sibbald, February MMII
*
- * $Id$
+ * Version $Id$
*/
/*
*
* Kern Sibbald, February MMII
*
- * $Id$
+ * Version $Id$
*/
/*
* Bacula Director -- Run Command
*
* Kern Sibbald, December MMI
+ *
+ * Version $Id$
*/
/*
*
* Kern Sibbald, October MMI
*
- * $Id$
+ * Version $Id$
*/
/*
* Bacula Director -- User Agent Server
*
* Kern Sibbald, September MM
+ *
+ * Version $Id$
*/
/*
memset(&ua, 0, sizeof(ua));
ua.automount = TRUE;
- ua.verbose = TRUE;
+ ua.verbose = 1;
ua.jcr = new_jcr(sizeof(JCR), dird_free_jcr);
ua.jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */
ua.UA_sock = UA_sock;
- ua.cmd = (char *) get_pool_memory(PM_FNAME);
- ua.args = (char *) get_pool_memory(PM_FNAME);
+ ua.cmd = get_pool_memory(PM_FNAME);
+ ua.args = get_pool_memory(PM_FNAME);
create_unique_job_name(ua.jcr, "*Console*");
ua.jcr->sched_time = ua.jcr->start_time;
* Bacula Director -- User Agent Status Command
*
* Kern Sibbald, August MMI
+ *
+ * Version $Id$
*/
/*
* When the File daemon sends the attributes, compare them to
* what is in the DB.
*
+ * Version $Id$
*/
/*
Start time: %s\n\
End time: %s\n\
Files Examined: %s\n\
-Termination: %s\n"),
+Termination: %s\n\n"),
edt,
jcr->jr.JobId,
jcr->jr.Job,
* Authenticate Director who is attempting to connect.
*
* Kern Sibbald, October 2000
+ *
+ * Version $Id$
*
*/
/*
*
* Kern Sibbald, March MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, September MMI
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, March MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Bacula File Daemon specific configuration and defines
*
* Kern Sibbald, Jan MMI
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#include "protos.h" /* file daemon prototypes */
#include "filed_conf.h"
#ifdef HAVE_LIBZ
-#include <zlib.h> /* compression headers */
+#include <zlib.h> /* compression headers */
#else
#define uLongf uint32_t
#endif
-extern int win32_client; /* Are we running on Windows? */
+extern int win32_client; /* Are we running on Windows? */
* for the resource records.
*
* Kern Sibbald, September MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Bacula File Daemon specific configuration
*
* Kern Sibbald, Sep MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/*
* Resource codes -- they must be sequential for indexing
*/
-#define R_FIRST 1001
+#define R_FIRST 1001
-#define R_DIRECTOR 1001
-#define R_CLIENT 1002
-#define R_MSGS 1003
+#define R_DIRECTOR 1001
+#define R_CLIENT 1002
+#define R_MSGS 1003
-#define R_LAST R_MSGS
+#define R_LAST R_MSGS
/*
* Some resource attributes
*/
-#define R_NAME 1020
-#define R_ADDRESS 1021
-#define R_PASSWORD 1022
-#define R_TYPE 1023
+#define R_NAME 1020
+#define R_ADDRESS 1021
+#define R_PASSWORD 1022
+#define R_TYPE 1023
/* Definition of the contents of each Resource */
struct s_res_dir {
- RES hdr;
- char *password; /* Director password */
- char *address; /* Director address or zero */
+ RES hdr;
+ char *password; /* Director password */
+ char *address; /* Director address or zero */
};
typedef struct s_res_dir DIRRES;
struct s_res_client {
- RES hdr;
- int FDport; /* where we listen for Directors */
+ RES hdr;
+ int FDport; /* where we listen for Directors */
char *working_directory;
char *pid_directory;
char *subsys_directory;
* resource structure definitions.
*/
union u_res {
- struct s_res_dir res_dir;
- struct s_res_client res_client;
- struct s_res_msgs res_msgs;
+ struct s_res_dir res_dir;
+ struct s_res_client res_client;
+ struct s_res_msgs res_msgs;
RES hdr;
};
*
* Kern Sibbald, October MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+/*
+ * Version $Id$
+ */
+
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
extern int authenticate_director(JCR *jcr);
extern int authenticate_storagedaemon(JCR *jcr);
extern int make_estimate(JCR *jcr);
-
*
* Kern Sibbald, November MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, August MMI
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, October MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, Nov MM
*
+ * Version $Id$
*/
/*
- Copyright (C) 2000, 2001 Kern Sibbald and John Walker
+ Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
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 the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
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.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __JCR_H_
Error checking memory allocator
+ Version $Id$
*/
/*
* Generic base 64 input and output routines
*
* Written by Kern E. Sibbald, March MM.
+ *
+ * Version $Id$
*/
/*
* Kern Sibbald, MM
*
* NOTE: base 0
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Adapted and enhanced for Bacula, originally written
* for inclusion in the Apcupsd package
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
bs->msglen = bvsnprintf(bs->msg, maxlen, fmt, arg_ptr);
va_end(arg_ptr);
if (bs->msglen < 0 || bs->msglen >= maxlen) {
- bs->msg = (char *) realloc_pool_memory(bs->msg, maxlen + 200);
+ bs->msg = (POOLMEM *)realloc_pool_memory(bs->msg, maxlen + 200);
goto again;
}
return bnet_send(bs) < 0 ? 0 : 1;
BSOCK *
init_bsock(int sockfd, char *who, char *host, int port)
{
- BSOCK *bsock = (BSOCK *) malloc(sizeof(BSOCK));
+ BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
if (bsock == NULL) {
Emsg0(M_ABORT, 0, "Out of memory in init_bsock.\n");
}
memset(bsock, 0, sizeof(BSOCK));
bsock->fd = sockfd;
bsock->errors = 0;
- bsock->msg = (char *) get_pool_memory(PM_MESSAGE);
+ bsock->msg = (POOLMEM *)get_pool_memory(PM_MESSAGE);
+ bsock->errmsg = (POOLMEM *)get_pool_memory(PM_MESSAGE);
bsock->who = bstrdup(who);
bsock->host = bstrdup(host);
bsock->port = port;
Emsg0(M_ABORT, 0, "Out of memory in dup_bsock.\n");
}
memcpy(bsock, osock, sizeof(BSOCK));
- bsock->msg = (char *) get_pool_memory(PM_MESSAGE);
+ bsock->msg = (POOLMEM *)get_pool_memory(PM_MESSAGE);
+ bsock->errmsg = (POOLMEM *)get_pool_memory(PM_MESSAGE);
bsock->duped = TRUE;
return bsock;
}
term_bsock(BSOCK *bsock)
{
free_pool_memory(bsock->msg);
+ free_pool_memory(bsock->errmsg);
free(bsock->who);
free(bsock->host);
free(bsock);
*/
/*
- * Originally written by Kern Sibbald for inclusion in apcupsd.
+ * Originally written by Kern Sibbald for inclusion in apcupsd,
+ * but heavily modified for Bacula
+ *
+ * Version $Id$
*/
#include "bacula.h"
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(port);
+ int tmax = 30 * (60 / 5); /* wait 30 minutes max */
for (tlog=0; bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0; tlog -= 5 ) {
if (tlog <= 0) {
tlog = 2*60; /* Complain every 2 minutes */
Emsg2(M_WARNING, 0, "Cannot bind port %d: %s. Retrying ...\n", port, strerror(errno));
}
sleep(5);
+ if (--tmax <= 0) {
+ Emsg2(M_ABORT, 0, "Cannot bind port %d: %s.\n", port, strerror(errno));
+ }
}
listen(sockfd, 5); /* tell system we are ready */
}
+#ifdef REALLY_USED
/*
* Bind an address so that we may accept connections
* one at a time.
}
}
+#endif
* The following code will soon be deleted, don't attempt
* to use it.
*/
-#ifdef dont_have_threads_junk
+#ifdef dont_have_threads
/*
* This routine is called by the main process to
*
* By Kern Sibbald, May MM
*
+ * Version $Id$
+ *
* Note, this routine was originally written so that the DEVICE structures
* could be shared between the child processes. Now that the Storage
* daemon is threaded, these routines are no longer needed. Rather than
*
* Kern Sibbald, May MM
*
- * NB: these items are deprecated. Shared memory was
- * used in a first version of the Storage daemon
- * when it forked. Since then it has been converted
- * to use threads. However, there are still some
- * vestiges of the shared memory code that remain and
- * can be removed.
+ * NB: these items are deprecated. Shared memory was
+ * used in a first version of the Storage daemon
+ * when it forked. Since then it has been converted
+ * to use threads. However, there are still some
+ * vestiges of the shared memory code that remain and
+ * can be removed.
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*/
typedef struct s_bshm {
- int size; /* length desired */
- int perms; /* permissions desired */
+ int size; /* length desired */
+ int perms; /* permissions desired */
- int shmid; /* id set by shm_create and shm_open */
- key_t shmkey; /* key set by shm_create */
- void *shmbuf; /* set by shm_open */
+ int shmid; /* id set by shm_create and shm_open */
+ key_t shmkey; /* key set by shm_create */
+ void *shmbuf; /* set by shm_open */
} BSHM;
* Negative msglen, is special "signal" (no data follows).
* See below for SIGNAL codes.
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
int timeout; /* time out after this value */
int terminated; /* set when BNET_TERMINATE arrives */
int duped; /* set if duped BSOCK */
- char *msg; /* message pool buffer */
+ POOLMEM *msg; /* message pool buffer */
char *who; /* Name of daemon to which we are talking */
char *host; /* Host name/IP */
- char *errmsg; /* edited error message (to be implemented) */
+ POOLMEM *errmsg; /* edited error message (to be implemented) */
RES *res; /* Resource to which we are connected */
struct s_bsock *next; /* next BSOCK if duped */
} BSOCK;
/*
* Bacula time and date routines -- John Walker
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
-/* Time and date structures and functions.
+/*
+
+ Time and date structures and functions.
Date and time are always represented internally
as 64 bit floating point Julian day numbers and
fraction. The day number and fraction are kept
as separate quantities to avoid round-off of
- day fraction. John Walker */
+ day fraction. John Walker
+
+ Version $Id$
+
+ */
+
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* cram-md5 is based on RFC2104.
*
* Written for Bacula by Kern E. Sibbald, May MMI.
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* By Kern Sibbald, January 2001
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/*
* daemon.c by Kern Sibbald
*
+ * Version $Id$
+ *
* this code is inspired by the Prentice Hall book
* "Unix Network Programming" by W. Richard Stevens
* and later updated from his book "Advanced Programming
*
* Kern Sibbald, August MMI
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* hmac_md5 was based on sample code in RFC2104 (thanks guys).
*
* Adapted to Bacula by Kern E. Sibbald, February MMI.
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern E. Sibbald, December 2000
*
+ * Version $Id$
+ *
* These routines are thread safe.
*
*/
/*
* Lexical scanner for Bacula configuration file
*
+ * Version $Id$
+ *
*/
/*
/*
* lex.h
*
- * Lexial scanning of configuration files, used by parsers.
+ * Lexical scanning of configuration files, used by parsers.
*
* Kern Sibbald, MM
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#define _LEX_H
/* Lex get_char() return values */
-#define L_EOF (-1)
-#define L_EOL (-2)
+#define L_EOF (-1)
+#define L_EOL (-2)
/* Internal tokens */
-#define T_NONE 100
+#define T_NONE 100
/* Tokens returned by get_token() */
-#define T_EOF 101
-#define T_NUMBER 102
-#define T_IPADDR 103
-#define T_IDENTIFIER 104
-#define T_STRING 105
-#define T_QUOTED_STRING 106
-#define T_BOB 108 /* begin block */
-#define T_EOB 109 /* end of block */
-#define T_EQUALS 110
-#define T_COMMA 111
-#define T_EOL 112
-#define T_SEMI 113
-#define T_ERROR 200
+#define T_EOF 101
+#define T_NUMBER 102
+#define T_IPADDR 103
+#define T_IDENTIFIER 104
+#define T_STRING 105
+#define T_QUOTED_STRING 106
+#define T_BOB 108 /* begin block */
+#define T_EOB 109 /* end of block */
+#define T_EQUALS 110
+#define T_COMMA 111
+#define T_EOL 112
+#define T_SEMI 113
+#define T_ERROR 200
/* Lexical state */
enum lex_state {
};
/* Lex scan options */
-#define LOPT_NO_IDENT 0x1 /* No Identifiers -- use string */
+#define LOPT_NO_IDENT 0x1 /* No Identifiers -- use string */
/* Lexical context */
typedef struct s_lex_context {
- int options; /* scan options */
- char *fname; /* filename */
- FILE *fd; /* file descriptor */
- char line[MAXSTRING]; /* input line */
- char str[MAXSTRING]; /* string being scanned */
- int str_len; /* length of string */
- int line_no; /* file line number */
- int col_no; /* char position on line */
- enum lex_state state; /* lex_state variable */
- int ch; /* last char/L_VAL returned by get_char */
+ int options; /* scan options */
+ char *fname; /* filename */
+ FILE *fd; /* file descriptor */
+ char line[MAXSTRING]; /* input line */
+ char str[MAXSTRING]; /* string being scanned */
+ int str_len; /* length of string */
+ int line_no; /* file line number */
+ int col_no; /* char position on line */
+ enum lex_state state; /* lex_state variable */
+ int ch; /* last char/L_VAL returned by get_char */
int token;
- struct s_lex_context *next; /* pointer to next lexical context */
+ struct s_lex_context *next; /* pointer to next lexical context */
} LEX;
#endif /* _LEX_H */
/*
* Library includes for Bacula lib directory
+ *
+ * Version $Id$
*/
/*
#include "md5.h"
#include "protos.h"
-
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
+ *
+ * Version $Id$
*/
/* Brutally hacked by John Walker back from ANSI C to K&R (no
* Bacula MD5 definitions
*
* Kern Sibbald, 2001
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* with the desired size and it will adjust only if necessary.
*
* Kern E. Sibbald
+ *
+ * Version $Id$
*/
/*
* Memory Pool prototypes
*
* Kern Sibbald, 2000
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#define free_memory(x) free_pool_memory(x)
extern void free_pool_memory(POOLMEM *buf);
extern size_t sizeof_pool_memory(POOLMEM *buf);
-extern POOLMEM *realloc_pool_memory(POOLMEM *buf, size_t size);
-extern POOLMEM *check_pool_memory_size(POOLMEM *buf, size_t size);
+extern POOLMEM *realloc_pool_memory(POOLMEM *buf, size_t size);
+extern POOLMEM *check_pool_memory_size(POOLMEM *buf, size_t size);
extern void close_memory_pool();
extern void print_memory_pool_stats();
-#define PM_NOPOOL 0 /* nonpooled memory */
-#define PM_FNAME 1 /* file name buffer */
-#define PM_MESSAGE 2 /* daemon message */
-#define PM_EMSG 3 /* error message */
-#define PM_MAX PM_EMSG /* Number of types */
+#define PM_NOPOOL 0 /* nonpooled memory */
+#define PM_FNAME 1 /* file name buffer */
+#define PM_MESSAGE 2 /* daemon message */
+#define PM_EMSG 3 /* error message */
+#define PM_MAX PM_EMSG /* Number of types */
*
* Kern Sibbald, April 2000
*
+ * Version $Id$
+ *
*/
/*
/*
* Define Message Types for Bacula
* Kern Sibbald, 2000
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#include "bits.h"
-#undef M_DEBUG
-#undef M_ABORT
-#undef M_FATAL
-#undef M_ERROR
-#undef M_WARNING
-#undef M_INFO
-#undef M_MOUNT
-#undef M_TERM
+#undef M_DEBUG
+#undef M_ABORT
+#undef M_FATAL
+#undef M_ERROR
+#undef M_WARNING
+#undef M_INFO
+#undef M_MOUNT
+#undef M_TERM
-#define M_DEBUG 1 /* debug message */
-#define M_ABORT 2 /* MUST abort immediately */
-#define M_FATAL 3 /* Fatal error, stopping job */
-#define M_ERROR 4 /* Error, but recoverable */
-#define M_WARNING 5 /* Warning message */
-#define M_INFO 6 /* Informational message */
-#define M_SAVED 7 /* Info on saved file */
-#define M_NOTSAVED 8 /* Info on notsaved file */
-#define M_SKIPPED 9 /* File skipped by option setting */
-#define M_MOUNT 10 /* Mount requests */
-#define M_TERM 11 /* Termination request */
+#define M_DEBUG 1 /* debug message */
+#define M_ABORT 2 /* MUST abort immediately */
+#define M_FATAL 3 /* Fatal error, stopping job */
+#define M_ERROR 4 /* Error, but recoverable */
+#define M_WARNING 5 /* Warning message */
+#define M_INFO 6 /* Informational message */
+#define M_SAVED 7 /* Info on saved file */
+#define M_NOTSAVED 8 /* Info on notsaved file */
+#define M_SKIPPED 9 /* File skipped by option setting */
+#define M_MOUNT 10 /* Mount requests */
+#define M_TERM 11 /* Termination request */
-#define M_MAX M_TERM /* keep this updated ! */
+#define M_MAX M_TERM /* keep this updated ! */
/* Define message destination structure */
/* *** FIXME **** where should be extended to handle multiple values */
typedef struct s_dest {
struct s_dest *next;
- int dest_code; /* destination (one of the MD_ codes) */
- int max_len; /* max mail line length */
- FILE *fd; /* file descriptor */
+ int dest_code; /* destination (one of the MD_ codes) */
+ int max_len; /* max mail line length */
+ FILE *fd; /* file descriptor */
char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
- char *where; /* filename/program name */
- char *mail_cmd; /* mail command */
- char *mail_filename; /* unique mail filename */
+ char *where; /* filename/program name */
+ char *mail_cmd; /* mail command */
+ char *mail_filename; /* unique mail filename */
} DEST;
/* Message Destination values for dest field of DEST */
-#define MD_SYSLOG 1 /* send msg to syslog */
-#define MD_MAIL 2 /* email group of messages */
-#define MD_FILE 3 /* write messages to a file */
-#define MD_APPEND 4 /* append messages to a file */
-#define MD_STDOUT 5 /* print messages */
-#define MD_STDERR 6 /* print messages to stderr */
-#define MD_DIRECTOR 7 /* send message to the Director */
-#define MD_OPERATOR 8 /* email a single message to the operator */
-#define MD_CONSOLE 9 /* send msg to UserAgent or console */
-#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */
+#define MD_SYSLOG 1 /* send msg to syslog */
+#define MD_MAIL 2 /* email group of messages */
+#define MD_FILE 3 /* write messages to a file */
+#define MD_APPEND 4 /* append messages to a file */
+#define MD_STDOUT 5 /* print messages */
+#define MD_STDERR 6 /* print messages to stderr */
+#define MD_DIRECTOR 7 /* send message to the Director */
+#define MD_OPERATOR 8 /* email a single message to the operator */
+#define MD_CONSOLE 9 /* send msg to UserAgent or console */
+#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */
void d_msg(char *file, int line, int level, char *fmt,...);
* for the resource records.
*
* Kern Sibbald, January MM
+ *
+ * Version $Id$
*/
/*
+/*
+ * Version $Id$
+ */
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*/
-struct res_items; /* Declare forward referenced structure */
+struct res_items; /* Declare forward referenced structure */
typedef void (MSG_RES_HANDLER)(LEX *lc, struct res_items *item, int index, int pass);
/* This is the structure that defines
* tables.
*/
struct res_items {
- char *name; /* Resource name i.e. Director, ... */
- MSG_RES_HANDLER *handler; /* Routine storing the resource item */
- void **value; /* Where to store the item */
- int code; /* item code/additional info */
- int flags; /* flags: default, required, ... */
- int default_value; /* default value */
+ char *name; /* Resource name i.e. Director, ... */
+ MSG_RES_HANDLER *handler; /* Routine storing the resource item */
+ void **value; /* Where to store the item */
+ int code; /* item code/additional info */
+ int flags; /* flags: default, required, ... */
+ int default_value; /* default value */
};
/* For storing name_addr items in res_items table */
#define ITEM(x) ((void **)&res_all.x)
-#define MAX_RES_ITEMS 32 /* maximum resource items per RES */
+#define MAX_RES_ITEMS 32 /* maximum resource items per RES */
/* This is the universal header that is
* at the beginning of every resource
* record.
*/
struct s_reshdr {
- char *name; /* resource name */
- char *desc; /* resource description */
- int rcode; /* resource id or type */
- int refcnt; /* reference count for releasing */
+ char *name; /* resource name */
+ char *desc; /* resource description */
+ int rcode; /* resource id or type */
+ int refcnt; /* reference count for releasing */
char item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
- struct s_reshdr *next; /* pointer to next resource of this type */
+ struct s_reshdr *next; /* pointer to next resource of this type */
};
typedef struct s_reshdr RES;
* This is the structure that defines the
* resources that are available to this daemon.
*/
-struct s_res {
- char *name; /* resource name */
- struct res_items *items; /* list of resource keywords */
- int rcode; /* code if needed */
- RES *res_head; /* where to store it */
+struct s_res {
+ char *name; /* resource name */
+ struct res_items *items; /* list of resource keywords */
+ int rcode; /* code if needed */
+ RES *res_head; /* where to store it */
};
/* Common Resource definitions */
-#define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */
+#define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */
-#define ITEM_REQUIRED 0x1 /* item required */
-#define ITEM_DEFAULT 0x2 /* default supplied */
+#define ITEM_REQUIRED 0x1 /* item required */
+#define ITEM_DEFAULT 0x2 /* default supplied */
/* Message Resource */
struct s_res_msgs {
- RES hdr;
- char *mail_cmd; /* mail command */
- char *operator_cmd; /* Operator command */
- DEST *dest_chain; /* chain of destinations */
+ RES hdr;
+ char *mail_cmd; /* mail command */
+ char *operator_cmd; /* Operator command */
+ DEST *dest_chain; /* chain of destinations */
char send_msg[nbytes_for_bits(M_MAX+1)]; /* bit array of types */
};
typedef struct s_res_msgs MSGS;
* resource structure definitions.
*/
union cu_res {
- struct s_res_msgs res_msgs;
+ struct s_res_msgs res_msgs;
RES hdr;
};
/* Configuration routines */
-void parse_config __PROTO((char *cf));
+void parse_config __PROTO((char *cf));
void free_config_resources __PROTO(());
/* Resource routines */
/*
* Prototypes for lib directory of Bacula
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
Q U E U E
Queue Handling Routines
- Taken from smartall by John Walker.
+ Taken from smartall written by John Walker.
http://www.fourmilab.ch/smartall/
+
+ Version $Id$
+
*/
/*
+/*
+ * Version $Id$
+ */
+
+
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/* General purpose queue */
struct b_queue {
- struct b_queue *qnext, /* Next item in queue */
- *qprev; /* Previous item in queue */
+ struct b_queue *qnext, /* Next item in queue */
+ *qprev; /* Previous item in queue */
};
typedef struct b_queue BQUEUE;
/* Queue functions */
-void qinsert(BQUEUE *qhead, BQUEUE *object);
+void qinsert(BQUEUE *qhead, BQUEUE *object);
BQUEUE *qnext(BQUEUE *qhead, BQUEUE *qitem);
BQUEUE *qdchain(BQUEUE *qitem);
BQUEUE *qremove(BQUEUE *qhead);
*
* Kern Sibbald, January MMI
*
+ * Version $Id$
+ *
* This code adapted from "Programming with POSIX Threads", by
* David R. Butenhof
*
/*
* Bacula Thread Read/Write locking code. It permits
- * multiple readers but only one writer.
+ * multiple readers but only one writer.
*
* Kern Sibbald, January MMI
*
* This code adapted from "Programming with POSIX Threads", by
* David R. Butenhof
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
typedef struct rwlock_tag {
pthread_mutex_t mutex;
- pthread_cond_t read; /* wait for read */
- pthread_cond_t write; /* wait for write */
- int valid; /* set when valid */
- int r_active; /* readers active */
- int w_active; /* writers active */
- int r_wait; /* readers waiting */
- int w_wait; /* writers waiting */
+ pthread_cond_t read; /* wait for read */
+ pthread_cond_t write; /* wait for write */
+ int valid; /* set when valid */
+ int r_active; /* readers active */
+ int w_active; /* writers active */
+ int r_wait; /* readers waiting */
+ int w_wait; /* writers waiting */
} rwlock_t;
#define RWLOCK_VALID 0xfacade
Serialisation Support Functions
John Walker
+
+ Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
-
+/*
+ *
+ * Version $Id$
+ */
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/*
- Serialisation Macros
+ Serialisation Macros
These macros use a uint8_t pointer, ser_ptr, which must be
defined by the code which uses them.
#define __SERIAL_H_ 1
/* ser_declare -- Declare ser_ptr locally within a function. */
-#define ser_declare uint8_t *ser_ptr
-#define unser_declare uint8_t *ser_ptr
+#define ser_declare uint8_t *ser_ptr
+#define unser_declare uint8_t *ser_ptr
/* ser_begin(x, s) -- Begin serialisation into a buffer x of size s. */
#define ser_begin(x, s) ser_ptr = ((uint8_t *)(x))
#define unser_begin(x, s) ser_ptr = ((uint8_t *)(x))
-/* ser_length -- Determine length in bytes of serialised into a
- buffer x. */
+/* ser_length -- Determine length in bytes of serialised into a
+ buffer x. */
#define ser_length(x) (ser_ptr - (uint8_t *)(x))
#define unser_length(x) (ser_ptr - (uint8_t *)(x))
/* ser_end(x, s) -- End serialisation into a buffer x of size s. */
-#define ser_end(x, s) ASSERT(ser_length(x) <= (s))
+#define ser_end(x, s) ASSERT(ser_length(x) <= (s))
#define unser_end(x, s) ASSERT(ser_length(x) <= (s))
/* ser_check(x, s) -- Verify length of serialised data in buffer x is
- expected length s. */
+ expected length s. */
#define ser_check(x, s) ASSERT(ser_length(x) == (s))
-/* Serialisation */
+/* Serialisation */
/* 8 bit signed integer */
-#define ser_int8(x) *ser_ptr++ = (x)
+#define ser_int8(x) *ser_ptr++ = (x)
/* 8 bit unsigned integer */
-#define ser_uint8(x) *ser_ptr++ = (x)
+#define ser_uint8(x) *ser_ptr++ = (x)
/* 16 bit signed integer */
-#define ser_int16(x) serial_int16(&ser_ptr, x)
+#define ser_int16(x) serial_int16(&ser_ptr, x)
/* 16 bit unsigned integer */
-#define ser_uint16(x) serial_uint16(&ser_ptr, x)
+#define ser_uint16(x) serial_uint16(&ser_ptr, x)
/* 32 bit signed integer */
-#define ser_int32(x) serial_int32(&ser_ptr, x)
+#define ser_int32(x) serial_int32(&ser_ptr, x)
/* 32 bit unsigned integer */
-#define ser_uint32(x) serial_uint32(&ser_ptr, x)
+#define ser_uint32(x) serial_uint32(&ser_ptr, x)
/* 64 bit signed integer */
-#define ser_int64(x) serial_int64(&ser_ptr, x)
+#define ser_int64(x) serial_int64(&ser_ptr, x)
/* 64 bit unsigned integer */
-#define ser_uint64(x) serial_uint64(&ser_ptr, x)
+#define ser_uint64(x) serial_uint64(&ser_ptr, x)
/* 64 bit IEEE floating point number */
-#define ser_float64(x) serial_float64(&ser_ptr, x)
+#define ser_float64(x) serial_float64(&ser_ptr, x)
/* 128 bit signed integer */
-#define ser_int128(x) memcpy(ser_ptr, x, sizeof(int128_t)), ser_ptr += sizeof(int128_t)
+#define ser_int128(x) memcpy(ser_ptr, x, sizeof(int128_t)), ser_ptr += sizeof(int128_t)
/* Binary byte stream len bytes not requiring serialisation */
#define ser_bytes(x, len) memcpy(ser_ptr, (x), (len)), ser_ptr += (len)
-/* Binary byte stream not requiring serialisation (length obtained by sizeof) */
-#define ser_buffer(x) ser_bytes((x), (sizeof (x)))
+/* Binary byte stream not requiring serialisation (length obtained by sizeof) */
+#define ser_buffer(x) ser_bytes((x), (sizeof (x)))
/* Binary string not requiring serialization */
-#define ser_string(x) ser_ptr += serial_string(ser_ptr, (x))
+#define ser_string(x) ser_ptr += serial_string(ser_ptr, (x))
-/* Unserialisation */
+/* Unserialisation */
/* 8 bit signed integer */
-#define unser_int8(x) (x) = *ser_ptr++
+#define unser_int8(x) (x) = *ser_ptr++
/* 8 bit unsigned integer */
-#define unser_uint8(x) (x) = *ser_ptr++
+#define unser_uint8(x) (x) = *ser_ptr++
/* 16 bit signed integer */
-#define unser_int16(x) (x) = unserial_int16(&ser_ptr)
+#define unser_int16(x) (x) = unserial_int16(&ser_ptr)
/* 16 bit unsigned integer */
#define unser_uint16(x) (x) = unserial_uint16(&ser_ptr)
/* 32 bit signed integer */
-#define unser_int32(x) (x) = unserial_int32(&ser_ptr)
+#define unser_int32(x) (x) = unserial_int32(&ser_ptr)
/* 32 bit unsigned integer */
#define unser_uint32(x) (x) = unserial_uint32(&ser_ptr)
/* 64 bit signed integer */
-#define unser_int64(x) (x) = unserial_int64(&ser_ptr)
+#define unser_int64(x) (x) = unserial_int64(&ser_ptr)
/* 64 bit unsigned integer */
#define unser_uint64(x) (x) = unserial_uint64(&ser_ptr)
/* Binary byte stream len bytes not requiring serialisation */
#define unser_bytes(x, len) memcpy((x), ser_ptr, (len)), ser_ptr += (len)
-/* Binary byte stream not requiring serialisation (length obtained by sizeof) */
+/* Binary byte stream not requiring serialisation (length obtained by sizeof) */
#define unser_buffer(x) unser_bytes((x), (sizeof (x)))
/* Binary string not requiring serialization */
* Signal handlers for Bacula daemons
*
* Kern Sibbald, April 2000
+ *
+ * Version $Id$
*
* Note, we probably should do a core dump for the serious
* signals such as SIGBUS, SIGPFE, ...
http://www.fourmilab.ch/smartall/
+
+ Version $Id$
+
*/
/*
/*
- Definitions for the smart memory allocator
+ Definitions for the smart memory allocator
+
+ Version $Id$
*/
typedef enum {False = 0, True = 1} Boolean;
extern void *sm_malloc(char *fname, int lineno, unsigned int nbytes),
- *sm_calloc(char *fname, int lineno,
- unsigned int nelem, unsigned int elsize),
- *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size),
- *actuallymalloc(unsigned int size),
- *actuallycalloc(unsigned int nelem, unsigned int elsize),
- *actuallyrealloc(void *ptr, unsigned int size);
+ *sm_calloc(char *fname, int lineno,
+ unsigned int nelem, unsigned int elsize),
+ *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size),
+ *actuallymalloc(unsigned int size),
+ *actuallycalloc(unsigned int nelem, unsigned int elsize),
+ *actuallyrealloc(void *ptr, unsigned int size);
extern void sm_free(char *fname, int lineno, void *fp);
extern void actuallyfree(void *cp),
- sm_dump(Boolean bufdump), sm_static(int mode);
+ sm_dump(Boolean bufdump), sm_static(int mode);
extern void sm_new_owner(char *fname, int lineno, char *buf);
#ifdef SMCHECK
#define sm_check_rtn(f, l, fl) 1
extern void *b_malloc();
-#define malloc(x) b_malloc(__FILE__, __LINE__, (x))
+#define malloc(x) b_malloc(__FILE__, __LINE__, (x))
#endif
* util.c miscellaneous utility subroutines for Bacula
*
* Kern Sibbald, MM
+ *
+ * Version $Id$
*/
/*
* This code inspired from "Programming with POSIX Threads", by
* David R. Butenhof
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*/
typedef struct waitq_ele_tag {
struct waitq_ele_tag *next;
- int done_flag; /* predicate for wait */
- pthread_cont_t done; /* wait for completion */
- void *msg; /* message to be passed */
+ int done_flag; /* predicate for wait */
+ pthread_cont_t done; /* wait for completion */
+ void *msg; /* message to be passed */
} waitq_ele_t;
/*
* Structure describing a wait queue
*/
typedef struct workq_tag {
- pthread_mutex_t mutex; /* queue access control */
- pthread_cond_t wait_req; /* wait for OK */
- int num_msgs; /* number of waiters */
- waitq_ele_t *first; /* wait queue first item */
- waitq_ele_t *last; /* wait queue last item */
+ pthread_mutex_t mutex; /* queue access control */
+ pthread_cond_t wait_req; /* wait for OK */
+ int num_msgs; /* number of waiters */
+ waitq_ele_t *first; /* wait queue first item */
+ waitq_ele_t *last; /* wait queue last item */
} workq_t;
extern int waitq_init(waitq_t *wq);
*
* Kern Sibbald, January MMI
*
+ * Version $Id$
+ *
* This code adapted from "Programming with POSIX Threads", by
* David R. Butenhof
*
* This code adapted from "Programming with POSIX Threads", by
* David R. Butenhof
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*/
typedef struct workq_ele_tag {
struct workq_ele_tag *next;
- void *data;
+ void *data;
} workq_ele_t;
/*
* Structure describing a work queue
*/
typedef struct workq_tag {
- pthread_mutex_t mutex; /* queue access control */
- pthread_cond_t work; /* wait for work */
- pthread_attr_t attr; /* create detached threads */
- workq_ele_t *first, *last; /* work queue */
- int valid; /* queue initialized */
- int quit; /* workq should quit */
- int max_workers; /* max threads */
- int num_workers; /* current threads */
- int idle_workers; /* idle threads */
- void (*engine)(void *arg); /* user engine */
+ pthread_mutex_t mutex; /* queue access control */
+ pthread_cond_t work; /* wait for work */
+ pthread_attr_t attr; /* create detached threads */
+ workq_ele_t *first, *last; /* work queue */
+ int valid; /* queue initialized */
+ int quit; /* workq should quit */
+ int max_workers; /* max threads */
+ int num_workers; /* current threads */
+ int idle_workers; /* idle threads */
+ void (*engine)(void *arg); /* user engine */
} workq_t;
#define WORKQ_VALID 0xdec1992
extern int workq_init(
- workq_t *wq,
- int threads, /* maximum threads */
- void (*engine)(void *) /* engine routine */
- );
+ workq_t *wq,
+ int threads, /* maximum threads */
+ void (*engine)(void *) /* engine routine */
+ );
extern int workq_destroy(workq_t *wq);
extern int workq_add(workq_t *wq, void *data);
/*
* Append code for Storage daemon
* Kern Sibbald, May MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Reqests/commands from the Director are handled in dircmd.c
*
* Kern Sibbald, December 2000
- *
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Authenticate caller
*
* Kern Sibbald, October 2000
+ *
+ * Version $Id$
*
*/
/*
*
* Kern E. Sibbald
*
- * $Id$
+ * Version $Id$
*
*/
/*
*
* Kern Sibbald, March MMI
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#ifndef __BLOCK_H
#define __BLOCK_H 1
-#define MAX_BLOCK_LENGTH 500001 /* this is a sort of sanity check */
-#define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
+#define MAX_BLOCK_LENGTH 500001 /* this is a sort of sanity check */
+#define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
/* Block Header definitions. */
#define BLKHDR_ID "BB01"
#define BLKHDR_ID_LENGTH 4
-#define BLKHDR_CS_LENGTH 4 /* checksum length */
-#define BLKHDR_LENGTH 16 /* Total length */
+#define BLKHDR_CS_LENGTH 4 /* checksum length */
+#define BLKHDR_LENGTH 16 /* Total length */
/*
* This is the Media structure for a block header
* This is the memory structure for a device block.
*/
typedef struct s_dev_block {
- struct s_dev_block *next; /* pointer to next one */
+ struct s_dev_block *next; /* pointer to next one */
/* binbuf is the number of bytes remaining
* in the buffer. For writes, it is bytes not yet written.
* For reads, it is remaining bytes not yet read.
*/
- uint32_t binbuf; /* bytes in buffer */
- uint32_t block_len; /* length of current block read */
- uint32_t buf_len; /* max/default block length */
- uint32_t BlockNumber; /* sequential block number */
- uint32_t read_len; /* bytes read into buffer */
- int failed_write; /* set if write failed */
- char *bufp; /* pointer into buffer */
- char *buf; /* actual data buffer. This is a
- * Pool buffer!
- */
+ uint32_t binbuf; /* bytes in buffer */
+ uint32_t block_len; /* length of current block read */
+ uint32_t buf_len; /* max/default block length */
+ uint32_t BlockNumber; /* sequential block number */
+ uint32_t read_len; /* bytes read into buffer */
+ int failed_write; /* set if write failed */
+ char *bufp; /* pointer into buffer */
+ char *buf; /* actual data buffer. This is a
+ * Pool buffer!
+ */
} DEV_BLOCK;
#endif
*
* Dumb program to do an "ls" of a Bacula 1.0 mortal file.
*
- * $Id$
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Kern E. Sibbald, December 2001
*
*
- * $Id$
+ * Version $Id$
*/
/*
Copyright (C) 2001, 2002 Kern Sibbald and John Walker
* Note, this program reads stored.conf, and will only
* talk to devices that are configured.
*
- * $Id$
+ * Version $Id$
*
*/
/*
* a consequence has lead to something more contored than is
* really necessary -- KES. Note, this contortion has been
* corrected to a large extent by a rewrite (Apr MMI).
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Definitions for using the Device functions in Bacula
* Tape and File storage access
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#define READ_ONLY 1
/* Generic status bits returned from status_dev() */
-#define MT_TAPE (1<<0) /* is tape device */
-#define MT_EOF (1<<1) /* just read EOF */
-#define MT_BOT (1<<2) /* at beginning of tape */
-#define MT_EOT (1<<3) /* end of tape reached */
-#define MT_SM (1<<4) /* DDS setmark */
-#define MT_EOD (1<<5) /* DDS at end of data */
-#define MT_WR_PROT (1<<6) /* tape write protected */
-#define MT_ONLINE (1<<7) /* tape online */
-#define MT_DR_OPEN (1<<8) /* tape door open */
-#define MT_IM_REP_EN (1<<9) /* immediate report enabled */
+#define MT_TAPE (1<<0) /* is tape device */
+#define MT_EOF (1<<1) /* just read EOF */
+#define MT_BOT (1<<2) /* at beginning of tape */
+#define MT_EOT (1<<3) /* end of tape reached */
+#define MT_SM (1<<4) /* DDS setmark */
+#define MT_EOD (1<<5) /* DDS at end of data */
+#define MT_WR_PROT (1<<6) /* tape write protected */
+#define MT_ONLINE (1<<7) /* tape online */
+#define MT_DR_OPEN (1<<8) /* tape door open */
+#define MT_IM_REP_EN (1<<9) /* immediate report enabled */
/* Bits for device capabilities */
-#define CAP_EOF 0x001 /* has MTWEOF */
-#define CAP_BSR 0x002 /* has MTBSR */
-#define CAP_BSF 0x004 /* has MTBSF */
-#define CAP_FSR 0x008 /* has MTFSR */
-#define CAP_FSF 0x010 /* has MTFSF */
-#define CAP_EOM 0x020 /* has MTEOM */
-#define CAP_REM 0x040 /* is removable media */
-#define CAP_RACCESS 0x080 /* is random access device */
-#define CAP_AUTOMOUNT 0x100 /* Read device at start to see what is there */
-#define CAP_LABEL 0x200 /* Label blank tapes */
-#define CAP_ANONVOLS 0x400 /* Mount without knowing volume name */
-#define CAP_ALWAYSOPEN 0x800 /* always keep device open */
+#define CAP_EOF 0x001 /* has MTWEOF */
+#define CAP_BSR 0x002 /* has MTBSR */
+#define CAP_BSF 0x004 /* has MTBSF */
+#define CAP_FSR 0x008 /* has MTFSR */
+#define CAP_FSF 0x010 /* has MTFSF */
+#define CAP_EOM 0x020 /* has MTEOM */
+#define CAP_REM 0x040 /* is removable media */
+#define CAP_RACCESS 0x080 /* is random access device */
+#define CAP_AUTOMOUNT 0x100 /* Read device at start to see what is there */
+#define CAP_LABEL 0x200 /* Label blank tapes */
+#define CAP_ANONVOLS 0x400 /* Mount without knowing volume name */
+#define CAP_ALWAYSOPEN 0x800 /* always keep device open */
/* Tape state bits */
-#define ST_OPENED 0x001 /* set when device opened */
-#define ST_TAPE 0x002 /* is a tape device */
-#define ST_LABEL 0x004 /* label found */
+#define ST_OPENED 0x001 /* set when device opened */
+#define ST_TAPE 0x002 /* is a tape device */
+#define ST_LABEL 0x004 /* label found */
#define ST_MALLOC 0x008 /* dev packet malloc'ed in init_dev() */
-#define ST_APPEND 0x010 /* ready for Bacula append */
-#define ST_READ 0x020 /* ready for Bacula read */
-#define ST_EOT 0x040 /* at end of tape */
-#define ST_WEOT 0x080 /* Got EOT on write */
-#define ST_EOF 0x100 /* Read EOF i.e. zero bytes */
-#define ST_NEXTVOL 0x200 /* Start writing on next volume */
-#define ST_SHORT 0x400 /* Short block read */
+#define ST_APPEND 0x010 /* ready for Bacula append */
+#define ST_READ 0x020 /* ready for Bacula read */
+#define ST_EOT 0x040 /* at end of tape */
+#define ST_WEOT 0x080 /* Got EOT on write */
+#define ST_EOF 0x100 /* Read EOF i.e. zero bytes */
+#define ST_NEXTVOL 0x200 /* Start writing on next volume */
+#define ST_SHORT 0x400 /* Short block read */
/* dev_blocked states (mutually exclusive) */
#define BST_NOT_BLOCKED 0 /* not blocked */
-#define BST_UNMOUNTED 1 /* User unmounted device */
+#define BST_UNMOUNTED 1 /* User unmounted device */
#define BST_WAITING_FOR_SYSOP 2 /* Waiting for operator to mount tape */
#define BST_DOING_ACQUIRE 3 /* Opening/validating/moving tape */
#define BST_WRITING_LABEL 4 /* Labeling a tape */
/* Volume Catalog Information structure definition */
typedef struct s_volume_catalog_info {
/* Media info for the current Volume */
- uint32_t VolCatJobs; /* number of jobs on this Volume */
- uint32_t VolCatFiles; /* Number of files */
- uint32_t VolCatBlocks; /* Number of blocks */
- uint64_t VolCatBytes; /* Number of bytes written */
- uint32_t VolCatMounts; /* Number of mounts this volume */
- uint32_t VolCatErrors; /* Number of errors this volume */
- uint32_t VolCatWrites; /* Number of writes this volume */
- uint32_t VolCatReads; /* Number of reads this volume */
- uint32_t VolCatRecycles; /* Number of recycles this volume */
- uint64_t VolCatMaxBytes; /* max bytes to write */
+ uint32_t VolCatJobs; /* number of jobs on this Volume */
+ uint32_t VolCatFiles; /* Number of files */
+ uint32_t VolCatBlocks; /* Number of blocks */
+ uint64_t VolCatBytes; /* Number of bytes written */
+ uint32_t VolCatMounts; /* Number of mounts this volume */
+ uint32_t VolCatErrors; /* Number of errors this volume */
+ uint32_t VolCatWrites; /* Number of writes this volume */
+ uint32_t VolCatReads; /* Number of reads this volume */
+ uint32_t VolCatRecycles; /* Number of recycles this volume */
+ uint64_t VolCatMaxBytes; /* max bytes to write */
uint64_t VolCatCapacityBytes; /* capacity estimate */
- char VolCatStatus[20]; /* Volume status */
+ char VolCatStatus[20]; /* Volume status */
char VolCatName[MAX_NAME_LENGTH]; /* Desired volume to mount */
} VOLUME_CAT_INFO;
/* Device structure definition */
typedef struct s_device {
- struct s_device *next; /* pointer to next open device */
- pthread_mutex_t mutex; /* access control */
- pthread_cond_t wait; /* thread wait variable */
+ struct s_device *next; /* pointer to next open device */
+ pthread_mutex_t mutex; /* access control */
+ pthread_cond_t wait; /* thread wait variable */
pthread_cond_t wait_next_vol; /* wait for tape to be mounted */
- pthread_t no_wait_id; /* this thread must not wait */
- int dev_blocked; /* set if we must wait (i.e. change tape) */
- int num_waiting; /* number of threads waiting */
- int num_writers; /* number of writing threads */
- int use_count; /* usage count on this device */
- int fd; /* file descriptor */
- int capabilities; /* capabilities mask */
- int state; /* state mask */
- int dev_errno; /* Our own errno */
- int mode; /* read/write modes */
- char *dev_name; /* device name */
- char *errmsg; /* nicely edited error message */
- uint32_t block_num; /* current block number base 0 */
- uint32_t file; /* current file number base 0 */
+ pthread_t no_wait_id; /* this thread must not wait */
+ int dev_blocked; /* set if we must wait (i.e. change tape) */
+ int num_waiting; /* number of threads waiting */
+ int num_writers; /* number of writing threads */
+ int use_count; /* usage count on this device */
+ int fd; /* file descriptor */
+ int capabilities; /* capabilities mask */
+ int state; /* state mask */
+ int dev_errno; /* Our own errno */
+ int mode; /* read/write modes */
+ char *dev_name; /* device name */
+ char *errmsg; /* nicely edited error message */
+ uint32_t block_num; /* current block number base 0 */
+ uint32_t file; /* current file number base 0 */
uint32_t LastBlockNumWritten; /* last block written */
- uint32_t min_block_size; /* min block size */
- uint32_t max_block_size; /* max block size */
- uint32_t max_volume_jobs; /* max jobs to put on one volume */
- int64_t max_volume_files; /* max files to put on one volume */
- int64_t max_volume_size; /* max bytes to put on one volume */
- int64_t max_file_size; /* max file size in bytes */
- int64_t volume_capacity; /* advisory capacity */
- uint32_t max_rewind_wait; /* max secs to allow for rewind */
- void *device; /* pointer to Device Resource */
-
- VOLUME_CAT_INFO VolCatInfo; /* Volume Catalog Information */
- struct Volume_Label VolHdr; /* Actual volume label */
+ uint32_t min_block_size; /* min block size */
+ uint32_t max_block_size; /* max block size */
+ uint32_t max_volume_jobs; /* max jobs to put on one volume */
+ int64_t max_volume_files; /* max files to put on one volume */
+ int64_t max_volume_size; /* max bytes to put on one volume */
+ int64_t max_file_size; /* max file size in bytes */
+ int64_t volume_capacity; /* advisory capacity */
+ uint32_t max_rewind_wait; /* max secs to allow for rewind */
+ void *device; /* pointer to Device Resource */
+
+ VOLUME_CAT_INFO VolCatInfo; /* Volume Catalog Information */
+ struct Volume_Label VolHdr; /* Actual volume label */
} DEVICE;
* dependent. Arrgggg!
*/
#ifndef MTEOM
-#ifdef MTSEOD
+#ifdef MTSEOD
#define MTEOM MTSEOD
#endif
#ifdef MTEOD
*
* Kern Sibbald, MM, MMI
*
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
}
/* *****FIXME**** we might do some checking for files too */
if (dev_is_tape(dev)) {
- Jmsg(jcr, M_INFO, 0, _("Ready to write at EOM File=%d\n"), dev_file(dev));
+ Jmsg(jcr, M_INFO, 0, _("Ready to append at EOM File=%d.\n"), dev_file(dev));
if (dev->VolCatInfo.VolCatFiles != dev_file(dev) + 1) {
/* ****FIXME**** this should refuse to write on tape */
Jmsg(jcr, M_INFO, 0, _("Hey! Num files mismatch! Catalog Files=%d\n"), dev->VolCatInfo.VolCatFiles);
* File daemon commands are handled in fdcmd.c
*
* Kern Sibbald, May MMI
+ *
+ * Version $Id$
*
*/
/*
* then when the Storage daemon receives a proper connection from
* the File daemon, control is passed here to handle the
* subsequent File daemon commands.
+ *
+ * Version $Id$
*
*/
/*
/*
* Job control and execution for Storage Daemon
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, MM
*
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/*
* Protypes for stored
+ *
+ * Version $Id$
*/
/*
/*
* Read code for Storage daemon
* Kern Sibbald, November MM
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
*
* Kern Sibbald, April MMI
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
* Record, and label definitions for Bacula
* media data format.
*
+ * Version $Id$
+ *
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
#define __RECORD_H 1
/* Return codes from read_device_volume_label() */
-#define VOL_NOT_READ 0 /* Volume label not read */
-#define VOL_OK 1 /* volume name OK */
-#define VOL_NO_LABEL 2 /* volume not labeled */
-#define VOL_IO_ERROR 3 /* volume I/O error */
-#define VOL_NAME_ERROR 4 /* Volume name mismatch */
-#define VOL_CREATE_ERROR 5 /* Error creating label */
-#define VOL_VERSION_ERROR 6 /* Bacula version error */
-#define VOL_LABEL_ERROR 7 /* Bad label type */
+#define VOL_NOT_READ 0 /* Volume label not read */
+#define VOL_OK 1 /* volume name OK */
+#define VOL_NO_LABEL 2 /* volume not labeled */
+#define VOL_IO_ERROR 3 /* volume I/O error */
+#define VOL_NAME_ERROR 4 /* Volume name mismatch */
+#define VOL_CREATE_ERROR 5 /* Error creating label */
+#define VOL_VERSION_ERROR 6 /* Bacula version error */
+#define VOL_LABEL_ERROR 7 /* Bad label type */
/* Length of Record Header (5 * 4 bytes) */
* This is the memory structure for the record header.
*/
typedef struct s_dev_rec {
- int sync; /* synchronous */
- uint32_t File; /* File number, returned if sync set */
- uint32_t Block; /* Block number, returned if sync set */
- uint32_t VolSessionId; /* sequential id within this session */
- uint32_t VolSessionTime; /* session start time */
- int32_t FileIndex; /* sequential file number */
- int32_t Stream; /* stream number */
- uint32_t data_len; /* current record length */
- uint32_t remainder; /* remaining bytes to read/write */
+ int sync; /* synchronous */
+ uint32_t File; /* File number, returned if sync set */
+ uint32_t Block; /* Block number, returned if sync set */
+ uint32_t VolSessionId; /* sequential id within this session */
+ uint32_t VolSessionTime; /* session start time */
+ int32_t FileIndex; /* sequential file number */
+ int32_t Stream; /* stream number */
+ uint32_t data_len; /* current record length */
+ uint32_t remainder; /* remaining bytes to read/write */
uint8_t ser_buf[RECHDR_LENGTH]; /* serialized record header goes here */
- char *data; /* Record data. This MUST be a memory pool item */
+ char *data; /* Record data. This MUST be a memory pool item */
} DEV_RECORD;
* Note, these values are negative to distinguish them
* from user records where the FileIndex is forced positive.
*/
-#define PRE_LABEL -1 /* Vol label on unwritten tape */
-#define VOL_LABEL -2 /* Volume label first file */
-#define EOM_LABEL -3 /* Writen at end of tape */
-#define SOS_LABEL -4 /* Start of Session */
-#define EOS_LABEL -5 /* End of Session */
+#define PRE_LABEL -1 /* Vol label on unwritten tape */
+#define VOL_LABEL -2 /* Volume label first file */
+#define EOM_LABEL -3 /* Writen at end of tape */
+#define SOS_LABEL -4 /* Start of Session */
+#define EOS_LABEL -5 /* End of Session */
/*
* in the DEVICE buffer, but are not actually written
* to the tape.
*/
- int32_t LabelType; /* This is written in header only */
- uint32_t LabelSize; /* length of serialized label */
+ int32_t LabelType; /* This is written in header only */
+ uint32_t LabelSize; /* length of serialized label */
/*
* The items below this line are stored on
* the tape
*/
- char Id[32]; /* Bacula Immortal ... */
+ char Id[32]; /* Bacula Immortal ... */
- uint32_t VerNum; /* Label version number */
+ uint32_t VerNum; /* Label version number */
- float64_t label_date; /* Date tape labeled */
- float64_t label_time; /* Time tape labeled */
- float64_t write_date; /* Date this label written */
- float64_t write_time; /* Time this label written */
+ float64_t label_date; /* Date tape labeled */
+ float64_t label_time; /* Time tape labeled */
+ float64_t write_date; /* Date this label written */
+ float64_t write_time; /* Time this label written */
char VolName[MAX_NAME_LENGTH]; /* Volume name */
char PrevVolName[MAX_NAME_LENGTH]; /* Previous Volume Name */
char MediaType[MAX_NAME_LENGTH]; /* Type of this media */
char HostName[MAX_NAME_LENGTH]; /* Host name of writing computer */
- char LabelProg[32]; /* Label program name */
- char ProgVersion[32]; /* Program version */
- char ProgDate[32]; /* Program build date/time */
+ char LabelProg[32]; /* Label program name */
+ char ProgVersion[32]; /* Program version */
+ char ProgDate[32]; /* Program build date/time */
};
#define SER_LENGTH_Volume_Label 1024 /* max serialised length of volume label */
* This record is at the beginning and end of each session
*/
struct Session_Label {
- char Id[32]; /* Bacula Immortal ... */
+ char Id[32]; /* Bacula Immortal ... */
- uint32_t VerNum; /* Label version number */
+ uint32_t VerNum; /* Label version number */
- uint32_t JobId; /* Job id */
- uint32_t VolumeIndex; /* Sequence no of volume for this job */
+ uint32_t JobId; /* Job id */
+ uint32_t VolumeIndex; /* Sequence no of volume for this job */
- float64_t write_date; /* Date this label written */
- float64_t write_time; /* Time this label written */
+ float64_t write_date; /* Date this label written */
+ float64_t write_time; /* Time this label written */
char PoolName[MAX_NAME_LENGTH]; /* Pool name */
char PoolType[MAX_NAME_LENGTH]; /* Pool type */
};
typedef struct Session_Label SESSION_LABEL;
-#define SERIAL_BUFSIZE 1024 /* volume serialisation buffer size */
+#define SERIAL_BUFSIZE 1024 /* volume serialisation buffer size */
#endif
* and acts on them. When a request to append data is made,
* it opens a data channel and accepts data from the
* File daemon.
+ *
+ * Version $Id$
*
*/
/*
/*
* Storage daemon specific defines and includes
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
DEVICE dev[MAX_DEVICES];
};
-extern char errmsg[]; /* general error message */
+extern char errmsg[]; /* general error message */
#endif /* __STORED_H_ */
* Configuration file parser for Bacula Storage daemon
*
* Kern Sibbald, March MM
+ *
+ * Version $Id$
*/
/*
/*
* Resource codes -- they must be sequential for indexing
+ *
+ * Version $Id$
*/
/*
Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
/* */
#define VERSION "1.20"
#define VSTRING "1"
-#define DATE "16 May 2002"
-#define LSMDATE "16May02"
+#define DATE "19 May 2002"
+#define LSMDATE "19May02"
/* Debug flags */
#define DEBUG 1