Cedric Tefft wrote:
Mark Nienberg wrote:

I'd like to write an SQL query to extract some information from the bacula catalog including file dates. I see from the bacula developers guide that the "File" table has a field named "LStat" that is defined as "File attributes in base64 encoding". I assume my file dates are in there, but how do I deal with the base64 bit?

A typical entry looks like this:
P0A HL4KO IHk B A A A BdD BAA Y BEU0tK BEHwQV BEHwQV A A C

I've got about half an answer for 'ya.

The database entry appears to be a series of base-64 encoded values corresponding to the fields of a UNIX stat structure (plus a couple extra bits), which 'man lstat' says is:

         struct stat {
             dev_t     st_dev;     /* ID of device containing file */
             ino_t     st_ino;     /* inode number */
             mode_t    st_mode;    /* protection */
             nlink_t   st_nlink;   /* number of hard links */
             uid_t     st_uid;     /* user ID of owner */
             gid_t     st_gid;     /* group ID of owner */
             dev_t     st_rdev;    /* device ID (if special file) */
             off_t     st_size;    /* total size, in bytes */
             blksize_t st_blksize; /* blocksize for filesystem I/O */
             blkcnt_t  st_blocks;  /* number of blocks allocated */
             time_t    st_atime;   /* time of last access */
             time_t    st_mtime;   /* time of last modification */
             time_t    st_ctime;   /* time of last status change */
         };

Therefore, from your example, "P0A" is the base64-encoded value of st_dev, "HL4KO" is the base64-encoded value of st_ino, etc.

So, if you're after the modification time (st_mtime) of your file, you should theoretically just have to base64 decode the string "BEHwQV" to get back a standard UNIX timestamp value (seconds since Jan 1, 1970). Exactly how you go about doing a base64 decode is, of course, the other half of the answer which I'm far too lazy to go into here, but Google should be able to take you the rest of the way, and if you're a C programmer, the bacula source code itself (in particular src/lib/base64.c) should be helpful.

Thanks. That is an excellent half answer! Now I understand which values I am trying to decode. I am just having trouble decoding them. See my response to James Harper and thanks for your help.
Mark



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to