- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: How get and set file caching option in C-Progr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2014 01:59 PM
06-30-2014 01:59 PM
Hi,
I write a C program, which require to find a default caching option of a file, and also be able to change this option.
The documentation I found talks only about how to open a file with desired mode (NO_CACHING or WRITETHROUGH) using XABITM. It also has a refernece to 'file’s caching attribute', which I can't locate how to get or set from a C-code.
"If you do not supply a XABITM or, if you supply a XABITM whose value is zero
(0), the file system uses the value in the file’s caching attribute."
Can anyone help me to find how to get and set 'file’s caching attribute' of a file from a C-code.
Thanks
Dmitriy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2014 03:59 PM
06-30-2014 03:59 PM
Re: How get and set file caching option in C-Program?
From what I understand, you need a xab with cc$rms_xabitm id code, an item list and a XAB$K_SENSEMODE or XAB$K_SETMODE. The item list should contain an XAB$_CACHING_OPTIONS or XAB$_CACHING_ATTRIBUTE item code and an address for an appropriate buffer.
I have no sample code, but a quick search with Google found the "C.3 Sample Program---DEC C (Using XAB$_TID)" in http://h71000.www7.hp.com/doc/72final/4454/4454pro_010.html. There may be better examples and/or newer documentation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2014 09:55 PM
06-30-2014 09:55 PM
Re: How get and set file caching option in C-Program?
Hmm, what you want is pretty special. Care to elaborate?
How is the C program accessing the file?
May we assume it is using the CRTL OPEN + READ, not direct calls ro RMS (SYS$OPEN, SYS$GET) nor QIO calls?
If the CRTL is used, then the program needs to be able to get at the RAB/FAB first.
Quit possibly you know this already, but one uses the "acc" callout for that on an open providing a service routine.
Below is a little example I use ( to use NQL on OpenVMS version that have is defined).
Harmut already gave enough to go on for the XABITM
Hein.
+-----------------------------------------------------+
| C-RTL activated callback to request NO QUERY LOCK |
+-----------------------------------------------------+
*/
int acc_set_nql (int dummy, struct FAB *fab, struct RAB *rab) {
#ifdef rab$v_nql
rab->rab$v_nql = 1;
#else
rab->rab$v_rrl = 1;
rab->rab$v_nlk = 1;
#endif
return 1;
}
:
fp = open(szFname, O_RDONLY, 0, "shr=... "ctx=bin", "acc", acc_set_nql, 0);
:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 09:36 AM
07-01-2014 09:36 AM
Re: How get and set file caching option in C-Program?
Hein/Harmut
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).
The documentation is clearly on XAB$_CACHING_OPTIONS XABITM, where it is tell how caching work for a current process that is opening the file.
My task is to set the deault option on a file - "the file’s caching attribute", which is used by other processes as default setting when the XABITM is not supplied during open call.
12.9 Extended File Cache (XAB$_CACHE_OPTIONS)
Setting and Showing the Current Caching Option
When you access a file, you can specify the caching option that you would like for the current process.
...
If you do not supply a XABITM or, if you supply a XABITM whose value is zero
(0), the file system uses the value in the file’s caching attribute.
I need to get/set "the file’s caching attribute".
Thanks
Dmitriy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 12:21 PM
07-01-2014 12:21 PM
SolutionWorks 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 ...
$ dir/out=x.x
$ set file/cach=writeb x.x
$ mc []getpermcachbits
file_contents: 00000220
writebehind
$ set file/cach=writet x.x
$ mc []getpermcachbits
file_contents: 00000110
writethrough
$ set file/cach=no x.x
$ mc []getpermcachbits
file_contents: 00000130
nocaching
$ pipe dump/header /bl=co=0 x.x |search sys$pipe cach
Caching attribute: No_caching
$
#include <stdio.h> #include <string.h> #include <descrip.h> #include <lib$routines.h> #include <rms.h> #include <ssdef.h> #include <starlet.h> #include <stsdef.h> #include <xabitmdef.h> #define exit_on_error(expression,mycode) { \ int \ sys_status; \ sys_status=(expression); \ if ((sys_status & 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 = &itm; itm.xab$b_cod = XAB$C_ITM; itm.xab$b_bln = XAB$K_ITMLEN; itm.xab$l_itemlist = &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 = &file_contents; item_list.itm$l_retlen = &return_length; item_list.terminator = 0; exit_on_error(sys$open (&fab), "OPEN failed"); exit_on_error(sys$display (&fab), "DISPLAY failed"); printf ("file_contents: %08x\n", file_contents); switch ((XAB$M_FILE_CONTENTS & file_contents)>>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; } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 07:49 AM
07-02-2014 07:49 AM
Re: How get and set file caching option in C-Program?
Harmut
Thank you very much for provided sample.
It is working for me now. The issue was a wrong value in item_list.itm$w_itmcod, where I was using XAB$_CACHING_OPTIONS instead of XAB$_CACHING_ATTRIBUTE.
The documentation does not have any references about XAB$_CACHING_ATTRIBUTE.
Dmitriy