<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How get and set file caching option in C-Program? in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6527698#M37342</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Harmut&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for provided sample.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is working for me now. The issue was a wrong value in&amp;nbsp;item_list.itm$w_itmcod, where I was using&amp;nbsp;XAB$_CACHING_OPTIONS instead of&amp;nbsp;XAB$_CACHING_ATTRIBUTE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The documentation does not have any references about &lt;SPAN&gt;XAB$_CACHING_ATTRIBUTE&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dmitriy&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jul 2014 14:49:40 GMT</pubDate>
    <dc:creator>Dmitriy_21</dc:creator>
    <dc:date>2014-07-02T14:49:40Z</dc:date>
    <item>
      <title>How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525634#M37337</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I write a C program, which require to find a default caching option of a file, and also be able to change this option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation I found talks only about how to open a file with desired mode (NO_CACHING or&amp;nbsp;WRITETHROUGH) using XABITM. It&amp;nbsp;&lt;SPAN&gt;also has a refernece to '&lt;/SPAN&gt;&lt;SPAN&gt;file’s caching attribute&lt;/SPAN&gt;&lt;SPAN&gt;', which I can't locate how to get or set from a C-code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"If you do not supply a XABITM or, if you supply a XABITM whose value is zero&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;(0), the file system uses the value in the file’s caching attribute."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me to find how to get and set &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;file’s caching attribute&lt;/SPAN&gt;&lt;SPAN&gt;' of a file from a C-code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dmitriy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2014 20:59:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525634#M37337</guid>
      <dc:creator>Dmitriy_21</dc:creator>
      <dc:date>2014-06-30T20:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525690#M37338</link>
      <description>&lt;P&gt;From what I understand, you need a xab with cc$rms_xabitm id code, an item&amp;nbsp;list and a XAB$K_SENSEMODE or XAB$K_SETMODE. The item list should contain an&amp;nbsp;XAB$_CACHING_OPTIONS or XAB$_CACHING_ATTRIBUTE item code and an address for an&amp;nbsp;appropriate buffer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no sample code, but a quick search with Google found the "C.3 Sample&amp;nbsp;Program---DEC C (Using XAB$_TID)" in&amp;nbsp;&lt;A target="_blank" href="http://h71000.www7.hp.com/doc/72final/4454/4454pro_010.html."&gt;http://h71000.www7.hp.com/doc/72final/4454/4454pro_010.html.&lt;/A&gt; There may be&amp;nbsp;better examples and/or newer documentation.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2014 22:59:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525690#M37338</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2014-06-30T22:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525882#M37339</link>
      <description>&lt;P&gt;Hmm, &amp;nbsp;what you want is pretty special. Care to elaborate?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How is the C program accessing the file?&lt;/P&gt;&lt;P&gt;May we assume it is using the CRTL OPEN + READ, not direct calls ro RMS (SYS$OPEN, SYS$GET) &amp;nbsp;nor QIO calls?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the CRTL is used, then the program needs to be able to get at the RAB/FAB first.&lt;/P&gt;&lt;P&gt;Quit possibly you know this already, but one uses the "acc" callout for that on an open providing a service routine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a little example I use ( to use NQL on OpenVMS version that have is defined).&lt;/P&gt;&lt;P&gt;Harmut already gave enough to go on for the XABITM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hein.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+-----------------------------------------------------+&lt;BR /&gt;| C-RTL activated callback to request NO QUERY LOCK |&lt;BR /&gt;+-----------------------------------------------------+&lt;BR /&gt;*/&lt;BR /&gt;int acc_set_nql (int dummy, struct FAB *fab, struct RAB *rab) {&lt;BR /&gt;#ifdef rab$v_nql&lt;BR /&gt;rab-&amp;gt;rab$v_nql = 1;&lt;BR /&gt;#else&lt;BR /&gt;rab-&amp;gt;rab$v_rrl = 1;&lt;BR /&gt;rab-&amp;gt;rab$v_nlk = 1;&lt;BR /&gt;#endif&lt;BR /&gt;return 1;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;fp = open(szFname, O_RDONLY, 0, "shr=... &amp;nbsp;"ctx=bin", "acc", acc_set_nql, 0);&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2014 04:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6525882#M37339</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2014-07-01T04:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6526586#M37340</link>
      <description>&lt;P&gt;Hein/&lt;SPAN&gt;Harmut&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for you suggetion, but it is not eactly whan I need (unless I missing something or it is described in a different section of RMS documentatin).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation is clearly on&amp;nbsp;&lt;SPAN&gt;XAB$_CACHING_&lt;/SPAN&gt;&lt;SPAN&gt;OPTIONS XABITM, where it is tell how caching work for a current process that is opening the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My task is to set the deault option on a file - &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;STRONG&gt;the file’s caching attribute&lt;/STRONG&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&amp;nbsp;which is used by other processes as default setting when the&amp;nbsp;XABITM is not supplied during open call.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;12.9 Extended File Cache (XAB$_CACHE_OPTIONS)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Setting and Showing the Current Caching Option&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When you access a file, you can specify the caching option that you would like&amp;nbsp;&lt;U&gt;for the current process&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you do not supply a XABITM or, if you supply a XABITM whose value is zero&lt;BR /&gt;(0), the file system uses the value in &lt;STRONG&gt;the file’s caching attribute.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need to get/set "&lt;STRONG&gt;the file’s caching attribute&lt;/STRONG&gt;".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dmitriy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2014 16:36:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6526586#M37340</guid>
      <dc:creator>Dmitriy_21</dc:creator>
      <dc:date>2014-07-01T16:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6526682#M37341</link>
      <description>&lt;P&gt;Works for me, as advertised. But I'm not sure what you want to accomplish. From the mentioned sample code I derived/hacked a simple program to get and display the permanent caching bits. My code at least makes use of more VMS header files, but there is still room for improvement. Anyway ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ dir/out=x.x&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ set file/cach=writeb x.x&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ mc []getpermcachbits&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;file_contents: 00000220&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;writebehind&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ set file/cach=writet x.x&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ mc []getpermcachbits&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;file_contents: 00000110&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;writethrough&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ set file/cach=no x.x&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ mc []getpermcachbits&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;file_contents: 00000130&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;nocaching&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$ pipe dump/header /bl=co=0 x.x |search sys$pipe cach&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Caching attribute: No_caching&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;$&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;lt;descrip.h&amp;gt;
#include &amp;lt;lib$routines.h&amp;gt;
#include &amp;lt;rms.h&amp;gt;
#include &amp;lt;ssdef.h&amp;gt;
#include &amp;lt;starlet.h&amp;gt;
#include &amp;lt;stsdef.h&amp;gt;
#include &amp;lt;xabitmdef.h&amp;gt;

#define exit_on_error(expression,mycode) { \
    int \
        sys_status; \
    sys_status=(expression); \
    if ((sys_status &amp;amp; 1) == 0) { \
        fprintf( stderr, "error - %s\n", mycode );\
        lib$signal(sys_status); }}

typedef struct {
    short int status;
    unsigned char filler [3];
    }   IOSB;

typedef struct {
    unsigned short itm$w_bufsiz, itm$w_itmcod;
    void *itm$l_bufadr;
    unsigned short *itm$l_retlen;
    unsigned long terminator;
    } ITMLST;

typedef struct {
    unsigned char  xab$b_cod;
    unsigned char  xab$b_bln;
    unsigned short filler;
    void *xab$l_nxt;
    void *xab$l_itemlist;
    unsigned char  xab$b_mode;
}       XABITM;

    struct  FAB
        fab;
    char
        *file_name =   "x.x";
    unsigned short int
        return_length;
    IOSB
        iosb;
    ITMLST
        item_list;
    unsigned int
        file_contents;
    XABITM
        itm;

main () {

    fab           = cc$rms_fab;
    fab.fab$l_fna = file_name;
    fab.fab$b_fns = strlen (file_name);
    fab.fab$b_fac = FAB$M_UPD | FAB$M_PUT | FAB$M_GET;
    fab.fab$l_xab = &amp;amp;itm; 

    itm.xab$b_cod      = XAB$C_ITM;
    itm.xab$b_bln      = XAB$K_ITMLEN;
    itm.xab$l_itemlist = &amp;amp;item_list;
    itm.xab$b_mode     = XAB$K_SENSEMODE;
    itm.xab$l_nxt      = 0;

    item_list.itm$w_bufsiz      = 4;
    item_list.itm$w_itmcod      = XAB$_CACHING_ATTRIBUTE;
    item_list.itm$l_bufadr      = &amp;amp;file_contents;
    item_list.itm$l_retlen      = &amp;amp;return_length;
    item_list.terminator        = 0;

    exit_on_error(sys$open (&amp;amp;fab), "OPEN failed");
    exit_on_error(sys$display (&amp;amp;fab), "DISPLAY failed");

    printf ("file_contents: %08x\n", file_contents);
    switch ((XAB$M_FILE_CONTENTS &amp;amp; file_contents)&amp;gt;&amp;gt;4) {
        case XAB$K_DEFAULT: printf ("default\n");
	    break;
        case XAB$K_WRITETHROUGH: printf ("writethrough\n");
	    break;
        case XAB$K_WRITEBEHIND: printf ("writebehind\n");
	    break;
        case XAB$K_NOCACHING: printf ("nocaching\n");
	    break;
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2014 19:21:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6526682#M37341</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2014-07-01T19:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How get and set file caching option in C-Program?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6527698#M37342</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Harmut&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for provided sample.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is working for me now. The issue was a wrong value in&amp;nbsp;item_list.itm$w_itmcod, where I was using&amp;nbsp;XAB$_CACHING_OPTIONS instead of&amp;nbsp;XAB$_CACHING_ATTRIBUTE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The documentation does not have any references about &lt;SPAN&gt;XAB$_CACHING_ATTRIBUTE&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dmitriy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2014 14:49:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/how-get-and-set-file-caching-option-in-c-program/m-p/6527698#M37342</guid>
      <dc:creator>Dmitriy_21</dc:creator>
      <dc:date>2014-07-02T14:49:40Z</dc:date>
    </item>
  </channel>
</rss>

