Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify backup date and time of file attribute on DEACCESS, not revision date and time and version.

 
allin-in-one
Frequent Advisor

Modify backup date and time of file attribute on DEACCESS, not revision date and time and version.

Hi,

 

I want to modify the backup date and time (i.e. ATR$C_BAKDATE) of the file attribute on the DEACCESS but don’t want the revision date and time and version be modified (i.e. ATR$C_REVDATE). Please let me know how to do it.

 

Also is the modify on DEACCESS requires FIB$M_WRITE ?

 

I am trying like below

 

qio_bdt[] = { { 8, ATR$C_BAKDATE, bdt}, // Backup Date
                           {0, 0, 0}

                         };

 

stat = sys$qio(0, /* Event flag */
                               chan, /* Channel number */
                                IO$_DEACCESS, /* I/O function */
                                0, /* NO iosb */
                                0, 0, 0, /* P1 buffer */
                                 0, /* P2 buffer length */
                                 0, 0, qio_bdt, 0);

 

 

 

Thanks,

12 REPLIES 12
H.Becker
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

To me it looks like "set file/attribute" can do the job:

 

$ copy nl: x.x
$ pipe dir/full x.x; |search sys$pipe "File ID:","Revised:","Backup:"
X.X;1 File ID: (145555,22,0) 
Revised: 25-AUG-2014 11:00:49.05 (1)
Backup: <No backup recorded>
$ set file/attr=bakdate="25-AUG-2014 11:02:02.02" x.x
$ pipe dir/full x.x; |search sys$pipe "File ID:","Revised:","Backup:"
X.X;1 File ID: (145555,22,0) 
Revised: 25-AUG-2014 11:00:49.05 (1)
Backup: 25-AUG-2014 11:02:02.02
$
$ copy nla0: myods5:x.x
$ pipe dir/full myods5:x.x; |search sys$pipe "File ID:","Revised:","Backup:"
x.x;2 File ID: (25322,33,0) 
Revised: 25-AUG-2014 11:04:22.85 (1)
Backup: <No backup recorded>
$ set file/attr=bakdate="25-AUG-2014 11:05:05.05" myods5:x.x
$ pipe dir/full myods5:x.x; |search sys$pipe "File ID:","Revised:","Backup:"
x.x;2 File ID: (25322,33,0) 
Revised: 25-AUG-2014 11:04:22.85 (1)
Backup: 25-AUG-2014 11:05:05.05
$

 

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

Thanks for the response.

Yes,  "set file/attribute" will definetly work.

Here I would like to do it through an application (i.e. using sys$qio call with IO$_DEACCESS ).

 

Thanks.

Steven Schweda
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

    Are you looking for FIB$M_NORECORD (and/or fib$v_norecord)?

 

   See Info-ZIP UnZip [.vms]vms.c:stamp_file() for some sample code.

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

Thank you.

I have pasted  sample code. Please let me know what are the changes I need to do so that revision number will not be changed when the backup time is changed.

Revised:    26-AUG-2014 16:48:24.27 (3)


Thanks.

 

 

 

#include <descrip.h>
#include <rms.h>
#include <stdio.h>
#include <iodef.h>
#include <string.h>
#include <starlet.h>
#include <atrdef.h>
#include <fibdef.h>
#include <stsdef.h>

#define FAT$K_LENGTH 32
#define FAT$C_LENGTH 32
#define FAT$S_FATDEF 32

struct fjndef  {
    unsigned fjn$v_only_ru : 1;
    unsigned fjn$v_rujnl : 1;
    unsigned fjn$v_bijnl : 1;
    unsigned fjn$v_aijnl : 1;
    unsigned fjn$v_atjnl : 1;
    unsigned fjn$v_never_ru : 1;
    unsigned fjn$v_journal_file:1;
    } ;

struct fatdef {
    union  {
        unsigned char fat$b_rtype;
        struct  {
            unsigned fat$v_rtype : 4;
            unsigned fat$v_fileorg : 4;
            } fat$r_rtype_bits;
        } fat$r_rtype_overlay;
# define FAT$S_RTYPE 4
# define FAT$V_RTYPE 0
#   define FAT$C_UNDEFINED 0
#   define FAT$C_FIXED 1
#   define FAT$C_VARIABLE 2
#   define FAT$C_VFC 3
#   define FAT$C_STREAM 4
#   define FAT$C_STREAMLF 5
#   define FAT$C_STREAMCR 6
# define FAT$S_FILEORG 4
# define FAT$V_FILEORG 4
#   define FAT$C_SEQUENTIAL 0
#   define FAT$C_RELATIVE 1
#   define FAT$C_INDEXED 2
#   define FAT$C_DIRECT 3
    union  {
        unsigned char fat$b_rattrib;
        struct  {
            unsigned fat$v_fortrancc : 1;
            unsigned fat$v_impliedcc : 1;
            unsigned fat$v_printcc : 1;
            unsigned fat$v_nospan : 1;
            } fat$r_rattrib_bits;
        } fat$r_rattrib_overlay;
#   define FAT$V_FORTRANCC 0
#   define FAT$M_FORTRANCC 1
#   define FAT$V_IMPLIEDCC 1
#   define FAT$M_IMPLIEDCC 2
#   define FAT$V_PRINTCC 2
#   define FAT$M_PRINTCC 4
#   define FAT$V_NOSPAN 3
#   define FAT$M_NOSPAN 8
    unsigned short int fat$w_rsize;
    union
        {
        unsigned long int fat$l_hiblk;
        struct
            {
            unsigned short int fat$w_hiblkh;
            unsigned short int fat$w_hiblkl;
            } fat$r_hiblk_fields;
        } fat$r_hiblk_overlay;
    union
        {
        unsigned long int fat$l_efblk;
        struct
            {
            unsigned short int fat$w_efblkh;
            unsigned short int fat$w_efblkl;
            } fat$r_efblk_fields;
        } fat$r_efblk_overlay;
    unsigned short int fat$w_ffbyte;
    unsigned char fat$b_bktsize;
    unsigned char fat$b_vfcsize;
    unsigned short int fat$w_maxrec;
    unsigned short int fat$w_defext;
    unsigned short int fat$w_gbc;
    char fat$fill[8];
    unsigned short int fat$w_versions;
    };

struct fchdef  {
    unsigned : 1;
    unsigned fch$v_nobackup : 1 ;
    unsigned fch$v_writeback : 1;
    unsigned fch$v_readcheck : 1;
    unsigned fch$v_writcheck : 1;
    unsigned fch$v_contigb : 1;
    unsigned fch$v_locked : 1;
    unsigned fch$v_contig : 1;
    unsigned : 3;
    unsigned fch$v_badacl : 1;
    unsigned fch$v_spool : 1;
    unsigned fch$v_directory : 1;
    unsigned fch$v_badblock : 1;
    unsigned fch$v_markdel : 1;
    unsigned fch$v_nocharge : 1;
    unsigned fch$v_erase : 1;
    };

int   start_of_backup[2];
struct {
        unsigned int buff1, buff2;
}time_value;

int getfile( char  * filename, int action )
    {

    static struct FAB fab;
    static struct NAM nam;
    static struct fibdef Fib;
    static struct dsc$descriptor FibDesc =
        {sizeof(Fib),DSC$K_DTYPE_Z,DSC$K_CLASS_S,(char *)&Fib};
    static struct dsc$descriptor_s DevDesc =
        {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,&nam.nam$t_dvi[1]};
    static struct fatdef Fat;
    static union {
        struct fchdef fch;
        long int dummy;
        } uchar;
    static struct fjndef jnl;
    static  int Cdate[2],Rdate[2],Edate[2],Bdate[2];
    static short int revisions;
    static unsigned long uic;
    static union {
        unsigned short int value;
        struct {
            unsigned system : 4;
            unsigned owner : 4;
            unsigned group : 4;
            unsigned world : 4;
            } bits;
        } prot;

    static unsigned short back[8];
    static int   acllen;
    static int   pro;
    static int   u_char;
    static int   highwater;
    static struct atrdef Atr[] = {
        {ATR$S_RECATTR,ATR$C_RECATTR,&Fat},
        {ATR$S_UCHAR,ATR$C_UCHAR,&uchar},
        {6, ATR$C_BACKLINK, back},
        {ATR$S_CREDATE,ATR$C_CREDATE,&Cdate[0]},
        {ATR$S_REVDATE,ATR$C_REVDATE,&Rdate[0]},
        {ATR$S_EXPDATE,ATR$C_EXPDATE,&Edate[0]},
        {ATR$S_BAKDATE,ATR$C_BAKDATE,&Bdate[0]},
        {ATR$S_ASCDATES,ATR$C_ASCDATES,&revisions},
        {ATR$S_FPRO,ATR$C_FPRO,&prot},
        {ATR$S_UIC,ATR$C_UIC,&uic},
        {ATR$S_JOURNAL,ATR$C_JOURNAL,&jnl},
        {4, ATR$C_ACLLENGTH, &acllen},
        {2, ATR$C_FPRO, &pro},
        {4, ATR$C_UCHAR, &u_char},
        {4, ATR$C_HIGHWATER, &highwater},
        {0,0,0}
        } ;
       int   stat = 0;
       char timestr[23];
       $DESCRIPTOR(atimenow, timestr);


    static char EName[NAM$C_MAXRSS];
    static char RName[NAM$C_MAXRSS];
    static struct dsc$descriptor_s FileName =
        {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
    static struct dsc$descriptor_s string = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
    static short int DevChan;
    static short int iosb[4];

    static long int i,status;
    static int  old_rtype=FAT$C_FIXED;


    fab = cc$rms_fab;
    fab.fab$l_fna = filename;
    fab.fab$b_fns = strlen(filename);
    fab.fab$l_nam = &nam;
    nam = cc$rms_nam;
    nam.nam$l_esa = EName;
    nam.nam$b_ess = sizeof(EName);
    nam.nam$l_rsa = RName;
    nam.nam$b_rss = sizeof(RName);


    status = sys$parse(&fab);
    if (!(status & 1)) return(status);


    status = sys$search(&fab);
    if (!(status & 1)) return(status);

    DevDesc.dsc$w_length = nam.nam$t_dvi[0];

    status = sys$assign(&DevDesc,&DevChan,0,0);
    if (!(status & 1)) return(status);

    FileName.dsc$a_pointer = nam.nam$l_name;
    FileName.dsc$w_length = nam.nam$b_name+nam.nam$b_type+nam.nam$b_ver;


    for (i=0;i<3;i++)
#ifdef VAXC
        Fib.fib$r_fid_overlay.fib$w_fid[i]=nam.nam$w_fid[i];
#else
        Fib.fib$w_fid[i]=nam.nam$w_fid[i];
#endif
    for (i=0;i<3;i++)
#ifdef VAXC
        Fib.fib$r_did_overlay.fib$w_did[i]=nam.nam$w_did[i];
#else
        Fib.fib$w_did[i]=nam.nam$w_did[i];
#endif

    Fib.fib$l_acctl |= FIB$M_WRITE;

  status = sys$qiow(0,DevChan,IO$_ACCESS| IO$M_ACCESS,&iosb,0,0,&FibDesc,&FileName,0,0,&Atr,0);
   
   sys$gettim (start_of_backup);

   /* Convert binary time to  ASCII */
        status = SYS$ASCTIM(0,            /* timlen - Length of ASCII string */
                            &atimenow,    /* timbuf - ASCII time buffer */
                            &start_of_backup,  /* timadr - Binary time */
                            0);           /* cvtflags - Conversion indicator */
       struct {
             short len, param;
             int  *ptr;
           } qio_bdt[] = { {   8, ATR$C_BAKDATE, start_of_backup},     // BackUP Date                         
                           { 0, 0, 0}
                         };

 status = sys$qiow(0,       /* Event flag */
                DevChan,        /* Channel number */
                IO$_DEACCESS,        /* I/O function */
                0,   /* NO iosb */
                0, 0, 0,     /* P1 buffer */
                0,   /* P2 buffer length */
                0, 0,  qio_bdt, 0);


     return(status);
    }
int main (int argc, char *argv[] )
    {

    if ( argc > 1 )

        getfile( argv[1], 1);

    }

 

Steven Schweda
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

> See Info-ZIP UnZip [.vms]vms.c:stamp_file() for some sample code.

 

> I have pasted sample code. Please let me know what are the changes I

> need to do [...]

 

   Could you not find the UnZip source?

 

   I haven't looked at your code much more closely than you looked at

the UnZip code, but my first guess would be something like:

 

    Fib.fib$l_acctl |= FIB$M_NORECORD;

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

Thank you.

 

Sorry I forgot to mention that with

 

Fib.fib$l_acctl |= FIB$M_NORECORD;                backup date cann't be modified.

 

Needs

 

Fib.fib$l_acctl |= FIB$M_WRITE ;

 

 

Thanks.

 

Steven Schweda
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

> Sorry I forgot to mention that with

>

> Fib.fib$l_acctl |= FIB$M_NORECORD;                backup date cann't be modified.

>

> Needs

>

> Fib.fib$l_acctl |= FIB$M_WRITE ;

 

   What stops you from setting both bits?

 

> Fib.fib$l_acctl |= FIB$M_NORECORD;

 

   Did I say that this suggestion _replaces_ your statement which sets

FIB$M_WRITE?  (No, I did not.)

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

By setting both bits I didn't get the desiared result.

Revision date and revision number are changed by setting both bits.

 

Thanks.

Hoff
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

FWIW...

 

I'd suggest migrating to fatdef.h, fchdef.h, fjndef.h and related definitions, as those are available in sys$share:sys$lib_c.tlb, and removing the local definitions.  

 

The embedded structures and constants might be entirely correct, or there might also be some potentially subtle errors, such as missing padding directives. 

 

To reference these specified include files, use the following command:

 

$ CC X.C+SYS$LIBRARY:SYS$LIB_C.TLB/LIBRARY

 

The code is not checking the status returned from the $qiow, nor from some of the other calls, nor is the IOSB being checked, and those can sometimes provide clues to the problem.

 

Probably obvious: there is a latent buffer overrun within the filename handling code, and a latent ODS-2 assumption.

 

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

Thanks for the suggestion.

I tried your suggestions but result is same.

 

Thanks.

H.Becker
Honored Contributor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

As far as I understand, you can't close (IO$_DEACCESS) a file, which was opened (IO$_ACCESS| IO$M_ACCESS) for write access without updating the revision. If you ONLY want to modify the BAKDATE you may want to use just IO$_MODIFY: this works as expected.

 

As mentioned before, Steven's example, vms.c, shows how to do that. As Steve mentioned, (in your example,) use the VMS supplied header files, consider using __NEW_STARLET, check the return status and use/check the iosb.

 

allin-in-one
Frequent Advisor

Re: Modify backup date and time of file attribute on DEACCESS, not revision date and time and versi

Hi,

 

Finally found the solution.

 

The changed code is

 

status = sys$qiow(0, /* Event flag */
DevChan, /* Channel number */
IO$_DEACCESS, /* I/O function */
0, /* NO iosb */
0, &FibDesc,  /* P1 buffer */
&FileName, /* P2 buffer length */
0, 0, qio_bdt, 0);

 

i.e. just adding P1 buffer and P2 buffer to the sys$qiow.

 

 

Thank you all for your help and time.