ctFILBLK ctFILBLK() allows a user to block access to a file. Declaration The file block routine is declared as follows: NINT ctFILBLK(pTEXT filename,LONG action); Description ctFILBLK() permits a file to be blocked and unblocked by name.
A user must have ADMIN permission to call this function. This routine permits an ADMIN group user to interrupt the file connection between users and the file. This allows, for example, an administrator to block access to a data file, open and update the file in exclusive mode, close the file, remove the file while the c-tree Server continues operating, replace the file with an alternate data file, and finally unblock the file and re-establish the user file connections. Configuration keyword COMPATIBILITY NONADMIN_FILBLK removes the ADMIN requirement. Blocking Files To block a file, the action parameter is comprised of a number of bit fields OR-ed together. Exactly one from each group below must be selected: Select this option.
Select ONE of the following two options.
Select ONE of the following two options.
*ctFBautopen -- The return when the file is unblocked is as if the file had not been shutdown by the server. No information about the client’s file state is maintained upon reopen: no current ISAM position or sequence sets or batches or data filters or file ranges or locks are maintained. Also, if a client has a file open and has updated that file in a transaction and has not yet committed the transaction, then if an administrator blocks that file, that client's transaction is aborted. Unblocking Files If the original blocker quits without unblocking the file(s), then the file(s) will unblocked by default. Optionally, additional action parameters can be specified to modify this behavior:
If the original blocker quits without unblocking the file(s), then the file(s) will not be accessible to any other user until the blocked is cleared. To unblock the file, call ctFILBLK() using the same file name and action set to ctFBunblock.
In the event a file block occurs when a thread connected to the file is in the middle of a transaction that has updated the file, then the transaction is aborted before the block is placed. Some general comments on the ctFILBLK() routine:
Returns ctFILBLK() returns the following return codes:
Please see Appendix A of the Programmer’s Reference Guide for a complete list of c-tree errors. The following pseudocode provides an example of using ctFILBLK(). Example
char[255] filename; strncpy(filename, “mydata.dat”, 10);
rc = (InitISAMXtd(16, 16, 16, 16, 0, "ADMIN", "ADMIN", "FAIRCOMS")) if (rc) printf(“ctree Plus failed to initialize with error %d”, rc);
rc = ctFILBLK(filename, ctFBblock | ctFBisam | ctFBautopen); if (rc) printf(“ctFILBLK failed to block file %s with error %d”, filename, rc);
system(“mv mydata.dat mydata.backup”); system(“mv newdat.dat mydata.dat”);
rc = ctFILBLK(filename, ctFBunblock); if (rc) printf(“ctFILBLK failed to unblock file %s with error %d”, filename, rc);
CloseISAM();
See Also QuietCtree() |
|||||||||||||||||||||||||||||||||||||||||||||||