31.07.2013 Views

CIFS for ClearPath OS 2200 User, Programmer, and Administrator ...

CIFS for ClearPath OS 2200 User, Programmer, and Administrator ...

CIFS for ClearPath OS 2200 User, Programmer, and Administrator ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ClearPath</strong> Enterprise Servers<br />

<strong>CIFS</strong> <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong><br />

<strong>User</strong>, <strong>Programmer</strong>, <strong>and</strong> <strong>Administrator</strong> Reference<br />

Manual<br />

Level 6R3<br />

June 2009 7859 6137–009<br />

unisys<br />

imagine it. done.


NO WARRANTIES OF ANY NATURE ARE EXTENDED BY THIS DOCUMENT. Any product or related in<strong>for</strong>mation<br />

described herein is only furnished pursuant <strong>and</strong> subject to the terms <strong>and</strong> conditions of a duly executed agreement to<br />

purchase or lease equipment or to license software. The only warranties made by Unisys, if any, with respect to the<br />

products described in this document are set <strong>for</strong>th in such agreement. Unisys cannot accept any financial or other<br />

responsibility that may be the result of your use of the in<strong>for</strong>mation in this document or software material, including<br />

direct, special, or consequential damages.<br />

You should be very careful to ensure that the use of this in<strong>for</strong>mation <strong>and</strong>/or software material complies with the laws,<br />

rules, <strong>and</strong> regulations of the jurisdictions with respect to which it is used.<br />

The in<strong>for</strong>mation contained herein is subject to change without notice. Revisions may be issued to advise of such<br />

changes <strong>and</strong>/or additions.<br />

Notice to U.S. Government End <strong>User</strong>s: This is commercial computer software or hardware documentation developed at<br />

private expense. Use, reproduction, or disclosure by the Government is subject to the terms of Unisys st<strong>and</strong>ard<br />

commercial license <strong>for</strong> the products, <strong>and</strong> where applicable, the restricted/limited rights provisions of the contract data<br />

rights clauses.<br />

Unisys <strong>and</strong> <strong>ClearPath</strong> are registered trademarks of Unisys Corporation in the United States <strong>and</strong> other countries.<br />

All other br<strong>and</strong>s <strong>and</strong> products referenced in this document are acknowledged to be the trademarks or registered<br />

trademarks of their respective holders.


<strong>ClearPath</strong> Enterprise<br />

Servers<br />

<strong>CIFS</strong> <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong><br />

<strong>User</strong>, <strong>Programmer</strong>, <strong>and</strong><br />

<strong>Administrator</strong> Reference<br />

Manual<br />

Level 6R3<br />

<strong>ClearPath</strong><br />

Enterprise Servers<br />

<strong>CIFS</strong> <strong>for</strong> <strong>ClearPath</strong><br />

<strong>OS</strong> <strong>2200</strong><br />

<strong>User</strong>,<br />

<strong>Programmer</strong>,<br />

<strong>and</strong><br />

<strong>Administrator</strong><br />

Reference<br />

Manual<br />

Level 6R3<br />

7859 6137–009 7859 6137–009<br />

Bend here, peel upwards <strong>and</strong> apply to spine.


Contents<br />

Section 1. Introduction<br />

What <strong>CIFS</strong> Does ................................................................................... 1–2<br />

Purpose of This Manual ........................................................................ 1–3<br />

Documentation Updates ....................................................................... 1–3<br />

Audience ............................................................................................... 1–3<br />

Notation Conventions ........................................................................... 1–4<br />

File System Structure ........................................................................... 1–5<br />

<strong>OS</strong> <strong>2200</strong> Directory Hierarchy ............................................... 1–6<br />

Non-/<strong>OS</strong><strong>2200</strong> Directory Hierarchy ....................................... 1–7<br />

Data Storage ........................................................................ 1–8<br />

File Packing ........................................................................................... 1–9<br />

Security Considerations ...................................................................... 1–10<br />

Communications Interface .................................................................. 1–11<br />

TIP Considerations .............................................................................. 1–12<br />

Section 2. Managing Files from the Workstation<br />

Networking <strong>CIFS</strong> with Windows NT4/2000/XP/2003/Vista <strong>and</strong><br />

Windows 95/98/Me .......................................................................... 2–1<br />

Creating a Share Directory .................................................................... 2–3<br />

Mapping a Drive to a Share Directory ................................................... 2–4<br />

Opening Share Files Using UNC ........................................................... 2–5<br />

Viewing <strong>CIFS</strong> Directories ...................................................................... 2–7<br />

Section 3. File Concepts<br />

File Definition <strong>and</strong> File Types ................................................................ 3–1<br />

File Names ........................................................................... 3–2<br />

Directory Definition <strong>and</strong> Rules <strong>for</strong> Directories ...................................... 3–4<br />

Rules <strong>for</strong> Creating Directory Entries .................................... 3–4<br />

Diagram of Directories, Files, <strong>and</strong> Links .............................. 3–5<br />

File Hierarchies ..................................................................................... 3–6<br />

Path Names........................................................................................... 3–7<br />

Special Path Name Components ......................................... 3–8<br />

Path Name Resolution .......................................................................... 3–9<br />

Open File Descriptions ........................................................................ 3–11<br />

File Descriptors ................................................................................... 3–13<br />

File Permissions .................................................................................. 3–14<br />

Time In<strong>for</strong>mation <strong>for</strong> Files ................................................................... 3–17<br />

File Attributes ...................................................................................... 3–18<br />

File Mode ............................................................................................ 3–18<br />

File Permissions ................................................................ 3–19<br />

7859 6137–009 iii


Contents<br />

File Format ......................................................................... 3–21<br />

File Type ............................................................................. 3–21<br />

Related Functions ................................................................................ 3–23<br />

File I/O Operations ............................................................................... 3–24<br />

Reading <strong>and</strong> Writing to Files .............................................. 3–24<br />

Directory Entries <strong>and</strong> Streams ........................................... 3–25<br />

Data Translation .................................................................. 3–25<br />

Advisory Record Locks ....................................................... 3–26<br />

Using Pipes ........................................................................ 3–29<br />

Related Functions ............................................................... 3–31<br />

Environment Variables ......................................................................... 3–32<br />

Section 4. Utility Interfaces<br />

Masking with @<strong>CIFS</strong>UT ......................................................................... 4–3<br />

backup ................................................................................................... 4–4<br />

binjar ...................................................................................................... 4–5<br />

cat (type) ................................................................................................ 4–6<br />

cd (chdir) ................................................................................................ 4–7<br />

chmod .................................................................................................... 4–8<br />

chown .................................................................................................. 4–10<br />

cp (copy) .............................................................................................. 4–11<br />

date ...................................................................................................... 4–13<br />

deltree .................................................................................................. 4–14<br />

echo ..................................................................................................... 4–15<br />

help ...................................................................................................... 4–16<br />

keys...................................................................................................... 4–17<br />

ln ......................................................................................................... 4–18<br />

ls (dir) ................................................................................................... 4–19<br />

mkdir (md) ............................................................................................ 4–22<br />

mkfifo ................................................................................................... 4–23<br />

mv (move) ............................................................................................ 4–24<br />

pwd (cd) ............................................................................................... 4–25<br />

rm (del) ................................................................................................. 4–26<br />

rmdir (rd) .............................................................................................. 4–28<br />

set ........................................................................................................ 4–29<br />

setsys .................................................................................................. 4–30<br />

share .................................................................................................... 4–31<br />

size ....................................................................................................... 4–32<br />

touch .................................................................................................... 4–33<br />

unshare ................................................................................................ 4–35<br />

use ....................................................................................................... 4–36<br />

version ................................................................................................. 4–37<br />

xlate ..................................................................................................... 4–38<br />

Section 5. C Program Interfaces<br />

Table of C APIs ...................................................................................... 5–2<br />

access() .................................................................................................. 5–6<br />

chdir() ..................................................................................................... 5–8<br />

chmod() .................................................................................................. 5–9<br />

iv 7859 6137–009


Contents<br />

chown() ............................................................................................... 5–11<br />

clearerr() .............................................................................................. 5–13<br />

close() .................................................................................................. 5–14<br />

closedir() .............................................................................................. 5–15<br />

creat() .................................................................................................. 5–16<br />

dup() .................................................................................................... 5–18<br />

dup2() .................................................................................................. 5–19<br />

end_process() ...................................................................................... 5–20<br />

fclose() ................................................................................................. 5–21<br />

fcntl() ................................................................................................... 5–22<br />

fdatasync() ........................................................................................... 5–33<br />

fdopen() ............................................................................................... 5–34<br />

feof() .................................................................................................... 5–35<br />

ferror() ................................................................................................. 5–36<br />

fflush() ................................................................................................. 5–37<br />

fgetc() .................................................................................................. 5–38<br />

fgetpos() .............................................................................................. 5–39<br />

fgets() .................................................................................................. 5–40<br />

fileno() ................................................................................................. 5–41<br />

fopen() ................................................................................................. 5–42<br />

fprintf() ................................................................................................. 5–44<br />

fputc() .................................................................................................. 5–49<br />

fputs() .................................................................................................. 5–50<br />

fread() .................................................................................................. 5–51<br />

freopen() .............................................................................................. 5–52<br />

fscanf() ................................................................................................ 5–53<br />

fseek() ................................................................................................. 5–57<br />

fsetpos() .............................................................................................. 5–58<br />

fstat() ................................................................................................... 5–59<br />

fsync() .................................................................................................. 5–61<br />

ftell() .................................................................................................... 5–62<br />

ftruncate() ............................................................................................ 5–63<br />

fwrite() ................................................................................................. 5–64<br />

getc() ................................................................................................... 5–65<br />

getchar() .............................................................................................. 5–66<br />

getcwd() .............................................................................................. 5–67<br />

getpwnam() ......................................................................................... 5–68<br />

getpwuid() ........................................................................................... 5–69<br />

gets() ................................................................................................... 5–71<br />

getuid() ................................................................................................ 5–72<br />

istat() ................................................................................................... 5–73<br />

link() ..................................................................................................... 5–75<br />

lseek() .................................................................................................. 5–78<br />

mask() .................................................................................................. 5–81<br />

mkdir() ................................................................................................. 5–82<br />

mkfifo() ................................................................................................ 5–84<br />

new_process() ..................................................................................... 5–86<br />

open() .................................................................................................. 5–87<br />

opendir() .............................................................................................. 5–94<br />

pack() ................................................................................................... 5–95<br />

perror() ................................................................................................. 5–97<br />

pipe() ................................................................................................... 5–98<br />

7859 6137–009 v


Contents<br />

printf() ................................................................................................ 5–100<br />

putc() .................................................................................................. 5–101<br />

putchar() ............................................................................................. 5–102<br />

puts() .................................................................................................. 5–103<br />

read() .................................................................................................. 5–104<br />

readdir() .............................................................................................. 5–107<br />

realpath() ............................................................................................ 5–109<br />

remove() ............................................................................................. 5–110<br />

rename() ............................................................................................. 5–111<br />

rewind() .............................................................................................. 5–115<br />

rewinddir() .......................................................................................... 5–116<br />

rmdir() ................................................................................................ 5–117<br />

scanf() ................................................................................................ 5–118<br />

share() ................................................................................................ 5–119<br />

sprintf() ............................................................................................... 5–120<br />

sscanf() .............................................................................................. 5–121<br />

stat() ................................................................................................... 5–122<br />

strerror() ............................................................................................. 5–123<br />

tmpfile() .............................................................................................. 5–124<br />

tmpnam() ........................................................................................... 5–125<br />

truncate() ............................................................................................ 5–126<br />

umask() .............................................................................................. 5–127<br />

uname() .............................................................................................. 5–129<br />

ungetc() .............................................................................................. 5–130<br />

unlink() ............................................................................................... 5–131<br />

utime() ................................................................................................ 5–132<br />

vfprintf() ............................................................................................. 5–135<br />

vprintf() ............................................................................................... 5–136<br />

vsprintf() ............................................................................................. 5–137<br />

write() ................................................................................................. 5–138<br />

xlate() ................................................................................................. 5–142<br />

Section 6. COBOL Program Interfaces<br />

Table of UCOB COPY PROCS ............................................................... 6–1<br />

Table of UCOB APIs .............................................................................. 6–2<br />

<strong>CIFS</strong>$ACCESS ....................................................................................... 6–5<br />

<strong>CIFS</strong>$CHDIR .......................................................................................... 6–8<br />

<strong>CIFS</strong>$CHMOD ....................................................................................... 6–9<br />

<strong>CIFS</strong>$CHOWN ..................................................................................... 6–12<br />

<strong>CIFS</strong>$CLEARERR ................................................................................. 6–14<br />

<strong>CIFS</strong>$CL<strong>OS</strong>E ........................................................................................ 6–15<br />

<strong>CIFS</strong>$CL<strong>OS</strong>EDIR .................................................................................. 6–17<br />

<strong>CIFS</strong>$CREAT ........................................................................................ 6–19<br />

<strong>CIFS</strong>$DUP ............................................................................................ 6–21<br />

<strong>CIFS</strong>$DUP2 .......................................................................................... 6–23<br />

<strong>CIFS</strong>$FCL<strong>OS</strong>E ...................................................................................... 6–25<br />

<strong>CIFS</strong>$FCNTL ........................................................................................ 6–26<br />

<strong>CIFS</strong>$FDATASYNC .............................................................................. 6–39<br />

<strong>CIFS</strong>$FDOPEN ..................................................................................... 6–41<br />

<strong>CIFS</strong>$FEOF .......................................................................................... 6–43<br />

vi 7859 6137–009


Contents<br />

<strong>CIFS</strong>$FERROR .................................................................................... 6–44<br />

<strong>CIFS</strong>$FFLUSH ..................................................................................... 6–45<br />

<strong>CIFS</strong>$FGETC ....................................................................................... 6–46<br />

<strong>CIFS</strong>$FGETP<strong>OS</strong> .................................................................................. 6–47<br />

<strong>CIFS</strong>$FGETS........................................................................................ 6–48<br />

<strong>CIFS</strong>$FILENO ...................................................................................... 6–49<br />

<strong>CIFS</strong>$FOPEN ....................................................................................... 6–50<br />

<strong>CIFS</strong>$FPRINTF .................................................................................... 6–52<br />

<strong>CIFS</strong>$FPUTC ....................................................................................... 6–57<br />

<strong>CIFS</strong>$FPUTS........................................................................................ 6–58<br />

<strong>CIFS</strong>$FREAD ....................................................................................... 6–59<br />

<strong>CIFS</strong>$FREOPEN .................................................................................. 6–61<br />

<strong>CIFS</strong>$FSCANF ..................................................................................... 6–63<br />

<strong>CIFS</strong>$FSEEK ........................................................................................ 6–67<br />

<strong>CIFS</strong>$FSETP<strong>OS</strong> ................................................................................... 6–68<br />

<strong>CIFS</strong>$FSTAT ........................................................................................ 6–69<br />

<strong>CIFS</strong>$FSYNC ....................................................................................... 6–71<br />

<strong>CIFS</strong>$FTELL ........................................................................................ 6–72<br />

<strong>CIFS</strong>$FTRUNCATE .............................................................................. 6–73<br />

<strong>CIFS</strong>$FWRITE ..................................................................................... 6–74<br />

<strong>CIFS</strong>$GETC ......................................................................................... 6–75<br />

<strong>CIFS</strong>$GETCWD ................................................................................... 6–77<br />

<strong>CIFS</strong>$GETS.......................................................................................... 6–78<br />

<strong>CIFS</strong>$ISTAT ......................................................................................... 6–79<br />

<strong>CIFS</strong>$LINK ........................................................................................... 6–81<br />

<strong>CIFS</strong>$LSEEK ........................................................................................ 6–84<br />

<strong>CIFS</strong>$MASK ........................................................................................ 6–87<br />

<strong>CIFS</strong>$MKDIR ....................................................................................... 6–88<br />

<strong>CIFS</strong>$MKFIFO ..................................................................................... 6–90<br />

<strong>CIFS</strong>$OPEN ......................................................................................... 6–92<br />

<strong>CIFS</strong>$OPENDIR ................................................................................. 6–100<br />

<strong>CIFS</strong>$PACK ....................................................................................... 6–102<br />

<strong>CIFS</strong>$PERROR .................................................................................. 6–104<br />

<strong>CIFS</strong>$PIPE ......................................................................................... 6–105<br />

<strong>CIFS</strong>$PRINTF .................................................................................... 6–107<br />

<strong>CIFS</strong>$PUTC ....................................................................................... 6–108<br />

<strong>CIFS</strong>$PUTCHAR ................................................................................ 6–109<br />

<strong>CIFS</strong>$PUTS........................................................................................ 6–110<br />

<strong>CIFS</strong>$READ ....................................................................................... 6–111<br />

<strong>CIFS</strong>$READDIR ................................................................................. 6–115<br />

<strong>CIFS</strong>$REMOVE ................................................................................. 6–118<br />

<strong>CIFS</strong>$RENAME ................................................................................. 6–119<br />

<strong>CIFS</strong>$REWIND .................................................................................. 6–123<br />

<strong>CIFS</strong>$REWINDDIR ............................................................................ 6–124<br />

<strong>CIFS</strong>$RMDIR ..................................................................................... 6–126<br />

<strong>CIFS</strong>$SCANF ..................................................................................... 6–128<br />

<strong>CIFS</strong>$SHARE ..................................................................................... 6–129<br />

<strong>CIFS</strong>$SPRINTF .................................................................................. 6–130<br />

<strong>CIFS</strong>$SSCANF ................................................................................... 6–131<br />

<strong>CIFS</strong>$STAT ........................................................................................ 6–132<br />

<strong>CIFS</strong>$STDERR ................................................................................... 6–134<br />

<strong>CIFS</strong>$STDIN ...................................................................................... 6–135<br />

7859 6137–009 vii


Contents<br />

Section 7. <strong>CIFS</strong> Client<br />

<strong>CIFS</strong>$STDOUT ................................................................................... 6–136<br />

<strong>CIFS</strong>$STRERROR .............................................................................. 6–137<br />

<strong>CIFS</strong>$TMPFILE .................................................................................. 6–138<br />

<strong>CIFS</strong>$TMPNAM ................................................................................. 6–139<br />

<strong>CIFS</strong>$TRUNCATE ............................................................................... 6–140<br />

<strong>CIFS</strong>$UMASK .................................................................................... 6–141<br />

<strong>CIFS</strong>$UNAME .................................................................................... 6–143<br />

<strong>CIFS</strong>$UNGETC ................................................................................... 6–144<br />

<strong>CIFS</strong>$UNLINK .................................................................................... 6–145<br />

<strong>CIFS</strong>$UTIME ...................................................................................... 6–147<br />

<strong>CIFS</strong>$WRITE ...................................................................................... 6–150<br />

<strong>CIFS</strong>$XLATE ...................................................................................... 6–155<br />

Example Program .............................................................................. 6–157<br />

Accessing a Remote System ................................................................ 7–1<br />

Using Passwords ................................................................................... 7–3<br />

Section 8. ZIPUT Processor<br />

Using the ZIPUT Processor ................................................................... 8–1<br />

ZIPUT Arguments .................................................................................. 8–2<br />

Section 9. Administration<br />

<strong>CIFS</strong> Installation Overview .................................................................... 9–1<br />

Directory Synchronization ...................................................................... 9–2<br />

<strong>CIFS</strong> Subsystem <strong>User</strong> ID ....................................................................... 9–4<br />

Populate ................................................................................................. 9–4<br />

Starting the <strong>CIFS</strong> Background Run ........................................................ 9–5<br />

Stopping the <strong>CIFS</strong> Subsystem <strong>and</strong> Background Run ............................ 9–7<br />

<strong>CIFS</strong> Background Run Options .............................................................. 9–8<br />

<strong>CIFS</strong> Background Run Console Keyins .................................................. 9–9<br />

<strong>CIFS</strong> Backup Procedure ....................................................................... 9–10<br />

<strong>CIFS</strong> File Security En<strong>for</strong>cement ........................................................... 9–11<br />

<strong>CIFS</strong> Network Access Security ............................................................ 9–12<br />

Local <strong>OS</strong> <strong>2200</strong> Authentication ............................................................. 9–13<br />

Network Authentication ....................................................................... 9–14<br />

<strong>OS</strong> <strong>2200</strong> <strong>User</strong> ID Requirements .......................................................... 9–18<br />

LAN Manager Authentication Level ..................................................... 9–20<br />

Environment Variables ......................................................................... 9–21<br />

File Filtering ......................................................................................... 9–26<br />

Appendix A. Limitations, Considerations, <strong>and</strong> Restrictions<br />

Appendix B. Error Codes<br />

Glossary ............................................................................................. 1<br />

viii 7859 6137–009


Contents<br />

Index ............................................................................................. 1<br />

7859 6137–009 ix


Contents<br />

x 7859 6137–009


Figures<br />

9–1. Network Authentication Menu Items .............................................................. 9–15<br />

9–2. Example Fully-Qualified Network <strong>User</strong> Name ................................................. 9–17<br />

7859 6137–009 xi


Figures<br />

xii 7859 6137–009


Section 1<br />

Introduction<br />

This guide describes <strong>CIFS</strong> <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong>, an implementation of the Common<br />

Internet File System (<strong>CIFS</strong>) specification that allows access to <strong>OS</strong> <strong>2200</strong> files through<br />

st<strong>and</strong>ard Internet protocols.<br />

<strong>CIFS</strong> permits direct access to files stored in <strong>OS</strong> <strong>2200</strong> through SMB clients like Windows<br />

Explorer. <strong>User</strong>s can move, copy, delete, <strong>and</strong> display properties of their <strong>OS</strong> <strong>2200</strong> files.<br />

They can also edit files with Notepad, Word, image processors, <strong>and</strong> so on, <strong>and</strong> save<br />

changes to the files. Using Windows drag-<strong>and</strong>-drop functions, users can copy or move<br />

files between their workstation <strong>and</strong> <strong>OS</strong> <strong>2200</strong>.<br />

The <strong>CIFS</strong> specification is created by Microsoft Corporation <strong>and</strong> is based on the existing<br />

Server Messages Block (SMB) protocol. SMB is a client/server request/response<br />

protocol <strong>for</strong> sharing files, printers, serial ports, <strong>and</strong> communication abstractions.<br />

<strong>Programmer</strong>s access <strong>CIFS</strong> services <strong>and</strong> Application Program Interfaces (APIs) by calling<br />

them as functions from a C compiler <strong>and</strong> COBOL compiler program. Most services can<br />

also be accessed through utility comm<strong>and</strong>s.<br />

<strong>CIFS</strong> includes four components: the <strong>CIFS</strong> Host Infrastructure subsystem (<strong>CIFS</strong>HI), the<br />

<strong>CIFS</strong> Library (<strong>CIFS</strong>LIB), the <strong>CIFS</strong> Utility (<strong>CIFS</strong>UT), <strong>and</strong> the ZIP Utility (ZIPUT). The <strong>CIFS</strong>HI<br />

component includes the communications layers necessary <strong>for</strong> a remote client to use<br />

<strong>CIFS</strong> on <strong>OS</strong> <strong>2200</strong> <strong>and</strong> <strong>for</strong> <strong>OS</strong> <strong>2200</strong> programs to access files on remote hosts, as well as<br />

the file system structure <strong>and</strong> host APIs. <strong>CIFS</strong>LIB consists of a C compiler <strong>and</strong> COBOL<br />

compiler-callable layer of interfaces to <strong>CIFS</strong>HI as well as I/O stream h<strong>and</strong>ling functions.<br />

<strong>CIFS</strong>UT provides a simple comm<strong>and</strong>-line interface to <strong>CIFS</strong> capabilities. ZIPUT<br />

manipulates ZIP files or other archives using the ZIP file <strong>for</strong>mat.<br />

<strong>CIFS</strong> supports Windows 95/98/Me, Windows NT4/2000/XP/2003/Vista, <strong>and</strong> other SMB<br />

clients (such as Samba). See Appendix A, “Limitations, Considerations, <strong>and</strong><br />

Restrictions.”<br />

7859 6137–009 1–1


Introduction<br />

What <strong>CIFS</strong> Does<br />

When <strong>CIFS</strong> is installed on <strong>OS</strong> <strong>2200</strong>, it sets up an alternative file system with a P<strong>OS</strong>IX-like<br />

hierarchical directory structure (an inverted tree-like structure with branches from the<br />

system root directory to each file <strong>and</strong> directory) that supports long file <strong>and</strong> directory<br />

names. A background run populates a special directory, called /os<strong>2200</strong>, with aliases <strong>for</strong><br />

all <strong>OS</strong> <strong>2200</strong> files (except certain system files) found in the Exec Master File Directories<br />

(MFD).<br />

The <strong>CIFS</strong> installation process also installs a text-based utility, @<strong>CIFS</strong>UT that provides a<br />

comm<strong>and</strong> line interface to manipulate files <strong>and</strong> directories within the <strong>CIFS</strong> file system.<br />

The utility accepts comm<strong>and</strong>s modeled after those typically available in Windows<br />

95/98/Me <strong>and</strong> Windows NT4/2000/XP/2003/Vista systems, <strong>and</strong> other systems similar to<br />

UNIX.<br />

Using @<strong>CIFS</strong>UT, users can create non-/os<strong>2200</strong> directories <strong>and</strong> files. They can also make<br />

directories visible on a network using the <strong>CIFS</strong> share interface. Once a share directory is<br />

created, users can manage the files <strong>and</strong> directories to which they have the necessary<br />

access permissions. Using Windows Explorer, users can move, copy, delete, edit (using<br />

Windows programs), save, <strong>and</strong> display the properties of any file in a share directory<br />

(again, assuming they have the correct permissions).<br />

<strong>CIFS</strong> creates an alias <strong>for</strong> each file added to a non-/os<strong>2200</strong> directory. This alias has a<br />

native <strong>OS</strong> <strong>2200</strong> file name <strong>and</strong> appears in the /os<strong>2200</strong> directory. There<strong>for</strong>e, all the files in<br />

the non-/os<strong>2200</strong> hierarchy has two file names in <strong>CIFS</strong>: the name assigned by the user<br />

<strong>and</strong> a native <strong>OS</strong> <strong>2200</strong> name.<br />

<strong>CIFS</strong> continuously maintains its file structure by monitoring system log entries to keep<br />

the /os<strong>2200</strong> directory in sync with the Exec MFDs. As a result, every file that is<br />

cataloged, deleted, or has its accessibility changed in an Exec MFD automatically causes<br />

the associated update in the <strong>CIFS</strong> directories. To ensure the <strong>CIFS</strong> directories are brought<br />

up to date, a synchronization process is run every time the <strong>CIFS</strong> subsystem initializes<br />

<strong>and</strong> at the site administrator’s discretion.<br />

The following diagram shows an example file structure created by <strong>CIFS</strong>. Note that the<br />

element “myfile” can be accessed by the path name /gjs3/Directory1/myfile or by its<br />

native <strong>OS</strong> <strong>2200</strong> name /os<strong>2200</strong>/qual/file/myfile.<br />

1–2 7859 6137–009


Introduction<br />

When a file is created in the non-/os<strong>2200</strong> directory hierarchy, <strong>CIFS</strong> normally stores the<br />

file data as an <strong>OS</strong> <strong>2200</strong> SDF element. It uses <strong>OS</strong> <strong>2200</strong> file <strong>and</strong> element names<br />

consisting of the qualifier SYS$<strong>CIFS</strong>$, an internally generated file name, <strong>and</strong> the<br />

requested name <strong>and</strong> extension as element <strong>and</strong> version, if possible. If the specified file<br />

name is not a legal <strong>OS</strong> <strong>2200</strong> element name (it is too long or contains illegal characters),<br />

<strong>CIFS</strong> generates a 12/12 alias <strong>for</strong> the <strong>OS</strong> <strong>2200</strong> element <strong>and</strong> version.<br />

Purpose of This Manual<br />

This manual supports the Common Interface File System (<strong>CIFS</strong>) implementation <strong>for</strong> the<br />

<strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> by describing <strong>CIFS</strong>. It includes user, programmer, <strong>and</strong> administrator<br />

in<strong>for</strong>mation, <strong>and</strong> is intended <strong>for</strong> use with all supported <strong>OS</strong> <strong>2200</strong> systems.<br />

Use this manual to look up specific topics or read it sequentially to learn about unfamiliar<br />

topics. The guide contains in<strong>for</strong>mation to introduce <strong>CIFS</strong>, define terminology, <strong>and</strong><br />

summarize functions.<br />

Documentation Updates<br />

Audience<br />

otherfile<br />

gjs3<br />

This document contains all the in<strong>for</strong>mation that was available at the time of publication.<br />

Changes identified after release of this document are included in problem list entry (PLE)<br />

18569205. To obtain a copy of the PLE, contact your Unisys representative or access the<br />

current PLE from the Unisys Product Support Web site:<br />

http://www.support.unisys.com/all/ple/18569205<br />

/os<strong>2200</strong><br />

Note: If you are not logged into the Product Support site, you will be asked to do so.<br />

This manual is intended <strong>for</strong> <strong>OS</strong> <strong>2200</strong> end users, system administrators, C <strong>and</strong> COBOL<br />

programmers whose applications must be portable or who wish to use <strong>CIFS</strong> capabilities.<br />

<strong>User</strong>s must have a good underst<strong>and</strong>ing of the <strong>OS</strong> <strong>2200</strong> file structure but not necessarily<br />

the <strong>CIFS</strong> specification. Knowledge of Windows or P<strong>OS</strong>IX-compliant file systems can be<br />

useful.<br />

7859 6137–009 1–3<br />

/<br />

Directory1<br />

myfile myfile<br />

file<br />

qual


Introduction<br />

Notation Conventions<br />

The following notation <strong>and</strong> organizational conventions are used throughout this manual:<br />

• Brackets ([ ])<br />

Brackets enclose optional arguments. The brackets themselves are not coded when<br />

using a <strong>CIFS</strong> interface.<br />

• Vertical bar (|)<br />

A vertical bar means the arguments are mutually exclusive <strong>and</strong> you can use only one.<br />

Using two or more mutually exclusive arguments produces undefined results, unless<br />

otherwise stated.<br />

• Ellipsis (...)<br />

An ellipsis means the previous syntax (either an option <strong>and</strong> its option argument or an<br />

oper<strong>and</strong>) can occur one or more times.<br />

If the ellipsis follows syntax that is enclosed in brackets, the syntax in the brackets<br />

can occur zero or more times. Do not repeat an option that does not have an option<br />

argument because the results are undefined, unless otherwise stated.<br />

• Options<br />

− Hyphen (P<strong>OS</strong>IX <strong>for</strong>mat) or a <strong>for</strong>ward slash (Windows <strong>for</strong>mat)<br />

A hyphen or a <strong>for</strong>ward slash identifies the argument that follows it as an option;<br />

the delimiter is there<strong>for</strong>e required.<br />

− Grouped order<br />

Individual options are usually grouped ahead of options that take arguments.<br />

Only one hyphen is required to precede a group of options.<br />

− Alphabetical order<br />

Within a group (that is, options with or without arguments), options are usually<br />

listed alphabetically <strong>for</strong> convenience, but have no implied relationships unless<br />

order dependencies are stated. When used, independent options can appear in<br />

any order.<br />

− Space<br />

• Oper<strong>and</strong>s<br />

A space shown between an option <strong>and</strong> its argument in the synopsis is optional<br />

unless otherwise stated. However, including a blank always results in correct<br />

code <strong>and</strong> is recommended <strong>for</strong> portable applications. When the synopsis shows<br />

no space between an option <strong>and</strong> its argument, the argument must immediately<br />

follow the option.<br />

− Order<br />

The order of oper<strong>and</strong>s is significant.<br />

1–4 7859 6137–009


− Blanks<br />

A blank (sequence of spaces) is required to separate oper<strong>and</strong>s.<br />

• Multiple lines<br />

Introduction<br />

Complex or mutually exclusive cases can be shown on separate lines, especially if<br />

mutually exclusive arguments affect the validity of other options <strong>and</strong> oper<strong>and</strong>s <strong>for</strong><br />

that case.<br />

• Indentation<br />

Indented lines merely continue the argument <strong>and</strong> do not imply new input lines.<br />

When used, these lines appear on a single logical line.<br />

• Default case<br />

For some interfaces, the synopsis contains the default case showing the values used<br />

<strong>for</strong> certain options when you call the utility without arguments. Default values are<br />

also included in the appropriate option descriptions.<br />

• Graphics symbols<br />

The following symbols are used in graphics throughout this document:<br />

− Circles are usually used to represent processes <strong>and</strong> directories.<br />

− Cylinders or rectangles are used to represent files.<br />

• Variable entities in syntax appear in italics as in the following example, where path<br />

<strong>and</strong> mode are the variables:<br />

int creat(const char * path, mode_t mode);<br />

• Symbolic constants include attributes, valid values <strong>for</strong> function variables, privileges,<br />

<strong>and</strong> defined keywords; they are in uppercase type. Examples include S_1100SDF<br />

<strong>and</strong> O_CREAT.<br />

• Function names, st<strong>and</strong>ard field names in structures, <strong>and</strong> st<strong>and</strong>ard variable names are<br />

in lowercase type. Function names are always followed by parentheses; field names<br />

can contain underscores. Some examples are<br />

− The open() function<br />

− The st_mode member of the stat structure<br />

− The errno variable<br />

File System Structure<br />

<strong>CIFS</strong> uses a P<strong>OS</strong>IX-like hierarchical directory structure that supports long file <strong>and</strong><br />

directory names. Names in each level are separated by a <strong>for</strong>ward slash (/) character.<br />

Each file <strong>and</strong> directory name can be up to 4095 bytes long. When creating files <strong>and</strong><br />

directories, <strong>CIFS</strong> maintains the case of alphabetic characters but ignores case based on<br />

the ISO 8859-1 character set when accessing existing names.<br />

7859 6137–009 1–5


Introduction<br />

A reference to a <strong>CIFS</strong> file or directory that begins with a <strong>for</strong>ward slash is considered an<br />

absolute reference. The path to the file or directory starts at the root of the file system<br />

hierarchy. A reference that does not begin with a slash is interpreted as relative to the<br />

caller’s current working directory. (<strong>CIFS</strong> supplies several mechanisms <strong>for</strong> changing the<br />

current working directory; see below <strong>for</strong> details.) Directory references that consist only<br />

of one or more periods are interpreted as designating directory entries in the hierarchy.<br />

One period indicates the current directory in the reference, two periods indicate the<br />

parent of the current directory in the reference, three periods indicate the parent’s<br />

parent, <strong>and</strong> so on.<br />

For example, the following utility comm<strong>and</strong><br />

cd /a/b/c/d/e/f/...<br />

sets the current working directory to /a/b/c/d.<br />

<strong>OS</strong> <strong>2200</strong> Directory Hierarchy<br />

<strong>CIFS</strong> provides access to all <strong>OS</strong> <strong>2200</strong> files <strong>and</strong> elements through a special directory:<br />

/os<strong>2200</strong>. During <strong>CIFS</strong> initialization, all <strong>OS</strong> <strong>2200</strong> files (except certain system files) are<br />

automatically added to the /os<strong>2200</strong> directory. <strong>CIFS</strong> monitors changes to the <strong>OS</strong> <strong>2200</strong> file<br />

environment <strong>and</strong> updates the /os<strong>2200</strong> hierarchy accordingly.<br />

Files <strong>and</strong> elements are addressed within the /os<strong>2200</strong> directory with the following name<br />

mapping:<br />

/os<strong>2200</strong>/[mfd#]qual/file[([+|-]n)][/elt[.[ver][.type]]]<br />

where:<br />

os<strong>2200</strong> is the special reserved directory name.<br />

mfd# is the <strong>OS</strong> <strong>2200</strong> Master File Directory (MFD), either STD# or SHARED#<br />

qual is the <strong>OS</strong> <strong>2200</strong> file qualifier.<br />

file is the <strong>OS</strong> <strong>2200</strong> file name.<br />

n is an optional absolute or relative F-cycle.<br />

elt is the <strong>OS</strong> <strong>2200</strong> program file element name.<br />

ver is the <strong>OS</strong> <strong>2200</strong> program file element version.<br />

type is an optional <strong>OS</strong> <strong>2200</strong> element type (one of the following: rel, abs, omn); a<br />

symbolic (SDF) element is used if a type is not explicitly specified.<br />

If an MFD is specified, only a file or directory in the requested MFD (STD# or SHARED#)<br />

can be accessed. If no MFD is specified, selection depends on the Exec configuration<br />

parameters DOUBLE_MFD_SEARCH <strong>and</strong> DIRECTORY_SELECTION, as well as the<br />

user’s current @QUAL,D setting. If an F-cycle is not specified, the latest F-cycle is<br />

assumed. If an element name is not specified, an <strong>OS</strong> <strong>2200</strong> data or program file is<br />

assumed. If neither an element version nor an element type is specified, the period<br />

be<strong>for</strong>e the version field must also be omitted.<br />

1–6 7859 6137–009


Introduction<br />

New <strong>OS</strong> <strong>2200</strong> data <strong>and</strong> program files can be created in the /os<strong>2200</strong> directory hierarchy,<br />

but the qualifier <strong>and</strong> file name must con<strong>for</strong>m to the <strong>OS</strong> <strong>2200</strong> qualifier <strong>and</strong> file name<br />

syntax rules: 12 characters or less consisting of any combination of letters, numbers,<br />

hyphen (-), <strong>and</strong> the dollar sign ($). Also, all /os<strong>2200</strong> names are maintained in lower case,<br />

but may be referenced in upper, lower, or mixed case.<br />

Element names need not con<strong>for</strong>m to <strong>OS</strong> <strong>2200</strong> syntax rules. When needed, <strong>CIFS</strong><br />

creates a syntactically valid alias so the element can be accessed outside of <strong>CIFS</strong>.<br />

A file reference in the /os<strong>2200</strong> hierarchy cannot specify just a qualifier.<br />

Either a qualifier <strong>and</strong> file name (<strong>for</strong> <strong>OS</strong> <strong>2200</strong> data files), or a qualifier, file name, <strong>and</strong><br />

element (<strong>for</strong> elements in <strong>OS</strong> <strong>2200</strong> program files) must be present in the absolute<br />

reference or in the current working directory plus relative reference. However, a<br />

directory reference in the /os<strong>2200</strong> hierarchy can operate at any level above the element.<br />

Links are allowed to target files or elements in the /os<strong>2200</strong> directory hierarchy, but no<br />

links can be created from the /os<strong>2200</strong> directory hierarchy. For example,<br />

/mydir/link-to-os<strong>2200</strong>-file can be a link pointing to /os<strong>2200</strong>/qual/file, but /os<strong>2200</strong>/qual/link<br />

is not allowed.<br />

Access permissions <strong>for</strong> elements are initially set to those of the containing program file.<br />

<strong>CIFS</strong> utility comm<strong>and</strong>s <strong>and</strong> program interfaces can be used to make element<br />

permissions different from those of the containing program file, but such changes are<br />

not effective outside of <strong>CIFS</strong> (when accessed through traditional <strong>OS</strong> <strong>2200</strong> I/O interfaces).<br />

Non-/<strong>OS</strong><strong>2200</strong> Directory Hierarchy<br />

All directory names starting with a <strong>for</strong>ward slash (/) <strong>and</strong> not /os<strong>2200</strong> are in the<br />

non-/os<strong>2200</strong> directory hierarchy. Directories <strong>and</strong> files within this hierarchy can have<br />

names up to 4095 bytes long. The value of each byte must be in the range 0x01 through<br />

0xFF. Spaces, periods, quotation marks, parentheses, so on, as well as many unprintable<br />

characters, are allowed. A <strong>for</strong>ward slash has special meaning, in that it separates the<br />

levels of the hierarchy. Using characters other than the normal ASCII printable set can<br />

cause difficulty in some application or client programs.<br />

Most files in the non-/os<strong>2200</strong> directory hierarchy automatically appear in the /os<strong>2200</strong><br />

directory hierarchy, since <strong>CIFS</strong> files are normally stored as <strong>OS</strong> <strong>2200</strong> files <strong>and</strong> elements.<br />

When a file is created in the non-/os<strong>2200</strong> directory hierarchy, <strong>CIFS</strong> uses <strong>OS</strong> <strong>2200</strong> file <strong>and</strong><br />

element names consisting of the qualifier SYS$<strong>CIFS</strong>$, an internally generated file name,<br />

<strong>and</strong> the requested name <strong>and</strong> extension as element <strong>and</strong> version, if possible. If the<br />

specified file name is not a legal <strong>OS</strong> <strong>2200</strong> element name (it is too long or contains illegal<br />

characters), <strong>CIFS</strong> generates a 12/12 alias <strong>for</strong> the <strong>OS</strong> <strong>2200</strong> element <strong>and</strong> version. The USE<br />

comm<strong>and</strong> of <strong>CIFS</strong>UT is available to attach an <strong>OS</strong> <strong>2200</strong> internal name to a <strong>CIFS</strong>-generated<br />

file name. This makes it easier <strong>for</strong> non-<strong>CIFS</strong>-aware <strong>2200</strong> programs to access<br />

<strong>CIFS</strong>-created files.<br />

Files in the /dev directory (there are only four) do not have aliases in the /os<strong>2200</strong><br />

hierarchy, nor are they accessible from the network. The /dev/tty file is used to represent<br />

the terminal or symbiont streams associated with each run utilizing <strong>CIFS</strong>; read <strong>and</strong> write<br />

requests to /dev/tty are automatically directed to the current READ$ <strong>and</strong> PRINT$ files or<br />

devices of the requesting program. The /dev/null file is a “bit bucket”: read requests<br />

always return zero byes; write requests always complete normally, but the data are<br />

7859 6137–009 1–7


Introduction<br />

Data Storage<br />

discarded. The /dev/r<strong>and</strong>om <strong>and</strong> /dev/ur<strong>and</strong>om files are a source of r<strong>and</strong>om bytes that<br />

can be used <strong>for</strong> such purposes as modeling or cryptography. Note that /dev/r<strong>and</strong>om <strong>and</strong><br />

/dev/ur<strong>and</strong>om can only be read from, not written to.<br />

Files accessed through <strong>CIFS</strong> are normally stored as St<strong>and</strong>ard Data Format (SDF)<br />

elements in <strong>OS</strong> <strong>2200</strong> program files. The environment variable, <strong>CIFS</strong>$NEXTFILE, can be<br />

used to <strong>for</strong>ce storage in a data file, if required. The SDF <strong>for</strong>mat is transparent to network<br />

clients <strong>and</strong> programs using the <strong>CIFS</strong> APIs because on read operations, <strong>CIFS</strong> always<br />

returns the exact byte sequences supplied on write requests. To facilitate data access by<br />

programs using traditional <strong>OS</strong> <strong>2200</strong> I/O mechanisms, <strong>CIFS</strong> interprets various line<br />

termination sequences as record breaks.<br />

• A single line feed (0x0A) – the Linux/UNIX st<strong>and</strong>ard compatible with UCS Runtime<br />

System I/O h<strong>and</strong>ling<br />

• A carriage return line feed sequence (0x0D <strong>and</strong> 0x0A) – typically used by Windows<br />

text files<br />

• A single carriage return (0x0D) – the normal Apple Mac <strong>OS</strong> line terminator<br />

Files using terminators other than a plain line feed can be filtered to make them<br />

compatible with Linux/UNIX based programs by using the w-option of the <strong>CIFS</strong>UT cp <strong>and</strong><br />

copy comm<strong>and</strong>s. There is no limit on record length, though files are limited to<br />

approximately 29 MB when stored as st<strong>and</strong>ard <strong>OS</strong> <strong>2200</strong> elements (34 GB in Large<br />

Element Program Files (LEPF)).<br />

<strong>CIFS</strong> always writes SDF files <strong>and</strong> elements using 9-bit or 18-bit characters, but is not<br />

normally concerned with the character set being used in any particular file. Similarly,<br />

<strong>CIFS</strong> normally passes back the input bytes from SDF data records directly to the caller.<br />

However, <strong>for</strong> Fieldata files, <strong>CIFS</strong> converts the characters to ASCII be<strong>for</strong>e storing them in<br />

the caller’s buffer; <strong>CIFS</strong> never writes Fieldata. Also, a user can specify translation to or<br />

from UNICODE by setting appropriate attributes on a directory with the <strong>CIFS</strong>UT utility or<br />

through a program interface.<br />

<strong>CIFS</strong> determines the size of a System Data Format (SDF) file or element based on the<br />

number of bytes contained in the data records, plus one or two (depending on the type<br />

of line terminator) <strong>for</strong> each data record that is not continued. This determination occurs<br />

the first time a file is read, <strong>and</strong> is remembered internally by <strong>CIFS</strong> thereafter. Note that a<br />

file may be updated outside <strong>CIFS</strong> in such a way that the update is not readily detectable;<br />

<strong>for</strong> example, rewriting an SDF data file without changing the number of tracks it<br />

occupies. When this happens, the remembered size might not reflect the new size of<br />

the file. You can use the truncate() program interface or the <strong>CIFS</strong>UT size comm<strong>and</strong> to<br />

in<strong>for</strong>m <strong>CIFS</strong> to recalculate the size when such an update is made.<br />

<strong>CIFS</strong> recognizes the file name extensions .rel, .abs, <strong>and</strong> .omn as indicative of the<br />

<strong>OS</strong> <strong>2200</strong> element types relocatable, executable, <strong>and</strong> omnibus, respectively. Files with<br />

these extensions are h<strong>and</strong>led with direct, rather than SDF, I/O operations. These special<br />

extensions must follow one other period somewhere in the file name in order to be<br />

interpreted as element types. For example, the name “program.abs” would be stored in<br />

SDF <strong>for</strong>mat with the version “abs,” whereas ”program.ver.abs” would be treated as an<br />

1–8 7859 6137–009


Introduction<br />

<strong>OS</strong> <strong>2200</strong> executable with the name ‘program/ver”; ”program..abs” would refer to the<br />

executable element ”program” (no version).<br />

The additional element-specific in<strong>for</strong>mation kept in a program file table of contents <strong>for</strong> a<br />

relocatable or executable element is appended to the text of the element when read by<br />

<strong>CIFS</strong>. Likewise, the caller must provide the same additional in<strong>for</strong>mation on writes of<br />

relocatable or executable elements, following the last byte of element text.<br />

See the following table <strong>for</strong> the <strong>for</strong>mat of the appended data.<br />

Type Bytes Contents<br />

.rel 4<br />

1<br />

3<br />

.abs 4<br />

File Packing<br />

1<br />

1<br />

1<br />

1<br />

Not used<br />

Flags (least significant 9 bits)<br />

Preamble length, broken into three 6-bit fields<br />

Element table entry word 6<br />

Flags (least significant 9 bits)<br />

Sub-type<br />

Sub-sub-type<br />

ZOOM header offset<br />

If the element Table of Contents (TOC) of the program file or the text area fills up while<br />

writing a <strong>CIFS</strong> file stored as an element, <strong>CIFS</strong> attempts to automatically pack the<br />

underlying <strong>OS</strong> <strong>2200</strong> program file. (This includes user-cataloged program files.) Packing<br />

recovers unused TOC space <strong>and</strong> file text space taken up by deleted elements in the<br />

program file. The action is directly analogous to a FURPUR @PACK. Any existing<br />

relocatable <strong>and</strong> PROC entry point tables are preserved.<br />

Note: The pack operation requires <strong>CIFS</strong> to have exclusive use (@ASG, AX) of the<br />

program file while it is being packed. There<strong>for</strong>e, the program file must not be assigned to<br />

any run or name section or the pack cannot be done. This includes the run doing the<br />

write that triggers the pack. If exclusive use is not obtained then the pack operation is<br />

not per<strong>for</strong>med.<br />

The <strong>CIFS</strong> pack is a safe pack, even if the system goes down or an X-keyin to the run is<br />

done during the pack; the contents of the program file are preserved, except in<br />

extremely rare circumstances. If the program file’s TOC is actually full of active (not<br />

deleted) elements <strong>and</strong> is about to overflow, the program file can also be converted<br />

during the pack operation to a Large Program File (LPF). This program file has the<br />

capacity to hold a maximum of 26,146 elements. A program file can also be packed by<br />

use of the -p option of the <strong>CIFS</strong>UT touch comm<strong>and</strong>, or by calling the pack or <strong>CIFS</strong>$PACK<br />

APIs. A <strong>CIFS</strong>UT “touch -pr directory-name” comm<strong>and</strong> packs all the underlying program<br />

files of a whole directory tree.<br />

7859 6137–009 1–9


Introduction<br />

Security Considerations<br />

<strong>CIFS</strong> uses st<strong>and</strong>ard <strong>OS</strong> <strong>2200</strong> security mechanisms, but extends them where necessary<br />

to match st<strong>and</strong>ard P<strong>OS</strong>IX usage. For example, <strong>CIFS</strong> maintains access controls <strong>for</strong><br />

elements, whereas st<strong>and</strong>ard <strong>OS</strong> <strong>2200</strong> does not.<br />

<strong>CIFS</strong> grants access to a given file or directory based on a combination of the effective<br />

user ID of the requester, access permissions, <strong>and</strong> file attributes. For owned files, the<br />

effective user ID is the actual user ID of the requesting run. For unowned files, the<br />

effective user ID is the project or account of the requesting run, determined by the Exec<br />

configuration tag PRIBYACCNT. Any read or write keys needed to access an unowned<br />

file must be specified by the <strong>CIFS</strong>$KEYS environment variable (see Section 4).<br />

<strong>CIFS</strong> supports the following access permissions.<br />

read Allows reading of the file data or directory contents<br />

write Allows writing of the file data or updating of the directory, <strong>and</strong> deletion of<br />

the file or directory<br />

execute Allows the file data to be loaded <strong>for</strong> execution, but not necessarily read<br />

(however, there is no mechanism <strong>for</strong> the Exec to utilize the <strong>CIFS</strong> capability<br />

to open just <strong>for</strong> execute); allows a directory to be used in the reference to a<br />

lower level directory or file<br />

1–10 7859 6137–009


Communications Interface<br />

Introduction<br />

<strong>CIFS</strong> allows network access to its file system, <strong>and</strong> there<strong>for</strong>e to all <strong>OS</strong> <strong>2200</strong> files, by<br />

means of Communications Application Program Interface <strong>and</strong> either CMS 1100 or<br />

Communications Plat<strong>for</strong>m, or both. By default, <strong>CIFS</strong> uses only installation mode A of<br />

Communications Application Program Interface; however, the site administrator can<br />

select other or multiple installation modes by setting a value <strong>for</strong> the <strong>CIFS</strong>$COMAPI<br />

environment variable. <strong>CIFS</strong> listens <strong>for</strong> connection requests on TCP ports 139 <strong>and</strong> 445 of<br />

all communications interfaces configured in all specified Communications Application<br />

Program Interface installation modes. File system connection requests are honored only<br />

<strong>for</strong> previously established connection points, also known as shares. <strong>OS</strong> <strong>2200</strong> users can<br />

create shares with the <strong>CIFS</strong>UT share comm<strong>and</strong>, or by means of the _cifs_share() API.<br />

<strong>CIFS</strong> utilizes the Server Message Block (SMB) protocol, which has been used in<br />

networking since the early 1980s. The protocol is widely used <strong>and</strong> has evolved to meet<br />

the needs <strong>and</strong> dem<strong>and</strong>s of growing communication environments. Vendor support <strong>for</strong><br />

the full SMB specification (other than by Microsoft) is limited since much of the original<br />

protocol is referred to as obsolete. These obsolete portions have been replaced by<br />

alternate <strong>and</strong> more robust client/server SMB exchange definitions. Although the protocol<br />

allows <strong>for</strong> device function control, pipes, print control, <strong>and</strong> mail slot access, the<br />

implementation of SMB on <strong>OS</strong> <strong>2200</strong> is limited to data storage (disk share) access.<br />

Applications running on Windows workstations have access to data maintained on<br />

<strong>OS</strong> <strong>2200</strong> systems through st<strong>and</strong>ard Microsoft or Linux networking redirectors on the<br />

workstation or server. These redirectors make network requests to known access points<br />

on file servers, referred to as shares. The share names are maintained by <strong>CIFS</strong> as<br />

reference names associated with a directory. By using a share reference, an SMB client<br />

can access a point in the <strong>CIFS</strong> controlled data storage. Only authenticated access is<br />

permitted; <strong>CIFS</strong> supports NT LAN Manager (NTLM), NTLMv2, <strong>and</strong> Kerberos<br />

authentication. Data access privileges are the same as those the user has through<br />

dem<strong>and</strong> or batch access to the <strong>OS</strong> <strong>2200</strong> system.<br />

Similarly, <strong>CIFS</strong> provides the means <strong>for</strong> <strong>OS</strong> <strong>2200</strong> programs to directly access files on any<br />

remote host that implements an SMB server. Such remote hosts include <strong>OS</strong> <strong>2200</strong>, MCP,<br />

Windows (all versions), UNIX, Linux, z/<strong>OS</strong>, <strong>and</strong> so on. This SMB client capability, in many<br />

cases, eliminates the need to transfer files between systems.<br />

Normal network transmissions use only 8 bits out of each <strong>OS</strong> <strong>2200</strong> quarter word, which<br />

is adequate <strong>for</strong> all character-based data. However, when relocatable or absolute<br />

elements, or omnibus elements with an extension of .omn, are transmitted over a<br />

network connection, <strong>CIFS</strong> uses a 6-bit <strong>for</strong>mat to ensure that all bits of such elements are<br />

sent or received. Consequently, these binary elements appear 50 percent larger on the<br />

network than they do on the <strong>OS</strong> <strong>2200</strong> host, <strong>and</strong> 50 percent more data is transferred on<br />

the connection than on an internal file copy.<br />

7859 6137–009 1–11


Introduction<br />

TIP Considerations<br />

Transaction processing (TIP) transactions do not normally use any file system other than<br />

TIP File Control or Universal Data System (UDS). Using other file systems generally<br />

involves more overhead than is acceptable <strong>for</strong> a transaction environment. Consequently,<br />

not all <strong>CIFS</strong> capabilities can be used by TIP transactions. In particular, the Exec imposes<br />

significant restrictions on the use of environment variables by TIP transactions, so any<br />

<strong>CIFS</strong> operations that are dependent on environment variable settings results in the<br />

default action being taken.<br />

TIP transactions that access <strong>CIFS</strong> files must execute with a user ID that has access to<br />

<strong>CIFS</strong> files. A TIP security user ID (TIP_SECURITY_USERID) must be configured on<br />

systems that are not under TIP session control. All systems that execute Resident<br />

Transaction Program System (RTPS) Java transactions must have a TIP security user ID<br />

configured.<br />

1–12 7859 6137–009


Section 2<br />

Managing Files from the Workstation<br />

This section provides in<strong>for</strong>mation about how to access <strong>CIFS</strong> files from Windows <strong>and</strong><br />

provides examples of how the in<strong>for</strong>mation is displayed in Windows <strong>and</strong> <strong>OS</strong> <strong>2200</strong><br />

dem<strong>and</strong> sessions. Refer to subsequent sections <strong>and</strong> the Glossary <strong>for</strong> definitions <strong>and</strong><br />

descriptions of <strong>CIFS</strong> utilities <strong>and</strong> comm<strong>and</strong>s.<br />

To access <strong>CIFS</strong> files on an <strong>OS</strong> <strong>2200</strong> system from Windows, you must<br />

• Have access to the <strong>OS</strong> <strong>2200</strong> system (provided by the system administrator).<br />

• Create a share directory or have access to a previously created share directory.<br />

• Map a drive to the share directory or access the resource with the Universal Naming<br />

Convention (UNC).<br />

Networking <strong>CIFS</strong> with Windows<br />

NT4/2000/XP/2003/Vista <strong>and</strong> Windows 95/98/Me<br />

When considering client configurations <strong>for</strong> connecting <strong>CIFS</strong>, be aware that both<br />

Windows NT4/2000/XP/2003/Vista <strong>and</strong> Windows 95/98/Me provide network support <strong>for</strong><br />

the following:<br />

• Client services <strong>for</strong> NetWare<br />

• Remote networking<br />

• TCP/IP, including PPP, SLIP, DHCP, <strong>and</strong> WINS<br />

• NetBEUI Protocol<br />

• NWLink IPX/SPX Compatible Transport<br />

• Windows Sockets St<strong>and</strong>ard used by popular Internet applications<br />

• <strong>OS</strong>F, DCE, <strong>and</strong> RPC available <strong>for</strong> advanced client-server applications <strong>and</strong> used<br />

extensively by Windows NT4/2000/XP/2003/Vista<br />

• Peer-to-peer networking<br />

• Internet connectivity<br />

7859 6137–009 2–1


Managing Files from the Workstation<br />

The networking implementation <strong>for</strong> Windows 95/98/Me is slightly different from that <strong>for</strong><br />

Windows NT4/2000/XP/2003/Vista. To support all Microsoft networking products that<br />

use the server message block (SMB) protocol, the client <strong>for</strong> Microsoft networks<br />

redirector (Vredir.vxd) is required. This allows Windows 95/98/Me computers to connect<br />

to computers running any of the following networking software:<br />

• Windows 95/98/Me<br />

• Windows NT4/2000/XP/2003/Vista<br />

• LAN Manager<br />

• Workgroup Add-on <strong>for</strong> MS-D<strong>OS</strong><br />

As is apparent from the above description, there is a significant variability in established<br />

Microsoft networks; however, if you can currently connect to other network resources,<br />

you have the redirectors required to access <strong>CIFS</strong>.<br />

Generally, Windows NT4/2000/XP/2003/Vista configurations need a host name with<br />

domain name or direct IP address to identify a share name (<strong>for</strong> example,<br />

\\rs99.rsvl.unisys.com\share_this or \\123.123.123.123 \share_that), whereas Windows<br />

95/98/Me configurations need only a host name provided with the share name (<strong>for</strong><br />

example, \\rs99\share_this or \\123.123.123.123\share_that). However, if the host name<br />

(<strong>for</strong> example, rs99) is configured in WINS, then Windows NT4/2000/XP/2003/Vista can<br />

also use a host name with the share name (<strong>for</strong> example, \\rs99\share_this). <strong>User</strong>s of NT<br />

4.0 service pack 5 have reported problems when using IP addresses. To avoid potential<br />

problems, NT 4.0 service pack 4, 6a, or higher must be used.<br />

Note: The above discussion assumes that share_this <strong>and</strong> share_that have been made<br />

available <strong>for</strong> network access using @<strong>CIFS</strong>UT.<br />

To prevent network connections from compromising the <strong>OS</strong> <strong>2200</strong> data access security<br />

measures that were established prior to the introduction of <strong>CIFS</strong>, permission bits <strong>for</strong><br />

directories <strong>and</strong> files must be set to allow access, as well as <strong>OS</strong> <strong>2200</strong> access <strong>and</strong><br />

<strong>OS</strong> <strong>2200</strong> ownership, since these are strictly en<strong>for</strong>ced. This can affect how <strong>and</strong> if your<br />

data is shared with others.<br />

Note: <strong>CIFS</strong> uses only TCP ports 139 <strong>and</strong> 445. That means that <strong>CIFS</strong> does not use WINS<br />

or NetBEUI traffic to ports 137 <strong>and</strong> 138 in establishing or maintaining connections. <strong>CIFS</strong><br />

does not advertise to the network, nor does it request in<strong>for</strong>mation from the network in<br />

establishing <strong>and</strong> maintaining sessions with clients. The <strong>CIFS</strong> server does not belong to or<br />

participate in any particular Microsoft domain concept, although it can connect with<br />

established domains. When a domain name is required, a response of “?” is given, as<br />

required by the protocol <strong>for</strong> any unknown domain.<br />

How host names are resolved in the client computer is key to determining how <strong>CIFS</strong><br />

resources can be accessed. Client computers have control of how network names are<br />

resolved. The necessary TCP/IP properties <strong>for</strong> DNS, LMH<strong>OS</strong>TS, <strong>and</strong> WINS can only be<br />

determined by the local network administrator. If a network connection is not possible<br />

using the above in<strong>for</strong>mation, it may be necessary to change some client network<br />

configurations to access <strong>CIFS</strong> resources. Remember, your current networking capability<br />

depends on present settings <strong>and</strong> on your established network.<br />

2–2 7859 6137–009


Managing Files from the Workstation<br />

The Map Network Drive dialog box maintains a list of the most recently connected<br />

shares. Once a connection is established, it can be easily reestablished by using the<br />

pull-down selection menu to review previously used resources.<br />

The following applies to all Microsoft client connections <strong>and</strong> applies also to <strong>CIFS</strong> network<br />

resource connections.<br />

Network Connections<br />

In Windows NT4/2000/XP/2003/Vista, users can connect to any network resource they<br />

have permission to access. If the current logon session is <strong>for</strong> a different account, users<br />

can fill in their user name in the Connect As text box of the Map Network Drive<br />

dialog box.<br />

In Windows 95/98/Me, the Connect As dialog is not available. To connect to a network<br />

resource from Windows 95/98/Me, users must log on to Windows 95/98/Me with a user<br />

ID that has access to the specific network resource.<br />

In either operating system, the net use comm<strong>and</strong> can also be used to map a network<br />

drive. For syntax <strong>and</strong> usage, use the in<strong>for</strong>mation available through the net help<br />

comm<strong>and</strong>.<br />

Persistent Connections<br />

In Windows NT4/2000/XP/2003/Vista, persistent network connections are enabled by<br />

default. To disable persistent connections, clear the Reconnect at Logon check box<br />

in the Connect Network Drive dialog box.<br />

In Windows 95/98/Me, Quick Logon is enabled by default. This network logon option<br />

restores the mapping of drive letters to network resources without actually establishing<br />

a session <strong>for</strong> each persistent network connection. If you want to establish sessions <strong>for</strong><br />

persistent connections during logon, enable Logon <strong>and</strong> Restore Network Connections.<br />

For in<strong>for</strong>mation on how to do so, refer to in<strong>for</strong>mation provided by Microsoft (such as the<br />

Windows 95 Resource Kit).<br />

Creating a Share Directory<br />

To create a share directory:<br />

1. Start a dem<strong>and</strong> session on the <strong>OS</strong> <strong>2200</strong> system.<br />

2. Call the <strong>CIFS</strong> utility processor, @<strong>CIFS</strong>UT.<br />

When you first execute this comm<strong>and</strong>, <strong>CIFS</strong> places you in the <strong>CIFS</strong> file structure at<br />

your default working directory. Your default working directory is based on your<br />

project ID. For example, if your project ID is MXM3, your default working directory is<br />

/os<strong>2200</strong>/mxm3.<br />

3. Use the mkdir (or md) comm<strong>and</strong> to create a directory. If you have already created a<br />

directory, you can skip this step. (To view files <strong>and</strong> directories, use the ls or dir<br />

comm<strong>and</strong>.)<br />

7859 6137–009 2–3


Managing Files from the Workstation<br />

4. Make the directory network-visible using the share comm<strong>and</strong>.<br />

For example, to make the directory “investments” visible on the network as<br />

“mxm3invest,” enter the comm<strong>and</strong>:<br />

share investments mxm3invest<br />

Refer to Section 4 <strong>and</strong> Section 5 <strong>for</strong> other share options.<br />

Mapping a Drive to a Share Directory<br />

To map a drive to a share directory from Windows<br />

1. Start Windows Explorer.<br />

2. From the Tools menu, select Map Network Drive.<br />

3. Select the drive letter you want to use <strong>for</strong> the share directory.<br />

4. Type in the path name to the share directory. You cannot browse <strong>for</strong> the directory.<br />

The path name has the <strong>for</strong>m \\<strong>OS</strong>-<strong>2200</strong>-hostname\sharename.<br />

5. You need to provide a valid <strong>OS</strong> <strong>2200</strong> user ID that is known to <strong>CIFS</strong> in the Connect<br />

As field or with the Connect using a different user name option if your site<br />

does not have Network Authentication configured. See “Network Authentication” in<br />

Section 9.<br />

Notes:<br />

• You will be prompted <strong>for</strong> your password if this is the first connection to the host.<br />

• If you are using Windows 95/98/Me, your Windows user ID must match the<br />

<strong>OS</strong> <strong>2200</strong> user ID provided by the system administrator. There is no Connect As field<br />

<strong>for</strong> Windows 95/98/Me.<br />

6. Click OK. The drive is mapped <strong>and</strong> appears in the list of drives in Explorer.<br />

You can view the files in the share directory, double-click them, <strong>and</strong> drag <strong>and</strong> drop<br />

them to <strong>and</strong> from the directory as you would any other files on your workstation.<br />

2–4 7859 6137–009


Opening Share Files Using UNC<br />

Managing Files from the Workstation<br />

You can access <strong>CIFS</strong> files directly in most Windows applications, without mapping a<br />

share directory to a drive, by providing the Universal Naming Convention (UNC) network<br />

path, sharename, <strong>and</strong> file name to the application.<br />

The following example illustrates this:<br />

1. Start the application you want to call, <strong>for</strong> example, Notepad.<br />

2. Type in the UNC network path, sharename, <strong>and</strong> file name in the File name field.<br />

3. Click Open.<br />

Note: When you click Open, a session is opened to <strong>OS</strong> <strong>2200</strong> to retrieve the file. You<br />

might have to provide your user ID <strong>and</strong> password be<strong>for</strong>e the opening the document on<br />

your workstation.<br />

7859 6137–009 2–5


Managing Files from the Workstation<br />

2–6 7859 6137–009


Viewing <strong>CIFS</strong> Directories<br />

Managing Files from the Workstation<br />

The following examples show how <strong>CIFS</strong> directories can be viewed.<br />

This example illustrates how the share directory “CRCTEST” appears in Windows<br />

Explorer (after mapping the share directory to drive F).<br />

This example illustrates how the same directory ‘CRCTEST’ displays when issued from<br />

an <strong>OS</strong> <strong>2200</strong> dem<strong>and</strong> session using the @<strong>CIFS</strong>UT ls -lr comm<strong>and</strong>.<br />

@cifsut<br />

<strong>CIFS</strong>UT 1R1Q2 (1999/Aug/17 10:31:39) 1999 Oct 12 Tue 15:31:04<br />

ls -lr /crctest<br />

drwxrwxrwx 3 17 420 Sep 29 15:23 2nd level dir<br />

-rwxrwxrwx 1 17 6836 Aug 17 10:25 TestingOne.txt<br />

-rwxrwxrwx 1 17 394800 Aug 11 22:08 dumpdir..abs<br />

/crctest/2nd level dir:<br />

drwxrwxrwx 4 17 700 Sep 29 16:26 3rd level dir<br />

/crctest/2nd level dir/3rd level dir:<br />

drwxrwxrwx 3 17 420 Sep 29 16:25 4th level dir<br />

-rwxrwxrwx 1 17 6836 Sep 29 16:23 Not So Long.txt<br />

-rwxrwxrwx 1 17 6836 Sep 29 16:26 Testing Long Names in <strong>CIFS</strong> Directories.txt<br />

/crctest/2nd level dir/3rd level dir/4th level dir:<br />

-rwxrwxrwx 1 17 6836 Sep 29 16:25 Short Name.txt<br />

7859 6137–009 2–7


Managing Files from the Workstation<br />

This example illustrates how program files <strong>and</strong> data files might appear in Windows<br />

Explorer <strong>for</strong> an <strong>OS</strong> <strong>2200</strong> project.<br />

This example illustrates the same listing of the <strong>OS</strong> <strong>2200</strong> project files with the @<strong>CIFS</strong>UT<br />

ls comm<strong>and</strong>:<br />

@cifsut<br />

<strong>CIFS</strong>UT 1R1Q2 (1999/Aug/17 10:31:39) 1999 Oct 12 Tue 15:34:29<br />

ls /os<strong>2200</strong>/caldarale<br />

$cshellsave$ code full$list pcf37-38 timetest<br />

call-cull comus-cull gen r<strong>and</strong>io timetesti<br />

call-test cts$crc high$list rbcomp xfer<br />

callt-cull dgt-call kernel$list save<br />

cat$tpf$ dump-dir lf4r2 savestack$<br />

cbpfl$crc ert-tools mfd-code testfile<br />

2–8 7859 6137–009


Managing Files from the Workstation<br />

This example illustrates a Windows Explorer view of <strong>OS</strong> <strong>2200</strong> program file contents,<br />

including Word documents, <strong>2200</strong> executables, C source files, <strong>and</strong> new text documents<br />

created with Windows by right-clicking the mouse.<br />

7859 6137–009 2–9


Managing Files from the Workstation<br />

This example illustrates how the program file contents would be listed with the FURPUR<br />

@prt, tlb comm<strong>and</strong>.<br />

@prt,tlb caldarale*xfer.<br />

FURPUR 31R4Q1 (990309 1451:50) 1999 Oct 12 Tue 1605:30<br />

SHARED#CALDARALE*XFER(1) ELEMENT TABLE<br />

D NAME VERSION TYPE DATE TIME SEQ # SIZE-PRE,TEXT (CYCLE WORD) PSRMODE LOCATION<br />

UNIXPROC-MD C ELT SYMB-Q 05 OCT 99 10:23:11 20 118 5 0 1 17526<br />

TSCRDUMP ZOOM 18 AUG 99 15:23:27 19 1856 15670<br />

NEWTEXTDOC-1 TXT SYMBOLIC 30 SEP 99 10:01:47 18 0 0 0 0 15670<br />

NEWTEXTDOCUM TXT SYMBOLIC 30 SEP 99 08:56:30 17 0 0 0 0 15670<br />

SQUEEZEPATH C ELT SYMB-Q 20 AUG 99 08:46:18 16 13 5 0 1 15657<br />

DUMPDIR C SYMB-Q 11 AUG 99 22:07:57 15 58 5 0 1 15599<br />

DUMPDIR ZOOM 11 AUG 99 22:08:12 14 3525 12074<br />

<strong>CIFS</strong>-FS RTF ELT SYMB-Q 21 JUL 99 10:03:24 13 1374 5 0 1 10700<br />

<strong>CIFS</strong>-FS DOC DOC SYMB 19 JUL 99 16:58:39 12 1158 0 0 0 9542<br />

HVTIP$CALLS MSD SYMB-Q 03 MAY 96 14:50:25 11 397 5 0 1 9145<br />

<strong>CIFS</strong>IO H C SYMB-Q 09 FEB 99 13:21:04 10 306 5 0 1 8839<br />

LSTEST C SYMB-Q 12 FEB 99 10:52:16 9 14 5 0 1 8825<br />

PCNSVRBUF TXT SYMBOLIC -Q 04 FEB 99 17:10:41 8 36 5 0 1 8789<br />

EM-TCF ELT SYMB-Q 16 APR 98 15:01:30 7 1776 5 0 1 7013<br />

EM-PCF NEW ELT SYMB-Q 16 APR 98 15:01:08 6 1789 5 0 1 5224<br />

EM-PCF ORIG ELT SYMB-Q 16 APR 98 15:00:19 5 1439 5 0 1 3785<br />

MAPELTS ELT SYMB-Q 16 APR 98 13:58:54 4 9 5 0 1 3776<br />

ELTLIST ELT SYMB-Q 15 APR 98 16:59:09 3 21 5 0 1 3755<br />

UAL-UCS PCF ELT SYMB-Q 16 MAR 98 14:42:43 2 1724 5 0 1 2031<br />

UAL-EM PCF ELT SYMB-Q 13 NOV 97 15:25:12 1 239 5 0 1 1792<br />

NEXT AVAILABLE LOCATION- 17644<br />

2–10 7859 6137–009


Section 3<br />

File Concepts<br />

This section includes the following topics:<br />

• Definitions <strong>and</strong> descriptions pertaining to files, file names, <strong>and</strong> directories<br />

File hierarchies<br />

• Path names <strong>and</strong> path name resolution<br />

• Open file descriptions<br />

• File descriptors <strong>and</strong> file permissions<br />

• Time in<strong>for</strong>mation <strong>for</strong> files <strong>and</strong> directories<br />

• Concepts of file management <strong>and</strong> file input/output (I/O) operations<br />

• Environment variables<br />

File Definition <strong>and</strong> File Types<br />

A file is a logical data container. <strong>CIFS</strong> supports directories, regular files, character files,<br />

pipes, <strong>and</strong> First-In First-Out (FIFO) files. Each of these file types is described below.<br />

Internally, <strong>CIFS</strong> uses an inode structure to manage each file in the system. An inode<br />

contains a file’s serial number, type, ownership, access permissions, size, <strong>OS</strong> <strong>2200</strong> alias,<br />

<strong>and</strong> creation, modification, <strong>and</strong> access times, among other in<strong>for</strong>mation. The ls <strong>and</strong> dir<br />

comm<strong>and</strong>s (described in Section 4) or the stat() <strong>and</strong> istat() functions (Section 5) retrieve<br />

in<strong>for</strong>mation about a file from its inode.<br />

A directory is a very specialized kind of file that contains links to other files (including<br />

directories). Directories are used to organize files into hierarchical structures. More<br />

detailed in<strong>for</strong>mation about directories appears in the following subsections.<br />

A regular file is a r<strong>and</strong>omly accessible sequence of bytes with no further structure<br />

imposed by <strong>CIFS</strong>. All <strong>OS</strong> <strong>2200</strong> files are accessible through <strong>CIFS</strong> interfaces. Likewise, all<br />

regular <strong>CIFS</strong> files are accessible through traditional <strong>OS</strong> <strong>2200</strong> mechanisms.<br />

A character file is a virtual file that is used as a caller's terminal (or batch read/print<br />

streams), or as a dummy file, or as a source of r<strong>and</strong>om data. Only four character files<br />

exist: /dev/tty (terminal access), /dev/null (dummy file), /dev/r<strong>and</strong>om <strong>and</strong> /dev/ur<strong>and</strong>om<br />

(r<strong>and</strong>om byte streams). <strong>CIFS</strong> directs read <strong>and</strong> write requests <strong>for</strong> /dev/tty to the<br />

requester's READ$ <strong>and</strong> PRINT$ streams.<br />

7859 6137–009 3–1


File Concepts<br />

File Names<br />

Read requests <strong>for</strong> /dev/null always return zero bytes, while write requests always appear<br />

to transfer all data (although the bytes are actually discarded). Reads from /dev/r<strong>and</strong>om<br />

<strong>and</strong> /dev/ur<strong>and</strong>om return a r<strong>and</strong>om byte sequence; writes are not allowed. Character<br />

files are not accessible from the network.<br />

A pipe allows processes to transfer data <strong>and</strong> synchronize execution. A pipe has the<br />

following characteristics:<br />

• A pipe provides a data stream between two processes.<br />

• Pipe data is read in the same order in which it is written; that is, in FIFO sequence.<br />

• A pipe is temporary; it vanishes when closed by all processes using it.<br />

• A pipe does not have a name <strong>and</strong> there<strong>for</strong>e, is not part of the file hierarchy.<br />

This diagram illustrates a pipe:<br />

A FIFO file is a pipe that has a name <strong>and</strong> permanently resides in the file hierarchy.<br />

A file name identifies a named file. All <strong>CIFS</strong> files other than pipes are associated with at<br />

least one file name. The following rules apply to file names:<br />

• A file name can consist of 1 to 4095 characters, plus a terminating nul character.<br />

• A file name can contain any characters except the following:<br />

− Slash (/)<br />

− Nul character ('\0')<br />

− Any character with a value greater than 8 bits (>255)<br />

− All periods<br />

Process A<br />

write ( )<br />

The slash <strong>and</strong> nul characters do not cause errors. They are used to delimit path name<br />

components <strong>and</strong>, there<strong>for</strong>e, cannot be part of any file name. See examples below.<br />

• Although <strong>CIFS</strong> allows nearly all characters in file names, many nonalphanumeric<br />

characters have special meaning to some applications or can cause erratic displays<br />

when sent to a terminal. Consequently, nonprinting characters should be avoided.<br />

These characters include the ranges 1 through 31 <strong>and</strong> 127 through 255.<br />

3–2 7859 6137–009<br />

Data<br />

Process B<br />

read ( )


File Concepts<br />

Generally, file names with such characters cannot be safely displayed without<br />

special h<strong>and</strong>ling in the output medium. Also, file names beginning or ending with<br />

spaces tend to be confusing.<br />

Examples<br />

The following are valid file names:<br />

p<br />

program_name<br />

15digits_first<br />

doc.22<br />

policy,12:b<br />

1234560<br />

thisnameisnottoolongthisnameisnottoolongthisnameisnottool<br />

For the reasons given above, the following are either invalid or not the intended file<br />

name:<br />

my/name<br />

Contains a slash. (<strong>CIFS</strong> interprets “name” as the file name <strong>and</strong> “my” as a directory<br />

name.)<br />

my\0name<br />

Contains a nul character. (<strong>CIFS</strong> interprets “my” as the file name <strong>and</strong> ignores<br />

“name.”)<br />

7859 6137–009 3–3


File Concepts<br />

Directory Definition <strong>and</strong> Rules <strong>for</strong> Directories<br />

A directory is a file that contains directory entries. A directory entry, or link, is an object<br />

that associates a file name with a named file; pipes do not have directory entries.<br />

(Directory entry <strong>and</strong> link are synonymous terms.) A subordinate directory is a directory<br />

whose name is an entry in another directory. A file’s link count is the total number of<br />

directory entries associated with that file.<br />

The following diagram shows the directory main_dir containing regular files (represented<br />

by cylinders) <strong>and</strong> subordinate directories (represented by circles):<br />

The contents of main_dir are represented by the following list of file names. This list is<br />

also an example of a directory stream.<br />

48.1234<br />

minutes.mtg<br />

myfile.1<br />

myfile.2<br />

outlines<br />

tempjunk<br />

See below <strong>for</strong> a detailed description of file hierarchies.<br />

Rules <strong>for</strong> Creating Directory Entries<br />

The following rules apply to creating entries in directories:<br />

• Each file name must be unique within a directory. However, the same file name can<br />

appear in different directories <strong>and</strong> can be associated with different files.<br />

• The same file can be associated with several different file names through multiple<br />

links. These links can be in the same directory or in different directories.<br />

3–4 7859 6137–009


File Concepts<br />

For examples of creating <strong>and</strong> removing links, see the link() <strong>and</strong> unlink() functions in<br />

Section 5.<br />

Diagram of Directories, Files, <strong>and</strong> Links<br />

The following diagram illustrates how links associate file names with files:<br />

In the diagram, the following path names refer to the same file:<br />

• A/Entry_A3<br />

• A/Sub_A/Entry_SA1<br />

• B/Entry_B2<br />

• B/Entry_B3<br />

Because four links exist <strong>for</strong> this file, its link count is 4.<br />

7859 6137–009 3–5


File Concepts<br />

File Hierarchies<br />

The file hierarchy is a relationship among all <strong>CIFS</strong> files. The hierarchy is an inverted<br />

tree-like structure with branches from the system root directory to each named file in the<br />

system. The system root directory is the top of the file hierarchy. All other directories<br />

branch from it. A node is any file on any branch of the file hierarchy.<br />

The following diagram illustrates the structure of the file hierarchy:<br />

Characteristics of a file hierarchy include these:<br />

• The last node on a branch can be a file of any type except a pipe (since pipes are not<br />

part of the file hierarchy).<br />

• All nodes that are not the last nodes on a branch are directories.<br />

• The top of the hierarchy is the system root directory.<br />

3–6 7859 6137–009


Path Names<br />

File Concepts<br />

A path name identifies a file; it is the ordered list of file names that locates a file. A path<br />

name component is a file name in the list.<br />

The following rules apply to path names:<br />

• A path name consists of one of the following combinations:<br />

− One or more file names, separated by slash characters<br />

− An initial slash (/) followed by zero or more file names, separated by slashes<br />

• Each path name component except the last must name a directory.<br />

• The last path name component can name any kind of file other than a pipe, including<br />

a directory.<br />

• If the path name refers to a directory, it can optionally end in one or more trailing<br />

slashes.<br />

• Multiple successive slashes are the same as one slash, except at the beginning of a<br />

path.<br />

• A null path name (that is, “”, the empty string) is invalid.<br />

Examples<br />

The following examples are valid path names:<br />

file1<br />

dir1/dir2/file1<br />

/main_dir/appl_dir/pgm_dir/file1<br />

/<br />

dir_1////sub_dir/<br />

Assuming “dir” means a directory name <strong>and</strong> “file” means a regular file name, the<br />

following examples are not the intended path names, <strong>for</strong> the reasons given:<br />

dir1/dir2/file1/file2<br />

Third component is not a directory.<br />

dir_1dir_sub<br />

Components are not separated by a slash. <strong>CIFS</strong> interprets this as a single file name<br />

rather than a directory <strong>and</strong> a subdirectory.<br />

7859 6137–009 3–7


File Concepts<br />

Special Path Name Components<br />

The current working directory is used to resolve relative path names <strong>for</strong> a process. Its<br />

value is either<br />

• The result of the last call to chdir(), if one occurred.<br />

• The initial directory of the first process <strong>for</strong> the user if chdir() has not been called.<br />

A parent directory of any file is a directory that contains a link to that file.<br />

Notes:<br />

• A file can have multiple parent directories because more than one directory can<br />

contain a link to the file. See the link() function in Section 5 <strong>for</strong> more in<strong>for</strong>mation.<br />

• A directory can have one parent directory in the /os<strong>2200</strong> hierarchy <strong>and</strong> one in the<br />

non-/os<strong>2200</strong> hierarchy.<br />

A child of a directory is one of the files listed in the directory. Dot (.) is a file name that<br />

refers to the directory itself. Dot-dot (..) is a file name that refers to the parent of the<br />

directory.<br />

Notes:<br />

• Both . <strong>and</strong> .. count as directory entries.<br />

• A component consisting solely of one or more dots is valid in path names. One dot<br />

refers to the current directory, two dots refers to the parent directory, three dots<br />

refers to the parent’s parent directory, <strong>and</strong> so on. For example, /a/b/../c/. resolves to<br />

/a/c.<br />

• With respect to the system root directory, both . <strong>and</strong> .. refer to the system root<br />

directory itself.<br />

3–8 7859 6137–009


Path Name Resolution<br />

File Concepts<br />

The process of finding a file from a given path name is called path name resolution. Path<br />

name components are interpreted from left to right according to one of two procedures,<br />

as determined by the following decision table:<br />

If the first character of the path<br />

name is ...<br />

Then use ...<br />

A slash (/) Absolute path name resolution<br />

Not a slash Relative path name resolution<br />

In both procedures, each path name component is located in the directory specified by<br />

the preceding path name component.<br />

Absolute Path Name Resolution<br />

Absolute path name resolution starts from the system root directory. It consists of the<br />

following steps:<br />

1. If the path name consists of a single slash, it resolves to the system root directory.<br />

2. Read the next file name, moving from left to right.<br />

3. Associate this file name with a file (possibly a directory) on the next level of the<br />

hierarchy.<br />

4. Repeat steps 2 <strong>and</strong> 3 <strong>for</strong> each path name component.<br />

Example<br />

In the path name /main_dir/appl_dir/pgm_dir/file_1<br />

• Directory main_dir is located in the system root directory.<br />

• Directory appl_dir is located in directory main_dir.<br />

• Directory pgm_dir is located in directory appl_dir.<br />

• Regular file file_1 is located in directory pgm_dir.<br />

7859 6137–009 3–9


File Concepts<br />

Path Name Component Parent of Child of<br />

main_dir appl_dir System root directory<br />

appl_dir pgm_dir main_dir<br />

pgm_dir file_1 appl_dir<br />

file_1 pgm_dir<br />

Relative Path Name Resolution<br />

Relative path name resolution starts from the current working directory of the process. It<br />

consists of the following steps:<br />

1. Read the next file name, moving from left to right.<br />

2. Associate this file name with a file (possibly a directory) on the next level of the<br />

hierarchy.<br />

3. Repeat steps 1 <strong>and</strong> 2 <strong>for</strong> each path name component.<br />

For example, in the path name<br />

dir_1/dir_2/file_1<br />

Directory dir_1 is located in the current working directory. Directory dir_2 is located in<br />

directory dir_1. Regular file file_1 is located in directory dir_2.<br />

3–10 7859 6137–009


Path Name Component Parent of Child of<br />

dir_1 dir_2 Current working directory<br />

dir_2 file_1 dir_1<br />

file_1 dir_2<br />

Open File Descriptions<br />

File Concepts<br />

An open file description is a <strong>CIFS</strong> record of how a process is accessing a file. Many <strong>CIFS</strong><br />

functions access files only indirectly, through open file descriptions. An open file<br />

description corresponds to one <strong>and</strong> only one instance of an open file. Each file open()<br />

request creates a new open file description. An open file description has the following<br />

attributes:<br />

• Read/write offset<br />

• File status flags<br />

• File access specification<br />

The values of the preceding attributes in each open file description are independent of<br />

the values in other open file descriptions, even <strong>for</strong> the same file.<br />

Read/Write Offset<br />

The read/write offset is the byte position in a file where the next I/O operation starts.<br />

The offset is not meaningful <strong>for</strong> character files, pipes, or FIFO files.<br />

File Status Flags<br />

The file status flags specify how the file was opened, such as opened to append data.<br />

Each of the following functions sets the file status flags (see Section 5 <strong>for</strong> in<strong>for</strong>mation on<br />

the functions):<br />

• The open() function<br />

• The fcntl() function with the F_SETFL comm<strong>and</strong> specified<br />

7859 6137–009 3–11


File Concepts<br />

File Access Specification<br />

The file access specification identifies the type of permission requested by a process <strong>for</strong><br />

accessing a file: read-only, write-only, or read/write access. The file access specification<br />

is one of the following values, specified with the open() function (see Section 5):<br />

• O_RDONLY Open the file <strong>for</strong> reading only.<br />

• O_WRONLY Open the file <strong>for</strong> writing only.<br />

• O_RDWR Open the file <strong>for</strong> reading <strong>and</strong> writing.<br />

Using Open File Descriptions<br />

A process accesses an open file description through a file descriptor (see below), which<br />

<strong>CIFS</strong> creates when the process opens a file. A process can create several open file<br />

descriptions that all refer to the same file, where each open file description<br />

• Is created by a call to open() or creat()<br />

• Is identified by a file descriptor<br />

• Operates independently of all other open file descriptions<br />

For example, an application may need to read, write, <strong>and</strong> update a file at three distinct<br />

locations within the file. The application can open the file once <strong>for</strong> read-only access, once<br />

<strong>for</strong> write-only access, <strong>and</strong> once <strong>for</strong> read/write access. The resulting open file descriptions<br />

<strong>for</strong> the three instances of the open file are independent <strong>and</strong> have unique offsets,<br />

allowing the application to access the file in the appropriate way at each location.<br />

The following diagram shows a process accessing a single file through several<br />

independent open file descriptions:<br />

Process<br />

<strong>CIFS</strong> Subsystem<br />

File<br />

Descriptors<br />

Open File<br />

Descriptions<br />

3–12 7859 6137–009<br />

File


File Descriptors<br />

Restrictions<br />

File Concepts<br />

A file descriptor is a nonnegative integer that identifies an open file description <strong>for</strong> file<br />

access. St<strong>and</strong>ard input is an input stream usually intended to be used <strong>for</strong> primary data<br />

input. By convention, the C name <strong>for</strong> st<strong>and</strong>ard input is stdin <strong>and</strong> the file descriptor is 0,<br />

which you access using the constant STDIN_FILENO. St<strong>and</strong>ard output is an output<br />

stream usually intended to be used <strong>for</strong> primary data output. By convention, the C name<br />

<strong>for</strong> st<strong>and</strong>ard output is stdout <strong>and</strong> the file descriptor is 1, which you access using the<br />

constant STDOUT_FILENO. St<strong>and</strong>ard error is an output stream usually intended to be<br />

used <strong>for</strong> diagnostic messages. By convention, the C name <strong>for</strong> st<strong>and</strong>ard error is stderr<br />

<strong>and</strong> the file descriptor is 2, which you access using the constant STDERR_FILENO.<br />

A file descriptor allows <strong>CIFS</strong> to find the open file description that corresponds to an<br />

instance of the open file. The following functions can return file descriptors <strong>for</strong> use in<br />

other system calls (see Section 5 <strong>for</strong> function descriptions):<br />

• creat() function<br />

• dup() function<br />

• dup2() function<br />

• fcntl() with the F_DUPFD comm<strong>and</strong> request<br />

• open() function<br />

• pipe() function<br />

The following restrictions apply to file descriptors:<br />

• A process can have up to 2048 file descriptors.<br />

• Each file descriptor refers to only one open file description. However, one open file<br />

description can have more than one file descriptor referring to it; see “Using File<br />

Descriptors” in this subsection.<br />

Using File Descriptors<br />

Any call to open() creates a new open file description <strong>and</strong> assigns the lowest available<br />

file descriptor. The process can later associate additional file descriptors with this open<br />

file description.<br />

For example, you might want to use st<strong>and</strong>ard input STDIN_FILENO <strong>and</strong> st<strong>and</strong>ard output<br />

STDOUT_FILENO <strong>for</strong> passing data between processes that access a pipe. You can<br />

redirect STDIN_FILENO <strong>and</strong> STDOUT_FILENO to the pipe by duplicating the appropriate<br />

file descriptors; see the example <strong>for</strong> the pipe() function in Section 5.<br />

7859 6137–009 3–13


File Concepts<br />

The following functions can associate more than one file descriptor with an open file<br />

description:<br />

• dup()<br />

• dup2()<br />

• fcntl()<br />

The following diagram shows a process accessing a file through a single open file<br />

description associated with several file descriptors:<br />

File Permissions<br />

<strong>CIFS</strong> Subsystem<br />

File<br />

Descriptors<br />

Open File<br />

Description<br />

Process File<br />

File permissions are attributes of a file that determine whether a process can read,<br />

write, or search/execute the file or change the file's characteristics. There are three<br />

types of file permissions:<br />

• Read permission allows the process to obtain the contents of a file (including a<br />

directory).<br />

• Write permission allows the process to create entries in a directory or modify the<br />

contents of other types of files.<br />

• Search/execute permission allows a process to search a directory or execute a file.<br />

Search permission applies only to directories; execute permission applies only to<br />

regular files.<br />

Permissions are determined by <strong>OS</strong> <strong>2200</strong> security policies, <strong>and</strong> augmented by<br />

<strong>CIFS</strong>-maintained permission bits.<br />

<strong>CIFS</strong> maintains separate access permission sets <strong>for</strong> references by three classes of<br />

requesters: file owner, group, <strong>and</strong> others. The owner set is used when the effective user<br />

ID matches the effective owner of the file; the other set is used <strong>for</strong> all mismatches.<br />

(Currently, named groups are not implemented in <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong>. There<strong>for</strong>e, group<br />

access permissions have no effect. <strong>CIFS</strong> keeps track of group access permission<br />

settings but does not use them to grant or deny access.) The file attributes supported by<br />

<strong>CIFS</strong> are read-only <strong>and</strong> write-only (they cannot be set concurrently).<br />

3–14 7859 6137–009


File Concepts<br />

These attributes only restrict any access granted by the permissions. <strong>CIFS</strong> honors<br />

settings established by other mechanisms (<strong>for</strong> example, @CHG,V) <strong>and</strong> changes any<br />

underlying <strong>OS</strong> <strong>2200</strong> file state to match when all read or write permissions are removed.<br />

At sites where access control records (ACRs) are in use, <strong>CIFS</strong> maintains permissions <strong>for</strong><br />

a file or directory based on any ACR attached to the underlying <strong>OS</strong> <strong>2200</strong> file. An ACR can<br />

be attached to new files by setting the <strong>CIFS</strong>$ACR environment variable (see Section 4)<br />

prior to invoking a <strong>CIFS</strong> file creation mechanism. The <strong>CIFS</strong>$ACR setting is also applied to<br />

existing files when ownership is changed through the chown comm<strong>and</strong> in <strong>CIFS</strong>UT or the<br />

chown( ) API. ACRs must be used to insure that access permissions set inside <strong>CIFS</strong> are<br />

effective when files are referenced by native <strong>OS</strong> <strong>2200</strong> mechanisms.<br />

<strong>CIFS</strong> sets the initial access permission values <strong>for</strong> files in the /os<strong>2200</strong> directory hierarchy<br />

based on the security state of each file. For private files, the effective owner is given full<br />

access while group <strong>and</strong> other access is set to none. For public files, full access is given<br />

to all classes. When a file has an ACR attached, access is based on the contents of the<br />

ACR.<br />

Permission Bits<br />

The permission bits set in the <strong>CIFS</strong> environment are used only as additional restrictions<br />

on the access rights granted by the Exec through public, private, ACR, <strong>and</strong> key settings.<br />

<strong>CIFS</strong> never gives more I/O access than the Exec allows, unless the user is considered<br />

privileged. For <strong>CIFS</strong>, privileged means having write access to the <strong>CIFS</strong> subsystem<br />

program file (ignoring any read-only attribute). Drive mapping does not involve any actual<br />

I/O, so <strong>CIFS</strong> only uses the permission bits to decide whether or not the connection must<br />

be allowed. This is analogous to doing a cd in @<strong>CIFS</strong>UT, which is also based solely on<br />

the permission bits, <strong>and</strong> can be per<strong>for</strong>med without regard to the Exec access checks.<br />

After the connection or the cd, however, the “unprivileged” user must still go through<br />

the Exec checks to actually look inside a file.<br />

7859 6137–009 3–15


File Concepts<br />

Permission Masks<br />

Each permission class has a permission mask attribute that controls the types of<br />

permissions <strong>for</strong> that class. The following diagram shows the concept of read (r), write<br />

(w), <strong>and</strong> search/execute (x) permission within the permission mask <strong>for</strong> each class:<br />

If all bits are set in a permission mask <strong>for</strong> a file, each class can read, write, <strong>and</strong><br />

search/execute the file; no permissions are denied.<br />

The default permission bits <strong>for</strong> new files <strong>and</strong> directories are shown in the following table.<br />

Permissions that are not allowed are shown as a dash (–).<br />

Method of Creating a New File<br />

or Directory<br />

Default Permission Bits<br />

COPY or MOVE comm<strong>and</strong> Same bits as those <strong>for</strong> source file or directory<br />

MKDIR comm<strong>and</strong> rwxrwxrwx (full access <strong>for</strong> owner, group, <strong>and</strong><br />

other users)<br />

Creation through network<br />

connections<br />

rwxr–xr–x (full access <strong>for</strong> owner, but only read<br />

<strong>and</strong> execute access <strong>for</strong> group <strong>and</strong> other users)<br />

<strong>CIFS</strong> APIs Caller-specified bits in the mode parameter<br />

(required <strong>for</strong> new files)<br />

Examples<br />

The following table shows some common permission assignments <strong>for</strong> each class.<br />

Permissions that are not allowed are shown as a dash (–).<br />

If the file<br />

permission bits<br />

are...<br />

Then the process has permission to...<br />

Owner Group Other<br />

rw-rw-rw- Read <strong>and</strong> write Read <strong>and</strong> write Read <strong>and</strong> write<br />

rw-r-r- Read <strong>and</strong> write Read only Read only<br />

rwxr-r- Read, write, <strong>and</strong><br />

execute<br />

rwxr-xr- Read, write, <strong>and</strong><br />

execute<br />

r w x r w x r w x<br />

Owner Group Other<br />

Read only Read only<br />

Read <strong>and</strong> execute Read only<br />

3–16 7859 6137–009


Using File Permissions<br />

File Concepts<br />

Each time a process tries to open a file or modify its characteristics, <strong>CIFS</strong> takes the<br />

following actions:<br />

1. Determines the class of the process with regard to the file.<br />

2. Uses the appropriate mask (set of permission bits) to determine which permissions<br />

the process has <strong>for</strong> the file.<br />

3. Compares the permitted permissions to the permissions requested by the process<br />

(that is, the file access specification).<br />

4. Continues or terminates the process request, depending on the result of the<br />

comparison.<br />

Time In<strong>for</strong>mation <strong>for</strong> Files<br />

The directory entry <strong>for</strong> a file contains time in<strong>for</strong>mation in addition to file ownership,<br />

permissions, <strong>and</strong> type. The following time in<strong>for</strong>mation <strong>for</strong> a file is maintained <strong>and</strong><br />

available to appropriate functions:<br />

Field Description<br />

Last read or<br />

write access<br />

Last<br />

modification<br />

(write access)<br />

Time of<br />

creation<br />

Updating Time Fields<br />

The time of the last read or write<br />

access to the data in the file.<br />

The time of the last modification<br />

(write access) to the data in the<br />

file.<br />

Field in<br />

struct stat<br />

Examples of<br />

Functions<br />

st_atime read() readdir()<br />

st_mtime mkdir() write()<br />

The time the file was created. st_ctime creat()<br />

Each function that references file data or changes the file's characteristics updates the<br />

appropriate time field.<br />

When a file is no longer open by any process (that is, the last open file description <strong>for</strong> a<br />

file is closed) the last access time is updated.<br />

The functions fstat() <strong>and</strong> stat() do not update any time in<strong>for</strong>mation <strong>for</strong> the selected file.<br />

Time In<strong>for</strong>mation <strong>for</strong> Open File Descriptions<br />

Time in<strong>for</strong>mation, along with the file mode <strong>and</strong> other status in<strong>for</strong>mation, belongs to a<br />

file. All open file descriptions <strong>for</strong> the file share that in<strong>for</strong>mation.<br />

7859 6137–009 3–17


File Concepts<br />

File Attributes<br />

<strong>CIFS</strong> maintains certain in<strong>for</strong>mation about each named file in the file system, including<br />

• File mode, including file permissions<br />

• Security attributes<br />

− Owner's user ID<br />

− Owner’s numeric user ID<br />

− Privacy Setting<br />

• Identifiers<br />

File Mode<br />

− File serial number<br />

• Size in bytes<br />

• Number of links to the file or directory<br />

• Time in<strong>for</strong>mation (see above)<br />

− Last access to file data<br />

− Time of file creation<br />

− Last data modification<br />

• <strong>OS</strong> <strong>2200</strong> file container name (an empty string if container is not allocated)<br />

The file mode contains in<strong>for</strong>mation about the following attributes:<br />

• File permissions, which control file access.<br />

• File <strong>for</strong>mat, which identifies System Data Format (SDF) <strong>and</strong> binary files.<br />

• File type, which identifies regular, directory, character, pipe, <strong>and</strong> FIFO files.<br />

Each of these attributes is described in the following subsections.<br />

3–18 7859 6137–009


File Mode Creation Mask<br />

File Concepts<br />

The file mode creation mask is a process attribute that limits the permissions the<br />

process can attach to a file. The value of the mask is controlled by the umask() function<br />

(see Section 5). The mask is a set of attributes corresponding to read, write, <strong>and</strong><br />

search/execute permissions <strong>for</strong> each of the permission classes (owner, group, <strong>and</strong> other;<br />

see above). If an attribute is set in the mask, that permission is denied when files are<br />

created. For example, to prohibit anyone in the group <strong>and</strong> other permission classes from<br />

writing to a file, set the corresponding attributes in the file mode creation mask be<strong>for</strong>e<br />

creating the file.<br />

Functions that create files request file permissions through a mode argument in the call<br />

statement. However, they first apply the file mode creation mask to turn off<br />

corresponding permissions that are set in the mode argument. For example, if the<br />

attributes <strong>for</strong> group <strong>and</strong> other write permissions are set in the file mode creation mask,<br />

those permissions are not set <strong>for</strong> files created subsequently.<br />

Note: To apply the file mode creation mask, functions per<strong>for</strong>m a bitwise AND operation<br />

between the value of mode <strong>and</strong> the complement of the file mode creation mask.<br />

Inheriting the File Mode Creation Mask<br />

New processes created by the _cifs_new_process() function inherit the file mode<br />

creation mask of the previous process.<br />

Using the File Mode<br />

The fstat() <strong>and</strong> stat() functions make the file mode available in a numeric field.<br />

The chmod() function references the file mode through a mode argument, using mode to<br />

modify the permissions in the file mode. The following functions reference the file mode<br />

through a mode argument, using the file mode creation mask to modify the permissions<br />

in mode:<br />

• creat()<br />

• mkdir()<br />

• mkfifo()<br />

• open()<br />

See Section 5 <strong>for</strong> function descriptions.<br />

File Permissions<br />

File permissions control read, write, <strong>and</strong> search/execute access to the file (see above <strong>for</strong><br />

a description of permission classes <strong>and</strong> illustrations of common permission attribute<br />

settings).<br />

7859 6137–009 3–19


File Concepts<br />

The following table identifies symbolic names <strong>for</strong> permissions <strong>for</strong> each permission class:<br />

Permission Class<br />

Symbolic Names <strong>for</strong> Permissions<br />

Read Write Search/Execute<br />

Owner S_IRUSR S_IWUSR S_IXUSR<br />

Group S_IRGRP S_IWGRP S_IXGRP<br />

Other S_IROTH S_IWOTH S_IXOTH<br />

To set permissions <strong>for</strong> a regular file, <strong>for</strong> example, you can create the file with the open()<br />

function. The mode argument in the call includes all the individual permissions you want<br />

the file to have, separated by the bitwise inclusive OR operator (|). For example, the<br />

following mode argument sets read, write, <strong>and</strong> execute permissions <strong>for</strong> the user:<br />

S_IRUSR | S_IWUSR | S_IXUSR<br />

Note: The search/execute permission attributes (S_IXUSR, S_IXGRP, <strong>and</strong> S_IXOTH)<br />

have dual meaning. They signify search permission <strong>for</strong> directories <strong>and</strong> execute<br />

permission <strong>for</strong> regular files. They have no meaning <strong>for</strong> any other type of file.<br />

Example<br />

Suppose you want to create a regular file that anyone can read. You assign all<br />

permissions <strong>for</strong> yourself as owner, <strong>and</strong> you allow read permission <strong>for</strong> the group <strong>and</strong><br />

other classes. The following example illustrates these permissions.<br />

rwxr--r--<br />

The following code sets the correct permissions when open() creates the file:<br />

open("/main_dir/my_dir/my_file", O_CREAT | O_RDWR,<br />

S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH)<br />

Class Permission Values<br />

The following values assign read, write, <strong>and</strong> search/execute permission <strong>for</strong> a class. Use<br />

them instead of the individual permissions if you want all three permissions <strong>for</strong> a class:<br />

• S_IRWXU—Set rwx <strong>for</strong> the owner class<br />

S_IRWXU is the read, write, <strong>and</strong> search/execute permission value <strong>for</strong> the file's<br />

owner class. It means that S_IRUSR, S_IWUSR, <strong>and</strong> S_IXUSR are all in effect.<br />

• S_IRWXG—Set rwx <strong>for</strong> the group class<br />

S_IRWXG is the read, write, <strong>and</strong> search/execute permission value <strong>for</strong> the file's group<br />

class. It means that S_IRGRP, S_IWGRP, <strong>and</strong> S_IXGRP are all in effect.<br />

3–20 7859 6137–009


• S_IRWXO—Set rwx <strong>for</strong> the other class<br />

File Concepts<br />

S_IRWXO is the read, write, <strong>and</strong> search/execute permission value <strong>for</strong> the file's other<br />

class. It means that S_IROTH, S_IWOTH, <strong>and</strong> S_IXOTH are all in effect.<br />

Example<br />

File Format<br />

Binary Format<br />

You can use the owner class permission value to code the previous example, as follows:<br />

open("/main_dir/my_dir/my_file", O_CREAT | O_RDWR,<br />

S_IRWXU | S_IRGRP | S_IROTH)<br />

The file mode contains in<strong>for</strong>mation about the data <strong>for</strong>mat of files, which can be either<br />

• Binary <strong>for</strong>mat—The S_1100BIN attribute is set in the file mode.<br />

• System data <strong>for</strong>mat (SDF)—The S_1100SDF attribute is set in the file mode.<br />

The <strong>for</strong>mat is important <strong>for</strong> files used with other <strong>OS</strong> <strong>2200</strong> software. Choose the <strong>for</strong>mat<br />

that is appropriate <strong>for</strong> the file’s purpose.<br />

If S_1100BIN is set, the file is an <strong>OS</strong> <strong>2200</strong> binary file. <strong>CIFS</strong> per<strong>for</strong>ms read <strong>and</strong> write<br />

operations to the file without special <strong>for</strong>matting.<br />

System Data Format<br />

Restrictions<br />

File Type<br />

If S_1100SDF is set, the file is an <strong>OS</strong> <strong>2200</strong> system data <strong>for</strong>mat (SDF) file. <strong>CIFS</strong> uses<br />

special SDF <strong>for</strong>matting to per<strong>for</strong>m read <strong>and</strong> write operations to the file.<br />

The following restrictions apply to the file <strong>for</strong>mat attributes:<br />

• A file can have at most one of the S_1100BIN <strong>and</strong> S_1100SDF attributes. An open()<br />

request fails when it tries to set both of them.<br />

• When S_1100BIN is not set, the file defaults to S_1100SDF.<br />

• Format cannot be changed once the file is created.<br />

The file mode contains in<strong>for</strong>mation about the file type, which identifies the file as a<br />

directory, a character file, a pipe or First-In-First-Out (FIFO) file, or a regular file.<br />

7859 6137–009 3–21


File Concepts<br />

Testing <strong>for</strong> File Type<br />

The macros in the following table test <strong>for</strong> the file type. Each macro returns one of the<br />

following values:<br />

• Nonzero, if the test is true<br />

• Zero if the test is false<br />

Macro Name File Type Determined by the Macro<br />

S_ISNET(m) Network file<br />

S_ISDIR(m) Directory<br />

S_ISCHR(m) Character (terminal, null, or r<strong>and</strong>om) file<br />

S_ISBLK(m) Block-oriented file (always FALSE <strong>for</strong> <strong>CIFS</strong>)<br />

S_ISREG(m) Regular file<br />

S_ISFIFO(m) Pipe or FIFO file<br />

S_ISELT(m) An element<br />

S_IS_1100(m) <strong>2200</strong> <strong>for</strong>mat (SDF or binary)<br />

S_ISBINELT(m) Binary element (relocatable, absolute, omnibus)<br />

S_ISSDFELT(m) SDF element<br />

S_ISUNKN(m) Type not yet known<br />

S_ISDIRECT(m) File mapped directly to an <strong>OS</strong> <strong>2200</strong> file or element<br />

S_ISSDF(m) SDF <strong>for</strong>mat<br />

S_ISBINARY(m) Binary <strong>for</strong>mat<br />

m is the st_mode field obtained through stat() or fstat().<br />

<strong>CIFS</strong> does not implement block special files. There<strong>for</strong>e, the S_ISBLK(m) test is always<br />

false.<br />

3–22 7859 6137–009


Related Functions<br />

File Concepts<br />

The following table identifies the tasks involved in managing files <strong>and</strong> the functions that<br />

per<strong>for</strong>m them. See Section 5 <strong>for</strong> detailed in<strong>for</strong>mation about each function.<br />

Topic Task Function<br />

Opening <strong>and</strong><br />

closing files<br />

<strong>and</strong> links<br />

Open a file, optionally creating the file if it does not<br />

exist.<br />

open(),<br />

fopen(),<br />

freopen()<br />

Create <strong>and</strong> open a new file. creat()<br />

Close a file, deallocating its file descriptor. close(),<br />

fclose()<br />

Create a link (new directory entry) to a file. link()<br />

Remove a link from a file, possibly deleting the file. unlink(),<br />

remove()<br />

Accessing files Determine if a process has permission to access a<br />

file or if the file exists.<br />

access()<br />

Change the file permissions in the file mode. chmod()<br />

Change the security attributes of a file. chown()<br />

Directories Determine the current working directory. getcwd()<br />

Change the current working directory. chdir()<br />

Create a new directory. mkdir()<br />

Remove (delete) a directory. rmdir()<br />

File in<strong>for</strong>mation Change the path name of a file or directory. rename()<br />

Determine in<strong>for</strong>mation about a file. fstat(), stat()<br />

Change access or modification time of a file or<br />

directory.<br />

utime()<br />

FIFO files Create a new First-In-First-Out (FIFO) file. mkfifo()<br />

7859 6137–009 3–23


File Concepts<br />

File I/O Operations<br />

This subsection describes reading <strong>and</strong> writing files <strong>and</strong> using directory entries <strong>and</strong><br />

streams, along with additional concepts related to I/O operations.<br />

Reading <strong>and</strong> Writing to Files<br />

Be<strong>for</strong>e reading or writing data to <strong>CIFS</strong> files other than directories, read <strong>and</strong> write<br />

operations require a file descriptor, which is made available when a process does one of<br />

the following:<br />

• Opens the file by calling the open() or creat() function, establishing an open file<br />

description with a corresponding file descriptor.<br />

• Inherits a file descriptor <strong>for</strong> an open file description from its parent process.<br />

A process can open a directory <strong>for</strong> reading (<strong>and</strong> read it) but not <strong>for</strong> writing.<br />

File Access by Multiple Processes<br />

An <strong>OS</strong> <strong>2200</strong> program can assign a file exclusively be<strong>for</strong>e writing to it. <strong>CIFS</strong> has no<br />

feature corresponding to exclusive assignment. There<strong>for</strong>e, you cannot prevent another<br />

process from writing to a file that is being used if the process has write permission <strong>for</strong><br />

the file.<br />

As an alternative, <strong>CIFS</strong> provides advisory record locks, which allow cooperating<br />

processes to coordinate access to part or all of a file. Advisory record locks do not<br />

prevent other processes with permission from writing to the file; any process can still<br />

read from or write to any portion of a file <strong>for</strong> which advisory record locks exist.<br />

But cooperating processes can check whether advisory locks exist <strong>and</strong> avoid writing to<br />

that segment until the lock is released. See below <strong>for</strong> an explanation of how advisory<br />

record locks work.<br />

Exclusive assignment of a file by any entity in the system prevents <strong>CIFS</strong> from accessing<br />

the file. This is true even if the file is exclusively assigned to the run making the <strong>CIFS</strong><br />

request.<br />

Making Sure Your Data Is Written to Disk<br />

The <strong>CIFS</strong> subsystem uses a buffering system in volatile storage <strong>for</strong> file data. Buffering<br />

increases the speed of input <strong>and</strong> output (I/O) operations, but it also increases the risk of<br />

lost data. <strong>CIFS</strong> provides the following mechanisms <strong>for</strong> securing data to disk storage (see<br />

Section 5 <strong>for</strong> details of how each mechanism works):<br />

• The O_DSYNC <strong>and</strong> O_SYNC flags <strong>for</strong> the open() function.<br />

• The fdatasync() <strong>and</strong> fsync() functions <strong>for</strong> individual files.<br />

3–24 7859 6137–009


Directory Entries <strong>and</strong> Streams<br />

File Concepts<br />

A directory entry is a file name or a subdirectory name within a directory (see above). A<br />

directory stream is a sequence of all the directory entries in a particular directory.<br />

Using Directory Streams<br />

Loosely, a directory stream is the list of names found in a particular directory. You might<br />

want to print a directory stream to have a record of the directory's contents or you might<br />

want to archive the file associated with each entry in the directory stream. The following<br />

functions process a directory stream:<br />

• The opendir() function opens the directory stream.<br />

• The closedir() function closes the directory stream.<br />

• The readdir() function reads the next entry in the directory stream.<br />

• The rewinddir() function repositions the directory stream to its beginning.<br />

In<strong>for</strong>mation on Directory Streams<br />

For each open directory stream, <strong>CIFS</strong> maintains a list of file names in the directory <strong>and</strong><br />

their corresponding file serial numbers; <strong>for</strong> each named file in a file system, the serial<br />

number is unique.<br />

Data Translation<br />

Automatic translation of data to <strong>and</strong> from Unicode may be enabled <strong>for</strong> SDF files stored in<br />

designated directories. For example, a directory can be set up to translate LETS-J data to<br />

Unicode when written to a file in the directory, <strong>and</strong> Unicode to Shift-JIS when read.<br />

The following character sets are supported:<br />

• UNICODE<br />

• Shift-JIS<br />

• LETS-J<br />

• JIS-X0201 (Katakana)<br />

• JIS-X0208 (Kanji)<br />

• JIS-X0212 (supplemental Kanji)<br />

• ISO8859-n (Latin variants 1 through 10 <strong>and</strong> 13 through 15)<br />

Use the <strong>CIFS</strong>UT xlate comm<strong>and</strong> (see Section 4) or the _cifs_xlate() API (Section 5) to<br />

establish translation modes <strong>for</strong> a directory.<br />

7859 6137–009 3–25


File Concepts<br />

Since a file can appear in more than one directory (using the <strong>CIFS</strong>UT ln comm<strong>and</strong> or the<br />

link() API) (Section 5), a given file can be read in multiple <strong>for</strong>mats once it is written in<br />

Unicode.<br />

Advisory Record Locks<br />

The advisory record locking mechanism provides a way <strong>for</strong> cooperating processes to<br />

coordinate the way they use a file. Cooperating processes can synchronize their behavior<br />

to avoid conflicting input <strong>and</strong> output (I/O) operations to the file.<br />

However, advisory record locks do not deny I/O access to a file. Any process with<br />

proper permissions can read from or write to the file regardless of the existence of<br />

advisory record locks.<br />

Processes use the fcntl() function to set, release, <strong>and</strong> check <strong>for</strong> advisory record locks.<br />

See Section 5 <strong>for</strong> a detailed description of the fcntl() function <strong>and</strong> its services. The<br />

following paragraphs provide a general description of how advisory record locks work.<br />

An advisory record lock is a mechanism by which a process alerts other cooperating<br />

processes of its I/O activity on some portion of a file. An exclusive advisory record lock<br />

prevents other processes from creating advisory record locks on that byte range. A<br />

process generally uses an exclusive lock when updating a file. A shared advisory record<br />

lock prevents other processes from creating exclusive advisory record locks on that byte<br />

range. A shared lock allows other shared locks, however. A process generally uses a<br />

shared lock when reading a file. Cooperating processes use the fcntl() function to<br />

request advisory locks <strong>for</strong> coordinating read <strong>and</strong> write operations on a file.<br />

Noncooperating processes do not use fcntl() or try to coordinate file access. They receive<br />

no in<strong>for</strong>mation about advisory locks that exist <strong>for</strong> a file.<br />

<strong>CIFS</strong> manages all advisory record locks set on a file. The list of locks is independent of<br />

other file attributes. When one process sets an advisory record lock on a portion of an<br />

open file <strong>and</strong> another process requests a lock on some or all of those bytes, <strong>CIFS</strong> takes<br />

one of the following actions, depending on the locking service specified in the call to<br />

fcntl():<br />

• Suspends the calling process until it can grant the lock request without conflict<br />

• Returns an error status to advise the calling process that a conflict exists<br />

The Status of Advisory Record Locks on a File<br />

For each byte in an open file, one of the following is true:<br />

• The byte is unlocked (no advisory record lock exists).<br />

• An exclusive advisory record lock exists.<br />

• One or more shared advisory record locks exist.<br />

3–26 7859 6137–009


The following diagram shows some bytes in an open file <strong>and</strong> their lock status<br />

(U=unlocked, E=exclusive lock, S=shared lock):<br />

E S S S U U U U U U E E E U U S S S S U U U U U<br />

1 2 3 4 5 6 7 8 9 10<br />

Characteristics of Locks<br />

Locks have the following characteristics:<br />

File Concepts<br />

• Locks can exist beyond the end of a file but cannot start be<strong>for</strong>e the beginning of a<br />

file.<br />

• If the requested lock length is 0, the fcntl() function extends the lock to the largest<br />

possible read/write offset.<br />

• Locks are associated with the file itself <strong>and</strong> not with the file descriptor or open file<br />

description.<br />

• Locks are not inherited by a child process.<br />

Shared <strong>and</strong> Exclusive Locks<br />

Existing shared locks owned by other processes allow the calling process to create a<br />

shared lock on any portion of the locked segment, but they deny requests <strong>for</strong> exclusive<br />

locks. Processes generally use shared locks when reading a file to avoid having other<br />

processes change the file's contents during the read operation.<br />

Existing exclusive locks deny all requests <strong>for</strong> shared or exclusive locks. Processes<br />

generally use exclusive locks when updating a file to avoid having other processes read<br />

or change the file's contents during the update operation.<br />

Lock Request Versus File Access Specification<br />

The lock request fails when it conflicts with the file access specification, as in the<br />

following cases:<br />

• A process requests a shared lock when the file is not open with read access.<br />

• A process requests an exclusive lock when the file is not open with write access.<br />

Locking <strong>and</strong> Unlocking Whole Files<br />

A process locks or unlocks an entire file if it specifies a lock of zero length <strong>and</strong> zero<br />

offset from the beginning of a file.<br />

7859 6137–009 3–27


File Concepts<br />

Removing Locks<br />

<strong>CIFS</strong> removes all file locks owned by a given process when the process<br />

• Closes any file descriptor <strong>for</strong> that file, whether or not the lock was created through<br />

that file descriptor<br />

• Terminates<br />

A process can remove a lock with the fcntl() function.<br />

Replacing <strong>and</strong> Merging Locks<br />

Deadlocks<br />

When a process successfully places a lock on a portion of a file that is adjacent to a lock<br />

of the same type that the process owns, <strong>CIFS</strong> merges the locks. For example, suppose a<br />

process owns shared locks on bytes 0 through 5 <strong>and</strong> bytes 7 through 9 in a file. The<br />

process requests a shared lock on byte 6 (or on a range including byte 6). The result is a<br />

single shared lock on bytes 0 through 9.<br />

A deadlock occurs when two or more processes try to access the same file in conflicting<br />

or restricted ways, resulting in one or more processes being suspended indefinitely.<br />

Deadlocks from Advisory Record Locks<br />

Deadlocks can occur as a result of conflicting requests <strong>for</strong> advisory record locks. The<br />

fcntl() function detects these conditions <strong>and</strong> prevents the deadlock by returning an error<br />

condition to the process requesting the conflicting lock.<br />

Deadlocks from Other Sources<br />

<strong>CIFS</strong> does not necessarily detect deadlocks that arise from services of the operating<br />

system or other software. There<strong>for</strong>e, <strong>CIFS</strong> cannot prevent deadlocks between processes<br />

that use advisory record locking in combination with other services that can cause<br />

suspension.<br />

For example, Transaction Processing (TIP) has a locking mechanism that can suspend a<br />

process. <strong>CIFS</strong> cannot detect this condition, however, <strong>and</strong> a deadlock can occur if<br />

another process tries to use a conflicting advisory record lock.<br />

Try to avoid potential deadlock situations when it is necessary to use other services that<br />

can cause suspension in conjunction with advisory record locking.<br />

3–28 7859 6137–009


Using Pipes<br />

File Concepts<br />

A pipe is a temporary mechanism <strong>for</strong> transferring data. Two processes can use a pipe,<br />

where one process calls the pipe() function to create a pipe <strong>and</strong> the other process<br />

accesses it. Both processes must know the pipe's file descriptors, so they must be<br />

either<br />

• Parent <strong>and</strong> child processes<br />

• Sibling processes (descended from the same parent)<br />

Alternatively, one process can use a pipe by itself.<br />

Example<br />

A common use <strong>for</strong> pipes is to pass data between two processes running different<br />

programs, as shown in the following diagram. Process A creates a pipe <strong>and</strong> writes data<br />

to it. Process B is a child of process A <strong>and</strong> inherits A's file descriptors. In particular,<br />

fildes[0] is the pipe's file descriptor <strong>for</strong> reading <strong>and</strong> fildes[1] is the pipe's file descriptor<br />

<strong>for</strong> writing. There<strong>for</strong>e, process B can read the data in the pipe <strong>and</strong> use it as necessary.<br />

All read <strong>and</strong> write operations are done on a First-In-First-Out (FIFO) basis.<br />

0<br />

1<br />

fildes[0]<br />

fildes[1]<br />

Process<br />

A<br />

_<strong>CIFS</strong>_NEW_PROCESS ( )<br />

fildes[0]<br />

fildes[1]<br />

File Descriptors File Descriptors<br />

7859 6137–009 3–29<br />

0<br />

1<br />

Process<br />

B


File Concepts<br />

Example Code<br />

The following code shows a simple example of a parent writing a message to a pipe <strong>and</strong><br />

creating a child process. The child reads the message <strong>and</strong> prints it. For simplicity, error<br />

checking is omitted.<br />

#include <br />

#include <br />

void child = thread(int read = fd) {<br />

}<br />

char msg[16];<br />

int count;<br />

/* Loop to insure we get all of the input until write end closes. */<br />

while ((count = read(readfd, msg, sizeof msg - 1)) > 0) {<br />

msg[count] = '\0';<br />

printf("Child: read %d byte message from pipe end %d\n",<br />

count, msg, read = fd);<br />

}<br />

/* Closing read end is not strictly necessary. */<br />

close(read = fd);<br />

return;<br />

int main() {<br />

int fd = pipe[2];<br />

}<br />

= task_array new = task = { 2, 0 };<br />

char message[] = "This is a piped string.";<br />

/* Create the pipe. */<br />

pipe(fd_pipe);<br />

/* Start child, passing pipe read end. */<br />

tskstart(new_task, child_thread, fd_pipe[0]);<br />

printf("Parent: writing to pipe end %d\n",<br />

message, fd_pipe[1]);<br />

write(fd_pipe[1], message, sizeof message);<br />

/* Child won't terminate until write end is closed. */<br />

close(fd_pipe[1]);<br />

return 0;<br />

3–30 7859 6137–009


This program produces the following output:<br />

Parent: writing to pipe end 4<br />

Child: read 15 byte message from pipe end 3<br />

Child: read 9 byte message < string.> from pipe end 3<br />

Related Functions<br />

File Concepts<br />

The following table identifies the tasks involved in file input <strong>and</strong> output (I/O) operations<br />

<strong>and</strong> the functions that per<strong>for</strong>m them. See Section 5 <strong>for</strong> detailed in<strong>for</strong>mation about each<br />

function.<br />

Topic Task Function<br />

Reading <strong>and</strong><br />

writing<br />

operations<br />

File descriptors,<br />

advisory locks,<br />

<strong>and</strong> the<br />

read/write offset<br />

Read a file. read()<br />

Write to a file. write()<br />

Write all data from buffer to a file, synchronizing<br />

data.<br />

Write all data from buffer to a file, synchronizing<br />

the file’s state (access times).<br />

fdatasync()<br />

fsync()<br />

Write all data from buffer, synchronizing data. sync()<br />

Create file descriptor <strong>for</strong> existing open file<br />

description.<br />

Associate a specific file descriptor with an existing<br />

open file description.<br />

Access <strong>and</strong> set the read/write offset, file descriptor<br />

flags, file status flags, <strong>and</strong> advisory record locking<br />

in<strong>for</strong>mation.<br />

Create a stream <strong>and</strong> associate it with a file<br />

descriptor.<br />

7859 6137–009 3–31<br />

dup()<br />

dup2()<br />

fcntl()<br />

fdopen()<br />

Retrieve a file descriptor <strong>for</strong> a specific data stream. fileno()<br />

Set the read/write offset <strong>for</strong> an open file. lseek()<br />

Pipes Create a pipe. pipe()<br />

Directories Open a directory stream. opendir()<br />

Close an open directory stream. closedir()<br />

Read a directory stream. readdir()<br />

Reposition a directory stream at its beginning. rewinddir()


File Concepts<br />

Environment Variables<br />

Environment variables control various aspects of <strong>CIFS</strong> operation, through both<br />

application program <strong>and</strong> utility interfaces. If a variable does not exist, <strong>CIFS</strong> assumes its<br />

value is blank, except as noted. Variables can be accessed through the set <strong>and</strong> setsys<br />

comm<strong>and</strong>s of the <strong>CIFS</strong> utility, or through the PUT$ENV <strong>and</strong> GET$ENV interfaces, as<br />

documented in the System Services Programming Reference Manual.<br />

Environment variables cannot be set by transaction processing (TIP) programs. However,<br />

TIP programs uses any environment variable settings established in the system or an<br />

appropriate user profile.<br />

Variable names are case sensitive; all <strong>CIFS</strong> variables must be specified in upper case.<br />

Lower case or mixed case names can be set by @<strong>CIFS</strong>UT <strong>for</strong> other purposes, but will<br />

not be recognized by the <strong>CIFS</strong> subsystem. The values are not case sensitive.<br />

Variable Legal Values Description<br />

<strong>CIFS</strong>$ACR PUBLIC,<br />

PRIVATE, or any<br />

valid ACR name<br />

useable by the<br />

caller.<br />

<strong>CIFS</strong>$CACHE Any numeric<br />

value. A k, m, or<br />

g suffix applies a<br />

multiplier of<br />

1024, 1024k, or<br />

1024m,<br />

respectively<br />

<strong>CIFS</strong>$CAT Valid @CAT<br />

parameters<br />

starting with the<br />

type field; if<br />

blank, the system<br />

default type is<br />

used in<br />

conjunction with<br />

a maximum size<br />

of 262,143<br />

tracks.<br />

<strong>CIFS</strong>$CD Any valid <strong>CIFS</strong><br />

directory name.<br />

Specifies the <strong>OS</strong> <strong>2200</strong> security attributes to<br />

set <strong>for</strong> any new files created through <strong>CIFS</strong><br />

or <strong>for</strong> existing files undergoing ownership<br />

change. Default is PRIVATE.<br />

Specifies the size of the <strong>CIFS</strong> file cache.<br />

The default size is 64 MW, <strong>and</strong> the<br />

minimum is 16 MW. Using a value smaller<br />

than the minimum results in <strong>CIFS</strong> using the<br />

minimum.<br />

Specifies the parameters to use on any<br />

mkdir() or open() with O_CREAT that<br />

creates an <strong>OS</strong> <strong>2200</strong> file associated with the<br />

specified <strong>CIFS</strong> directory or file.<br />

Specifies the current working directory.<br />

Defaults to /os<strong>2200</strong>/<br />

Changed by <strong>CIFS</strong> on any successful chdir()<br />

call.<br />

3–32 7859 6137–009


Variable Legal Values Description<br />

<strong>CIFS</strong>$COMAPI Communications<br />

Application<br />

Program<br />

Interface<br />

installation<br />

modes (letters A<br />

through Z, in any<br />

combination).<br />

<strong>CIFS</strong>$KEYS Valid <strong>OS</strong> <strong>2200</strong><br />

read/write keys in<br />

the <strong>for</strong>m<br />

/, or blank; the<br />

separating slash<br />

may be omitted if<br />

the write key is<br />

blank or not<br />

needed.<br />

File Concepts<br />

Specifies the Communications Application<br />

Program Interface installation modes that<br />

<strong>CIFS</strong> must use <strong>for</strong> network access. Used<br />

only by the <strong>CIFS</strong> background run. Defaults<br />

to mode A if not specified.<br />

Specifies the read <strong>and</strong> write keys used to<br />

access or create a file on the next [f]open(),<br />

mkdir(), opendir(), or stat() request. Cleared<br />

on any successful [f]open(), mkdir(), or<br />

opendir() call.<br />

<strong>CIFS</strong>$MFD STD, SHARED Specifies which <strong>2200</strong> master file directory<br />

to use <strong>for</strong> file lookup <strong>and</strong> creation. If this<br />

value is not present, <strong>CIFS</strong> uses the caller’s<br />

default MFD setting.<br />

<strong>CIFS</strong>$NEXTFILE Any valid<br />

<strong>OS</strong> <strong>2200</strong> file<br />

name.<br />

Specifies what <strong>2200</strong> file to associate with<br />

the <strong>CIFS</strong> file created on the next mkdir() or<br />

[f]open() that creates a new file. This value<br />

is ignored if the <strong>CIFS</strong> file name uses the<br />

/os<strong>2200</strong> path. Cleared on any successful<br />

mkdir() or [f]open() call, regardless of<br />

whether a file was created or the /os<strong>2200</strong><br />

structure was used.<br />

<strong>CIFS</strong>$PW Password Specifies the authorization password to be<br />

used by the <strong>CIFS</strong> client to connect with<br />

remote hosts.<br />

<strong>CIFS</strong>$RAW TRUE, FALSE Specifies whether or not data must be<br />

written exactly as received by <strong>CIFS</strong> (TRUE)<br />

or converted to SDF <strong>for</strong>mat (FALSE). The<br />

default is FALSE. Applies only to the next<br />

open() that creates a new file, <strong>and</strong> is<br />

cleared on any successful open() or fopen().<br />

<strong>CIFS</strong>$SUBTYPE St<strong>and</strong>ard element<br />

subtypes.<br />

Specifies what symbolic or omnibus<br />

element subtype <strong>CIFS</strong> must attach to an<br />

element created on the next [f]open().<br />

Cleared on any successful [f]open().<br />

Defaults to the file name extension, if it is<br />

one of the st<strong>and</strong>ard subtype mnemonics.<br />

7859 6137–009 3–33


File Concepts<br />

Variable Legal Values Description<br />

<strong>CIFS</strong>$USER <strong>User</strong> ID <strong>and</strong><br />

optional domain.<br />

<strong>CIFS</strong>$WAITROLBAK Any numeric<br />

value. A k, m, or<br />

g suffix applies a<br />

multiplier of<br />

1024, 1024k, or<br />

1024m,<br />

respectively.<br />

<strong>CIFS</strong>$WAITXUSE Any numeric<br />

value. A k, m, or<br />

g suffix applies a<br />

multiplier of<br />

1024, 1024k, or<br />

1024m,<br />

respectively.<br />

Specifies authorization credentials to be<br />

used by the <strong>CIFS</strong> client to connect with<br />

remote hosts.<br />

Specifies the amount of time, in seconds,<br />

that a caller must wait <strong>for</strong> a rolled-out file<br />

when O_NONBLOCK is not set on an<br />

open() request. The default value is 600 (10<br />

minutes).<br />

Specifies the amount of time, in seconds,<br />

that a caller must wait <strong>for</strong> an exclusively<br />

assigned file when O_NONBLOCK is not<br />

set on an open() request. The default value<br />

is 0.<br />

3–34 7859 6137–009


Section 4<br />

Utility Interfaces<br />

<strong>CIFS</strong> includes a text-based utility, @<strong>CIFS</strong>UT that provides a comm<strong>and</strong> line interface to<br />

manipulate entities within the <strong>CIFS</strong> file system. The utility accepts comm<strong>and</strong>s modeled<br />

after those typically available in Windows 95/98/Me, Windows NT4/2000/XP/2003/Vista,<br />

<strong>and</strong> P<strong>OS</strong>IX systems. Generally, the Windows comm<strong>and</strong>s are aliases <strong>for</strong> the P<strong>OS</strong>IX<br />

comm<strong>and</strong>s with either a one-to-one correspondence or a subset of the P<strong>OS</strong>IX options.<br />

@<strong>CIFS</strong>UT automatically determines the syntax being requested (P<strong>OS</strong>IX or Windows), so<br />

the syntax <strong>for</strong> comm<strong>and</strong>s shown in the following tables <strong>and</strong> descriptions can be freely<br />

intermixed in any utility session.<br />

Note: The syntax <strong>for</strong> directory <strong>and</strong> file names is given in Section 1. However, the<br />

Windows comm<strong>and</strong>s use a back slash (\) rather than the st<strong>and</strong>ard <strong>for</strong>ward slash (/) as a<br />

directory delimiter. The st<strong>and</strong>ard <strong>for</strong>ward slash (/) indicates option values <strong>for</strong> the<br />

Windows comm<strong>and</strong>s. Any directory or file name that includes embedded spaces or<br />

other special characters (both Windows <strong>and</strong> P<strong>OS</strong>IX versions) must be bracketed by a<br />

quotation mark (“) at each end. Otherwise, one or more spaces function as field<br />

separators.<br />

Each comm<strong>and</strong> input to @<strong>CIFS</strong>UT consists of one or more lines of ASCII text. Any<br />

comm<strong>and</strong> that spans more than one line must use a vertical line (|) at the end of each<br />

continued line.<br />

The <strong>for</strong>mat of the processor call line is<br />

@<strong>CIFS</strong>UT[,opt] [comm<strong>and</strong>_set,...]<br />

<strong>CIFS</strong>UT sequentially processes comm<strong>and</strong>s contained in the comm<strong>and</strong>_set files or<br />

elements (if any), <strong>and</strong> then reads comm<strong>and</strong>s from the input stream. Display of comm<strong>and</strong><br />

lines processed by <strong>CIFS</strong>UT is controlled by the processor call options L, N, <strong>and</strong> S, as well<br />

as the echo comm<strong>and</strong>. By default, <strong>CIFS</strong>UT displays comm<strong>and</strong>s from any comm<strong>and</strong>_set<br />

files or elements, but not from the input stream. Specifying the L or S options causes<br />

<strong>CIFS</strong>UT to display all comm<strong>and</strong>s; specifying the N option inhibits display of any lines.<br />

7859 6137–009 4–1


Masking with @<strong>CIFS</strong>UT<br />

Comm<strong>and</strong>s include<br />

P<strong>OS</strong>IX Syntax Windows Syntax Description<br />

backup backup Save <strong>CIFS</strong> directory structure.<br />

binjar [-r]<br />

new_ext<br />

[pathname<br />

[old_ext]...]<br />

binjar<br />

new_ext<br />

[pathname<br />

[old_ext]...] [/s]<br />

Convert files from SDF to binary <strong>for</strong>mat.<br />

cat cat (type) Copy one or more files to the st<strong>and</strong>ard output<br />

stream.<br />

cd cd (chdir) Change current working directory.<br />

chmod — Change file permissions.<br />

chown — Change the owner of a file.<br />

cp copy Copy one or more files to a target.<br />

date — Display local date, UTC/GMT date, or local offset<br />

from UTC/GMT.<br />

— deltree Delete directory <strong>and</strong> all files <strong>and</strong> subdirectories.<br />

echo echo Control display of input comm<strong>and</strong> lines.<br />

help help Gives a <strong>CIFS</strong>UT comm<strong>and</strong> list or comm<strong>and</strong> syntax.<br />

ln — Insert a link <strong>for</strong> a regular or FIFO file into a directory.<br />

ls dir Display file in<strong>for</strong>mation on st<strong>and</strong>ard output.<br />

keys keys Set <strong>and</strong> clear environmental variables.<br />

mkdir md (mkdir) Create directory.<br />

mkfifo — Create fifo file.<br />

mv move Move or rename file.<br />

pwd cd (chdir) Write absolute path name of working directory to<br />

st<strong>and</strong>ard output.<br />

rm del Remove file entries in a directory.<br />

rmdir rd (rmdir) Remove empty directory.<br />

set set Display, initialize or update environment variables.<br />

setsys setsys Display, initialize, or update system environment<br />

variables.<br />

share share Create network-visible name <strong>for</strong> directory.<br />

size size Change logical length of a regular file.<br />

touch — Change access <strong>and</strong>/or modification time/date of files<br />

<strong>and</strong> optionally pack the underlying <strong>OS</strong> <strong>2200</strong> program<br />

files of directories.<br />

unshare unshare Remove network-visible name <strong>for</strong> directory.<br />

4–2 7859 6137–009


P<strong>OS</strong>IX Syntax Windows Syntax Description<br />

Masking with @<strong>CIFS</strong>UT<br />

use use Attach an <strong>OS</strong> <strong>2200</strong> internal name to a <strong>CIFS</strong><br />

directory.<br />

version version Display <strong>CIFS</strong> subsystem version in<strong>for</strong>mation.<br />

xlate xlate Set or display translation modes <strong>for</strong> a directory.<br />

Masking with @<strong>CIFS</strong>UT<br />

You can use masks when providing file names to the @<strong>CIFS</strong>UT comm<strong>and</strong>s. The two<br />

mask characters * <strong>and</strong> ? can be used in any combination.<br />

Use ∗ to match zero or more characters.<br />

Use ? to match any single character.<br />

Masking can be used only in the cd, chmod, chown, copy, cp, del, deltree, dir, ln, ls,<br />

move, mv, rd, rm, <strong>and</strong> rmdir comm<strong>and</strong>s; it is not available with any of the others.<br />

Masking cannot be specified in any comm<strong>and</strong> target; <strong>for</strong> example, “cp t∗ x∗ “ is not<br />

allowed. Also, masking characters only apply to @<strong>CIFS</strong>UT; they cannot be used in the<br />

program interfaces other than _cifs_mask().<br />

Examples<br />

ls file∗abc<br />

Displays all files that begin with “file” <strong>and</strong> end with “abc.” The file can have<br />

anything in between. Valid values include “fileabc.”<br />

ls file?<br />

Displays all 5-character file names that begin with “file” <strong>and</strong> have another character<br />

at the end of the file name; plain “file” cannot be matched.<br />

ls ∗jan??<br />

Displays all file names that end with “jan” followed by two more characters.<br />

7859 6137–009 4–3


ackup<br />

backup<br />

Application<br />

Use the backup comm<strong>and</strong> to save the <strong>CIFS</strong> directory structure by generating the<br />

necessary <strong>CIFS</strong>UT or FAS comm<strong>and</strong>s to rebuild the structure.<br />

Note: This comm<strong>and</strong> is intended <strong>for</strong> administrator use, <strong>and</strong> must be done whenever a<br />

system-wide file save is per<strong>for</strong>med. Individual users can use the backup comm<strong>and</strong> on<br />

specific directories to obtain a snapshot of that specific part of the file system.<br />

P<strong>OS</strong>IX Syntax<br />

backup [-f] savefile [start_directory]<br />

Windows Syntax<br />

backup savefile [start_directory] [/f]<br />

Arguments<br />

savefile<br />

specifies where to store the generated comm<strong>and</strong>s. This file must be used as input<br />

to <strong>CIFS</strong>UT (no f-option) or FAS (f-option) to restore the <strong>CIFS</strong> directory structure if it is<br />

necessary to reinitialize it.<br />

start_directory<br />

-f or /f<br />

specifies the directory within the <strong>CIFS</strong> file system where scanning must start. If not<br />

specified, start_directory defaults to the system root directory.<br />

generates FAS backup comm<strong>and</strong>s <strong>for</strong> the specified starting directory <strong>and</strong><br />

subdirectories. If no starting directory is given, FAS backup comm<strong>and</strong>s <strong>for</strong> only <strong>CIFS</strong><br />

system files are generated. (This requires that the run is <strong>CIFS</strong>-privileged.)<br />

4–4 7859 6137–009


injar<br />

Application<br />

binjar<br />

Use the binjar comm<strong>and</strong> to convert files from SDF to binary <strong>for</strong>mat, renaming the original<br />

to avoid losing it. By default, binjar operates on .jar files, but other extensions may also<br />

be specified.<br />

P<strong>OS</strong>IX or Windows Syntax<br />

binjar [-r] new_ext [pathname [old_ext]...]<br />

Windows Syntax<br />

binjar new_ext [pathname [old_ext]...] [/s]<br />

Arguments<br />

-r<br />

indicates to recursively process all files in the specified directory <strong>and</strong> its<br />

subdirectories.<br />

new_ext<br />

specifies the additional extension used to rename all files converted to binary <strong>for</strong>mat.<br />

pathname<br />

specifies the name of the file or directory on which to operate. Masking is not<br />

permitted. Must be a directory if either the -r or /s option is used.<br />

old_ext<br />

/s<br />

specifies the extensions <strong>for</strong> the files to convert, if other than the default value (jar).<br />

May be used only if pathname is a directory.<br />

indicates to recursively process all files in the specified directory <strong>and</strong> its<br />

subdirectories.<br />

7859 6137–009 4–5


cat (type)<br />

cat (type)<br />

Application<br />

Use the cat (type) comm<strong>and</strong> to copy one or more files to the st<strong>and</strong>ard output<br />

stream.<br />

P<strong>OS</strong>IX Syntax<br />

cat [-estv] source [source ...]<br />

Windows Syntax<br />

type source [source ...]<br />

Arguments<br />

-e<br />

-s<br />

-t<br />

-v<br />

source<br />

Causes a $ character to be printed at the end of each line be<strong>for</strong>e the newline;<br />

ignored if the -v option is not present.<br />

Forces the comm<strong>and</strong> to be silent about nonexistent files.<br />

Causes tabs to be printed as ^I <strong>and</strong> <strong>for</strong>mfeeds as ^L; ignored if the ---v option is not<br />

present.<br />

Causes nonprinting characters (other than tabs, <strong>for</strong>mfeeds, newlines) to be displayed<br />

as ^n, M-x, M+x, or M*x. For control characters, n is the uppercase ASCII character<br />

obtained by adding 0100 to the character value; <strong>for</strong> DEL, n is a question mark. For<br />

characters outside of the ASCII range, M-, M+, <strong>and</strong> M* indicate the ranges<br />

0200-0377, 0400-0577, <strong>and</strong> 0600-0777 respectively; x is the ASCII character defined<br />

by the seven low-order bits of the character value.<br />

Specifies the names of the file to be copied.<br />

4–6 7859 6137–009


cd (chdir)<br />

Application<br />

cd (chdir)<br />

Use the cd (chdir) comm<strong>and</strong> to change the current working directory. The new working<br />

directory may be specified with either an absolute or relative path name.<br />

P<strong>OS</strong>IX or Windows Syntax<br />

cd [dirname]<br />

Windows Syntax<br />

chdir [dirname]<br />

Arguments<br />

dirname specifies the path name of the directory to which you want to change.<br />

Note: cd without any parameters functions as pwd, displaying the current working<br />

directory.<br />

7859 6137–009 4–7


chmod<br />

chmod<br />

Application<br />

Use the chmod comm<strong>and</strong> to change file permissions (read, write, or search/execute) <strong>for</strong><br />

a file, as appropriate <strong>for</strong> the file type. If the target of the comm<strong>and</strong> refers to a file in the<br />

<strong>OS</strong> <strong>2200</strong> Master File Directory, the read-only <strong>and</strong> write-only attributes of that file are also<br />

changed to correspond to the <strong>CIFS</strong> file permissions.<br />

P<strong>OS</strong>IX Syntax<br />

chmod [-r] {mode |[ugoa]{{+|-|=}[rwxugo]}...[,[ugoa]{{+|-=}[rwxugo]}...]...}<br />

file ...<br />

Arguments<br />

-r<br />

mode<br />

ugoa<br />

recursively changes the file modes of all files (including directories) subordinate to<br />

the specified directory, except <strong>for</strong> the following cases:<br />

• Some files might not be accessible, such as a file within a directory that does<br />

not have search permission; chmod cannot operate on such a file.<br />

• chmod changes the mode of the directory be<strong>for</strong>e changing the modes of the<br />

directory's files. If the specified change turns off the directory's search or read<br />

permission, chmod cannot access the directory <strong>and</strong> is prevented from changing<br />

any of its files.<br />

specifies the permission values as a 3-digit number, with one digit <strong>for</strong> the user,<br />

group, <strong>and</strong> other classes, respectively. The permission values are:<br />

4 read<br />

2 write<br />

1 execute<br />

These values must be added together to give the desired permission <strong>for</strong> each class.<br />

For example, the value 754 gives full access to the owning user, read <strong>and</strong> execute<br />

access to the group, <strong>and</strong> only read access to other users.<br />

specifies the who value, which identifies the permission classes to change. It<br />

contains zero or more of the following values:<br />

u <strong>User</strong> (owner) class<br />

g Group class<br />

o Other class<br />

a All classes (default)<br />

4–8 7859 6137–009


+-=<br />

specifies the operator value, which identifies how to change the permissions. It<br />

contains one of the following values:<br />

rwxugo<br />

file<br />

chmod<br />

+ Add permission<br />

- Subtract permission<br />

= Assign permission; that is, clear all the bits in the who value <strong>and</strong> then add<br />

the permission.<br />

specifies the permission value, which identifies the permissions to change. It<br />

contains zero or more of the following values:<br />

r Read permission<br />

w Write permission<br />

x Search/execute permission<br />

u Read, write, <strong>and</strong> execute as currently set <strong>for</strong> user class<br />

g Read, write, <strong>and</strong> execute as currently set <strong>for</strong> group class<br />

o Read, write, <strong>and</strong> execute as currently set <strong>for</strong> other class<br />

identifies the file whose file mode is changed by this chmod request.<br />

7859 6137–009 4–9


chown<br />

chown<br />

Application<br />

Use the chown comm<strong>and</strong> to change the owner of a file. Only the owner of the file or a<br />

privileged user can change the owner. If the value of the <strong>CIFS</strong>$ACR environment variable<br />

is not blank, that value (public, private, or ACR name) is applied to the specified files.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

chown [-r] owner file ...<br />

Arguments<br />

-r<br />

owner<br />

file<br />

indicates recursive traversal of directories. When this option is specified, chown acts<br />

on all files in the named directory, all subordinate directories, <strong>and</strong> all files in the<br />

subordinate directories, except where read or search permission is lacking.<br />

specifies the user name or numeric user ID of the new owner. A user name can<br />

appear numeric (<strong>for</strong> example, 765). If you specify a numeric value, chown assumes it<br />

is a user name unless no user with that name exists. In that case, chown treats the<br />

value as a user ID.<br />

identifies the file whose owner is changed by this chown request.<br />

Examples<br />

Change the file owner <strong>for</strong> a single file using a user name:<br />

chown jdoe my_file<br />

Change the file owner <strong>for</strong> multiple files:<br />

chown jdoe my_file my_file2 memo.bob<br />

Change the file owner using a numeric user ID:<br />

chown 123 my_file<br />

Change the owner <strong>for</strong> all files in a directory <strong>and</strong> all subordinate directories <strong>and</strong> files:<br />

chown -R jdoe my_dir<br />

4–10 7859 6137–009


cp (copy)<br />

Application<br />

cp (copy)<br />

Use the cp (copy) comm<strong>and</strong> to copy one or more files (including directories) to a target.<br />

P<strong>OS</strong>IX Syntax<br />

cp [-firpbsw] source [source ...] target<br />

Windows Syntax<br />

copy source [source ...] target [/w]<br />

Arguments<br />

-c<br />

When FTP Services (<strong>for</strong>merly cpFTP) copies a file to an <strong>OS</strong> <strong>2200</strong> system in mode C<br />

<strong>for</strong>mat (two <strong>OS</strong> <strong>2200</strong> words placed in 9 consecutive bytes), the resulting data cannot<br />

be used without first being re<strong>for</strong>matted. The -c option implements conversions<br />

between binary <strong>and</strong> SDF, as follows:<br />

Without the -c option:<br />

Binary input – Each quarter word written to one character<br />

SDF input – each character written to one quarter word<br />

With the -c option:<br />

-f<br />

-i<br />

-r<br />

Binary input – 8 quarter words written to 9 characters<br />

SDF input – 9 characters written to 8 quarter words<br />

This permits relatively easy correction of files mangled by FTP.<br />

<strong>for</strong>ce the copy if target is read only.<br />

prompts <strong>for</strong> confirmation whenever the copy would overwrite an existing target.<br />

must be specified when the source is a directory. If the directory named by target<br />

does not exist, cp creates a directory named target <strong>and</strong> copies all the files, including<br />

any subdirectories <strong>and</strong> their files, in source to target. If the directory named by target<br />

exists, a copy of source (with its attendant file structure) becomes a subdirectory of<br />

target. In either case, all files retain their file types.<br />

7859 6137–009 4–11


cp (copy)<br />

-p<br />

-b<br />

-s<br />

source<br />

target<br />

sets the following attributes of target to the same values as in source:<br />

Last modification <strong>and</strong> access times<br />

File mode settings<br />

<strong>for</strong>ce copy of source to binary <strong>for</strong>mat.<br />

<strong>for</strong>ce copy of source to SDF <strong>for</strong>mat.<br />

specifies the name of the file to be copied. If target is a directory, you can specify<br />

more than one file; otherwise, only one file is permitted.<br />

specifies the destination file name (might be a directory); target must be different<br />

from source.<br />

-w <strong>and</strong> /w<br />

removes carriage returns from the ends of lines.<br />

4–12 7859 6137–009


date<br />

Application<br />

Use the date comm<strong>and</strong> to display the local time/date, UTC/GMT time/date, or local time<br />

offset from UTC/GMT time.<br />

P<strong>OS</strong>IX Syntax<br />

date [-o] [-u]<br />

Arguments<br />

-o<br />

-u<br />

displays the local time offset from UTC/GMT time in the <strong>for</strong>mat hh:mm.<br />

displays UTC/GMT time.<br />

Note: Not specifying any options displays the local system time.<br />

date<br />

7859 6137–009 4–13


deltree<br />

deltree<br />

Application<br />

Use the deltree comm<strong>and</strong> to delete a specific directory <strong>and</strong> all files <strong>and</strong> subdirectories.<br />

The rm –r comm<strong>and</strong> is the P<strong>OS</strong>IX equivalent.<br />

Windows Syntax<br />

deltree dirname<br />

Arguments<br />

dirname<br />

is the location <strong>and</strong> name of the directory you want to delete.<br />

4–14 7859 6137–009


echo<br />

Application<br />

Use the echo comm<strong>and</strong> to control display of input comm<strong>and</strong> lines.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

echo [on³off]<br />

Arguments<br />

on<br />

off<br />

enables display of input comm<strong>and</strong> lines.<br />

disables display of input comm<strong>and</strong> lines.<br />

On is assumed if neither on nor off is specified.<br />

echo<br />

7859 6137–009 4–15


help<br />

help<br />

Application<br />

Use the help comm<strong>and</strong> to display a list of <strong>CIFS</strong>UT comm<strong>and</strong>s or to display the syntax of<br />

a list of <strong>CIFS</strong>UT comm<strong>and</strong>s.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

help [cmd ...]<br />

Arguments<br />

cmd<br />

A <strong>CIFS</strong>UT comm<strong>and</strong> name, such as cat or ls. Multiple comm<strong>and</strong> names can be listed<br />

<strong>and</strong> are separated by blanks.<br />

4–16 7859 6137–009


keys<br />

Application<br />

Use the keys comm<strong>and</strong> to have <strong>CIFS</strong>UT set <strong>and</strong> clear the environment variable<br />

<strong>CIFS</strong>$KEYS be<strong>for</strong>e manipulating <strong>OS</strong> <strong>2200</strong> files that have read or write keys. Read/write<br />

keys can be used <strong>for</strong> unowned files <strong>and</strong> <strong>for</strong> owned files if the<br />

owned_file_read_write_keys dynamic configuration parameter is set to true. Using the<br />

set comm<strong>and</strong> to establish a <strong>CIFS</strong>$KEYS value also sets both the source <strong>and</strong> target<br />

values <strong>for</strong> the keys comm<strong>and</strong>.<br />

keys<br />

Note: <strong>CIFS</strong>UT uses the source or target keys settings only in subsequent comm<strong>and</strong>s,<br />

such as cp, mv, rm, <strong>and</strong> so on; it does not change <strong>CIFS</strong>$KEYS immediately. The source<br />

value is used <strong>for</strong> dir, ls, share, use, <strong>and</strong> the “from” side of copy, cp, ln, move, <strong>and</strong> mv.<br />

The target value is used <strong>for</strong> chmod, chown, del, deltree, md, mkdir, rd, rm, <strong>and</strong> rmdir,<br />

<strong>and</strong> the “to” side of backup, copy, cp, ln, move, <strong>and</strong> mv. The difference between source<br />

<strong>and</strong> target is whether the file or directory is just being read or it is being changed.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

keys [source=[rkey][/wkey]] [target=[rkey][/wkey]]<br />

Formats/Arguments<br />

keys<br />

clears both the source <strong>and</strong> target keys settings.<br />

keys source=[rkey][/wkey]<br />

sets the <strong>CIFS</strong>$KEYS value <strong>for</strong> the source file keys <strong>and</strong> clears the <strong>CIFS</strong>$KEYS setting<br />

<strong>for</strong> target file keys (since no target argument is specified).<br />

keys target=[rkey][/wkey]<br />

sets the <strong>CIFS</strong>$KEYS value <strong>for</strong> the target file keys <strong>and</strong> clears the <strong>CIFS</strong>$KEYS setting<br />

<strong>for</strong> source file keys (since no source argument is specified).<br />

keys source=[rkey][/wkey] target=[rkey][/wkey]<br />

sets the <strong>CIFS</strong>$KEYS value <strong>for</strong> both the source <strong>and</strong> target file keys.<br />

[rkey][/wkey]<br />

specifies the values of the source or target file read <strong>and</strong> write keys.<br />

7859 6137–009 4–17


ln<br />

ln<br />

Application<br />

Use the ln comm<strong>and</strong> to create additional directory entries <strong>for</strong> a specified set of regular or<br />

FIFO files. When linked, different file names (typically in different directories) refer to the<br />

same file contents. There is no Windows equivalent.<br />

P<strong>OS</strong>IX Syntax<br />

ln [-f] source [source...] target<br />

Arguments<br />

-f<br />

source<br />

target<br />

is required when the file named by target already exists.<br />

specifies the name of an existing file to which target is linked. You can specify more<br />

than one source if target names a directory (other than the directory containing the<br />

source files).<br />

specifies the name of the file to be linked to source-file or the name of the directory<br />

where the new linked file name is to be created:<br />

• If target does not exist, file name target is created <strong>and</strong> linked to source-file.<br />

• If a file named target already exists, its contents are removed <strong>and</strong> target is linked<br />

to source-file (subject to the conditions described under the -f option).<br />

• If target names a directory, the file name source-file is created in that directory<br />

<strong>and</strong> linked to the original source-file.<br />

4–18 7859 6137–009


ls (dir)<br />

Application<br />

Use the ls (dir) comm<strong>and</strong> to write in<strong>for</strong>mation about files to the st<strong>and</strong>ard output.<br />

Note: File types are identified by a question mark (?) when <strong>CIFS</strong> has not yet<br />

determined whether the object is a file or a directory.<br />

P<strong>OS</strong>IX Syntax<br />

ls [-agilmortuvx12] [filename ...]<br />

Windows Syntax<br />

dir [filename...] [/a[[:]attributes]] [/o[[:]sortorder]] [/t[[:]timefield]]<br />

[/s] [/2]<br />

Arguments<br />

-a<br />

-g<br />

-i<br />

-l<br />

-m<br />

-o<br />

-r<br />

-t<br />

displays all directory entries.<br />

displays the same in<strong>for</strong>mation as -l, except <strong>for</strong> owner user ID.<br />

displays the inode number of the directory entry.<br />

ls (dir)<br />

displays additional file in<strong>for</strong>mation: file type, file permissions, number of links, owner<br />

user ID, group (ACR) ID, file size in bytes, <strong>and</strong> last modification time.<br />

displays entry names in a stream, separated by commas.<br />

displays the same in<strong>for</strong>mation as -l, except <strong>for</strong> group (ACR) ID.<br />

displays directories recursively (subdirectories <strong>and</strong> their contents).<br />

sorts entries by time of last modification instead of by name.<br />

7859 6137–009 4–19


ls (dir)<br />

-u<br />

-v<br />

-x<br />

-1<br />

-2<br />

uses time of last access instead of last modification <strong>for</strong> displaying (-l) or sorting (-t).<br />

displays entries in reverse order.<br />

displays entries sorted in rows rather than columns.<br />

displays entries <strong>for</strong> each line, instead of in columns.<br />

displays the underlying <strong>OS</strong> <strong>2200</strong> directory, file name, <strong>and</strong> f-cycle.<br />

filename<br />

specifies the name of a file or group of files <strong>for</strong> which in<strong>for</strong>mation is requested.<br />

/a[[:]attributes]<br />

displays only the names of those files with the attributes you specify. The colon (":")<br />

is optional. Use any combination of these values, <strong>and</strong> do not separate the values<br />

with spaces:<br />

/o[[:]sortorder]<br />

d directories<br />

r read-only files<br />

-d nondirectory files only<br />

-r files that are not read-only<br />

controls the order in which dir sorts <strong>and</strong> displays file names. The colon (“:”) is<br />

optional. Use any combination of these values, <strong>and</strong> do not separate these values<br />

with spaces:<br />

n in alphabetic order by name<br />

e in alphabetic order by extension<br />

d by date <strong>and</strong> time, earliest first<br />

s by size, smallest first<br />

g with directories grouped be<strong>for</strong>e nondirectory files<br />

-n in reverse alphabetic order by name (Z through A)<br />

-e in reverse alphabetic order by extension (Z through A)<br />

-d by date <strong>and</strong> time, latest first<br />

-s by size, largest first<br />

-g with directories grouped after nondirectory files<br />

4–20 7859 6137–009


t[[:]timefield]<br />

ls (dir)<br />

controls which time field is displayed or used <strong>for</strong> sorting. The following list describes<br />

each of the values you can use <strong>for</strong> timefield:<br />

c creation<br />

a last access<br />

w last written<br />

/s lists every occurrence, in the specified directory <strong>and</strong> all subdirectories, of the<br />

specified file name.<br />

/2 displays <strong>2200</strong> file name <strong>for</strong>mat.<br />

7859 6137–009 4–21


mkdir (md)<br />

mkdir (md)<br />

Application<br />

Use the mkdir (md) comm<strong>and</strong> to create one or more directories <strong>and</strong>, optionally, to create<br />

components of the path name that do not exist.<br />

P<strong>OS</strong>IX Syntax<br />

mkdir [-enp] [-m mode] dirname...<br />

Windows Syntax<br />

mkdir dirname<br />

md dirname<br />

Arguments<br />

-p<br />

creates any component of the path name that does not exist.<br />

-m mode<br />

specifies the access permission <strong>for</strong> the created directory. Mode settings are the<br />

same as <strong>for</strong> chmod.<br />

dirname<br />

-e<br />

-n<br />

specifies the directory name <strong>and</strong> can include slash (/), dot (.), <strong>and</strong> dot-dot (..) in all<br />

valid path names.<br />

creates a Large Element Program File (LEPF). If the file already exists, it converts a<br />

normal program file to an LEPF.<br />

creates a normal Program File (PF). If the file already exists, it converts an LEPF to<br />

a PF if no elements are found greater than 262,143 sectors long.<br />

4–22 7859 6137–009


mkfifo<br />

Application<br />

mkfifo<br />

Use the mkfifo comm<strong>and</strong> to create one or more new First-In-First-Out (FIFO) files, <strong>and</strong><br />

optionally, to create components of the path name that do not exist. The new FIFO is<br />

empty.<br />

P<strong>OS</strong>IX Syntax<br />

mkfifo [-p] [-m mode] fifoname ...<br />

Arguments<br />

-p<br />

creates any component of the path name that does not exist.<br />

-m mode<br />

specifies the access permission <strong>for</strong> the created FIFO file. Mode settings are the<br />

same as <strong>for</strong> chmod. The default mode bits are 0644.<br />

fifoname<br />

specifies the FIFO file name <strong>and</strong> can include slash (/), dot (.), <strong>and</strong> dot-dot (..) in valid<br />

path names<br />

7859 6137–009 4–23


mv (move)<br />

mv (move)<br />

Application<br />

Use the mv (move) comm<strong>and</strong> to move or rename a file. You can also use the mv (move)<br />

comm<strong>and</strong> to move a directory along with any subordinate files <strong>and</strong> directories.<br />

P<strong>OS</strong>IX Syntax<br />

mv [-fi] source [source ...] target<br />

Windows Syntax<br />

move source target<br />

Arguments<br />

-f<br />

-i<br />

source<br />

target<br />

moves the specified file without prompting <strong>for</strong> confirmation even in circumstances<br />

that would otherwise cause a confirmation prompt.<br />

prompts <strong>for</strong> confirmation whenever the move would overwrite an existing file.<br />

specifies the name of the file (may be a directory) to be moved. If target is a<br />

directory, you can specify more than one file; otherwise, only one file is permitted.<br />

specifies the destination file name (may be a directory); target must be different than<br />

source.<br />

4–24 7859 6137–009


pwd (cd)<br />

Application<br />

pwd (cd)<br />

Use the pwd (cd) comm<strong>and</strong> to write the absolute path name of the working directory to<br />

the st<strong>and</strong>ard output.<br />

P<strong>OS</strong>IX Syntax<br />

pwd<br />

Windows Syntax<br />

cd<br />

Arguments<br />

None<br />

7859 6137–009 4–25


m (del)<br />

rm (del)<br />

Application<br />

Use the rm (del) comm<strong>and</strong> to remove one or more entries from a directory.<br />

P<strong>OS</strong>IX Syntax<br />

rm [-cfir] filename [filename ...]<br />

Windows Syntax<br />

del filename [filename ...] [/c] [/f] [/p] [/q] [/s]<br />

Arguments<br />

-c<br />

-f<br />

-i<br />

-r<br />

removes all cycles of a directory entry rather than the current one.<br />

removes files without asking you whether to remove the file, even when the file is<br />

write-protected.<br />

removes files but asks you first whether to remove each file.<br />

recursively removes all files, including subdirectories, without asking you whether to<br />

remove them.<br />

filename<br />

/c<br />

/f<br />

/p<br />

/q<br />

specifies one or more file names to remove.<br />

removes all cycles of a directory entry rather than the current one.<br />

<strong>for</strong>ces deletion of read-only files.<br />

prompts you <strong>for</strong> confirmation be<strong>for</strong>e deleting the specified files.<br />

inhibits prompt if mask of “*” is requested.<br />

4–26 7859 6137–009


s<br />

deletes specified files from the current directory <strong>and</strong> all subdirectories.<br />

Recursive Removal of Files<br />

rm (del)<br />

The following figure shows regular files <strong>and</strong> directories removed recursively using rm -r<br />

or del /s:<br />

SALADS<br />

3<br />

COLD<br />

6<br />

2<br />

11<br />

7<br />

SANDWICHES<br />

BAKE<br />

4<br />

LETTUCE<br />

5<br />

SPINACH<br />

8<br />

CHEESE<br />

9<br />

PEANUT_<br />

BUTTER<br />

Explanation:<br />

7859 6137–009 4–27<br />

10<br />

1<br />

12<br />

RECIPE<br />

SHOPPING_<br />

LIST<br />

1. Remove contents of RECIPE?<br />

2. Remove contents of COLD?<br />

3. Remove contents of SALADS?<br />

4. Remove file of LETTUCE?<br />

5. Remove file of SPINACH?<br />

6. Remove directory SALADS?<br />

7. Remove contents of SANDWICHES?<br />

8. Remove file CHEESE?<br />

9. Remove file PEANUT_BUTTER?<br />

10. Remove directory SANDWICHES?<br />

11. Remove directory COLD?<br />

12. Remove file SHOPPING_LIST?<br />

13. Continue in the same manner through the HOT directory<br />

13<br />

HOT<br />

FRY<br />

MACARONI_<br />

AND_CHEESE<br />

EGG PANCAKE


mdir (rd)<br />

rmdir (rd)<br />

Application<br />

Use the rmdir (rd) comm<strong>and</strong> to remove empty directories.<br />

P<strong>OS</strong>IX Syntax<br />

rmdir [-p] dirname ...<br />

Windows Syntax<br />

rmdir dirname<br />

rd dirname<br />

Arguments<br />

-p<br />

removes all empty directories in path name dirname.<br />

dirname<br />

specifies the path name of a directory to remove.<br />

4–28 7859 6137–009


set<br />

Application<br />

Use the set comm<strong>and</strong> to display, initialize, or update environment variables <strong>for</strong> the<br />

current run (see Environment Variables, Section 3). Using the set comm<strong>and</strong> to establish<br />

a <strong>CIFS</strong>$KEYS value also sets the source <strong>and</strong> target values <strong>for</strong> the keys comm<strong>and</strong>.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

set [variable[=[string]]]<br />

Arguments<br />

Blank/None<br />

displays the current environment settings.<br />

variable[=]<br />

string<br />

if followed by an equal sign (=), it specifies the variable you want to set or modify. If<br />

not followed by an equal sign, displays the current value of the variable.<br />

specifies the string you want associated with the specified variable. If you omit the<br />

string, variable is cleared. All characters are valid <strong>for</strong> the string, so values containing<br />

embedded spaces must not be enclosed in quotation marks unless the quotation<br />

marks are part of the value.<br />

7859 6137–009 4–29<br />

set


setsys<br />

setsys<br />

Application<br />

Use the setsys comm<strong>and</strong> to display, initialize, or update environment variables in the<br />

active system profile (see “Environment Variables,” Section 3).<br />

Notes:<br />

• Only callers with write access to the passive system profile file can update the active<br />

system profile. In addition, the caller must be system-low (clearance level 0) <strong>for</strong><br />

secure systems beyond Fundamental Security (Security Options 1, 2, <strong>and</strong> 3).<br />

The active system profile settings exist only <strong>for</strong> the life of the system <strong>and</strong> are<br />

discarded at system termination. Use the security management product to designate<br />

the passive system profile location to be used <strong>for</strong> future sessions.<br />

• Also see “security management product” in the glossary.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

setsys [variable[=[string]]]<br />

Arguments<br />

Blank/None<br />

displays the current system environment settings.<br />

variable[=]<br />

string<br />

if followed by an equal sign (=), it specifies the variable you want to set or modify. If<br />

not followed by an equal sign, displays the current value of the variable.<br />

specifies the string you want associated with the specified variable. If you omit the<br />

string, variable is cleared. All characters are valid <strong>for</strong> the string, so values containing<br />

embedded spaces must not be enclosed in quotation marks unless the quotation<br />

marks are part of the value.<br />

4–30 7859 6137–009


share<br />

Application<br />

Use the share comm<strong>and</strong> to create a network-visible name <strong>for</strong> the specified directory.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

share dirname [netname]<br />

Arguments<br />

dirname<br />

specifies the location <strong>and</strong> name of the directory to be made network visible.<br />

netname<br />

specifies the name of the directory as seen from network connections. If not<br />

specified, the comm<strong>and</strong> displays the current share name <strong>for</strong> the directory. The<br />

netname cannot be more than 31 characters long.<br />

share<br />

Note: Many network clients cannot access names that have more than 12 characters.<br />

7859 6137–009 4–31


size<br />

size<br />

Application<br />

Use the size comm<strong>and</strong> to change the logical length of a regular file.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

size filename nnnn<br />

Arguments<br />

filename<br />

nnnn<br />

specifies the location <strong>and</strong> name of the file to be resized.<br />

specifies the new size of the file. It may be larger or smaller than the existing size.<br />

For files stored in SDF <strong>for</strong>mat, the nnnn value of 34359738367 has special meaning.<br />

<strong>CIFS</strong> treats this as an indication that it must recalculate the actual size of the file on<br />

the next read of the file that encounters the EOF record.<br />

4–32 7859 6137–009


touch<br />

Application<br />

touch<br />

Use the touch comm<strong>and</strong> to change the access or modification time or date of files, or to<br />

pack the underlying <strong>OS</strong> <strong>2200</strong> program files of the specified <strong>CIFS</strong> directories. The <strong>CIFS</strong><br />

pack operation (touch -p ...) is directly analogous to a FURPUR @PACK. Any existing<br />

relocatable <strong>and</strong> PROC entry point tables in the program file are preserved.<br />

Note: The <strong>CIFS</strong> pack is a safe pack, in that if the system goes down or an X-keyin to the<br />

run is done during the pack, the contents of the program files are preserved, except in<br />

rare circumstances.<br />

P<strong>OS</strong>IX Syntax<br />

touch [-afmpr] [-d ref_file | -t date] [filename | dirname ...]<br />

Arguments<br />

-a<br />

-f<br />

-m<br />

-p<br />

-r<br />

update only the access time.<br />

a file is created if it does not exist.<br />

update only the modification time. If neither -a nor -m nor -p is specified, the effect is<br />

the same as -am.<br />

pack the underlying <strong>OS</strong> <strong>2200</strong> program files of the <strong>CIFS</strong> directories. A pack of a<br />

program file is needed when there are many deleted element entries <strong>and</strong> either the<br />

text area reaches or is closed to the maximum size of the file, or the TOC area<br />

fills-up.<br />

Note: <strong>CIFS</strong> requires exclusive use of a program file while it is being packed. It must<br />

not be assigned to any run or name section, including the run doing the touch<br />

comm<strong>and</strong>. Using the -r option with the -p option gives the ability to pack the<br />

underlying program files of a whole tree of directories with one comm<strong>and</strong>.<br />

recur through any directories encountered.<br />

-d ref_file<br />

use the corresponding time of ref_file instead of the current time.<br />

7859 6137–009 4–33


touch<br />

-t date<br />

CC<br />

YY<br />

MM<br />

DD<br />

hh<br />

mm<br />

ss<br />

where date is of the <strong>for</strong>mat<br />

[[CC]YY]MMDDhhmm[:ss]<br />

where each pair of digits represents the following:<br />

(optional) specifies the first two digits of the year (the century).<br />

If neither CC nor YY is specified, the current year is assumed.<br />

If YY is specified but CC is not specified, CC is derived as follows:<br />

If YY is CC becomes<br />

69–99 19<br />

00–68 20<br />

(optional) specifies the last two digits of the year.<br />

If neither CC nor YY is specified, the current year is assumed.<br />

specifies the month of the year (01 through 12).<br />

specifies the day of the month (01 through 31).<br />

specifies the hour of the day (00 through 23).<br />

specifies the minute of the hour (00 through 59).<br />

(optional) specifies the second of the minute (00 through 61).<br />

Note: The -r <strong>and</strong> -t options are mutually exclusive.<br />

filename<br />

specifies one or more files, including directories, to modify. Masking may be used.<br />

4–34 7859 6137–009


unshare<br />

Application<br />

unshare<br />

Use the unshare comm<strong>and</strong> to remove a network-visible name <strong>for</strong> the specified directory.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

unshare dirname<br />

Arguments<br />

dirname<br />

specifies the location <strong>and</strong> name of the directory to be removed from network<br />

visibility.<br />

7859 6137–009 4–35


use<br />

use<br />

Application<br />

Use the use comm<strong>and</strong> to temporarily associate an <strong>OS</strong> <strong>2200</strong> internal file name with the<br />

<strong>OS</strong> <strong>2200</strong> file associated with a <strong>CIFS</strong> file, typically a <strong>CIFS</strong> directory. This allows <strong>2200</strong><br />

programs that are not <strong>CIFS</strong>-aware to access files in the <strong>CIFS</strong> hierarchy. The association<br />

lasts until the run terminates or is removed with the <strong>OS</strong> <strong>2200</strong> ECL comm<strong>and</strong> @FREE.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

use int_name cifs_path<br />

Arguments<br />

int_name<br />

specifies the <strong>OS</strong> <strong>2200</strong> internal name to associate with the <strong>CIFS</strong> file. The name must<br />

con<strong>for</strong>m to <strong>OS</strong> <strong>2200</strong> ECL syntax rules (maximum of 12 characters from the set of<br />

alphanumerics, dollar sign, <strong>and</strong> dash).<br />

cifs_path<br />

specifies the path name of the <strong>CIFS</strong> file to expose to non-<strong>CIFS</strong>-aware programs.<br />

This must not be a <strong>CIFS</strong> file that is stored as an <strong>OS</strong> <strong>2200</strong> element, so cifs_path<br />

usually refers to a directory.<br />

4–36 7859 6137–009


version<br />

Application<br />

Use the version comm<strong>and</strong> to display the <strong>CIFS</strong> subsystem name, build date, build<br />

number, <strong>and</strong> gate bank BDI.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

version<br />

Arguments<br />

None<br />

version<br />

7859 6137–009 4–37


xlate<br />

xlate<br />

Application<br />

Use the xlate comm<strong>and</strong> to set or display the translation attributes <strong>for</strong> a directory.<br />

P<strong>OS</strong>IX <strong>and</strong> Windows Syntax<br />

Xlate dirname [in=[ccsname]] [out=[ccsname]]<br />

Arguments<br />

dirname<br />

specifies the directory to manipulate.<br />

ccsname<br />

specifies the coded character set name <strong>for</strong> the desired translation. SDF files written<br />

into the directory use the in= setting to convert the data from the specified ccsname<br />

<strong>for</strong>mat into Unicode. Likewise, files read out of a translation–enabled directory use<br />

the out= setting to convert Unicode to the specified ccsname <strong>for</strong>mat. A blank<br />

ccsname turns off translation <strong>for</strong> that direction. Case is ignored <strong>for</strong> ccsname.<br />

If neither argument is specified, <strong>CIFS</strong>UT displays the current translate settings <strong>for</strong><br />

the directory. If only one argument is specified, only that one is changed <strong>for</strong> the<br />

directory.<br />

Valid values <strong>for</strong> ccsname are UNICODE, Shift-JIS, LETS-J, JIS-X0201, JIS–X0208,<br />

JIS-X0212, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5, ISO8859-6,<br />

ISO8859-7, ISO8859-8, ISO8859-9, ISO8859-10, ISO8859-13, ISO8859-14, <strong>and</strong><br />

ISO8859-15. Character mappings are available from the Unicode Web site,<br />

http://www.unicode.org.<br />

4–38 7859 6137–009


Section 5<br />

C Program Interfaces<br />

The following table lists the C application program interfaces (APIs) supplied by the<br />

<strong>CIFS</strong>LIB component. Each API has a P<strong>OS</strong>IX-like name <strong>and</strong> a <strong>CIFS</strong> name (unless no<br />

equivalent P<strong>OS</strong>IX-like name exists). The P<strong>OS</strong>IX-like names are provided first because<br />

their syntax allows them to be more easily alphabetized. The <strong>CIFS</strong> name is the same<br />

except <strong>for</strong> the “_cifs_” prefix.<br />

A description of each API follows the table, again alphabetized by the P<strong>OS</strong>IX-like name<br />

<strong>for</strong> convenience.<br />

Note: The error codes that are described with each API are the most common error<br />

codes <strong>for</strong> that function. Appendix B includes a complete list of error codes.<br />

<strong>User</strong> programs written in UC can use the <strong>CIFS</strong> API name directly by including the<br />

following function definition statement:<br />

#include <br />

With cifsio.h, programs can also access files using the st<strong>and</strong>ard UC libraries. When they<br />

do so, the #include of stdio.h must appear be<strong>for</strong>e the cifsio.h include.<br />

UC programs can access the <strong>CIFS</strong> interfaces through the P<strong>OS</strong>IX names with this<br />

statement:<br />

#include <br />

This technique precludes simultaneous use of the UC I/O library, but allows programs to<br />

be much more portable.<br />

Notes:<br />

• All interfaces <strong>and</strong> structures are defined by the above #include header files.<br />

• In addition to stdio.h, other files can be affected by the order in which cifsio.h or<br />

cifspsxio.h is included. To avoid unexpected redefinitions, place the #include<br />

statement <strong>for</strong> cifsio.h or cifspsxio.h after any #include statements <strong>for</strong> st<strong>and</strong>ard library<br />

header files.<br />

• Masking of characters applies only to @<strong>CIFS</strong>UT <strong>and</strong> the program interface<br />

_cifs_mask(). Masking cannot be used in other program interfaces.<br />

7859 6137–009 5–1


Table of C APIs<br />

Table of C APIs<br />

P<strong>OS</strong>IX API<br />

Name<br />

<strong>CIFS</strong> API Name<br />

Description<br />

access _cifs_access Determines existence <strong>and</strong> accessibility<br />

chdir _cifs_chdir Changes current working directory<br />

chmod _cifs_chmod Changes access permissions <strong>for</strong> a file<br />

chown _cifs_chown Changes the owner <strong>and</strong>, optionally, the group of<br />

a file<br />

clearerr _cifs_clearerr Clears end-of-file <strong>and</strong> error indications<br />

close _cifs_close Terminates access to an open file<br />

closedir _cifs_closedir Terminates access to an open directory<br />

creat _cifs_creat Creates <strong>and</strong> opens a new file<br />

dup _cifs_dup Creates an additional file descriptor <strong>for</strong> an open<br />

file<br />

dup2 _cifs_dup2 Associates a specific file descriptor with an open<br />

file<br />

(none) _cifs_end_process Terminates a <strong>CIFS</strong> process<br />

fclose _cifs_fclose Terminates access to an open stream<br />

fcntl _cifs_fcntl Manipulates file attributes <strong>and</strong> status<br />

fdatasync _cifs_fdatasync Forces writing of all buffered data <strong>for</strong> an open<br />

file<br />

fdopen _cifs_fdopen Associates a stream with an open file<br />

feof _cifs_feof Checks end-of-file condition <strong>for</strong> a stream<br />

ferror _cifs_ferror Checks read/write errors <strong>for</strong> a stream<br />

fflush _cifs_fflush Forces writing of stream buffers<br />

fgetc _cifs_fgetc Gets next character from a stream<br />

fgetpos _cifs_fgetpos Gets current position of a stream<br />

fgets _cifs_fgets Gets multiple characters from stream<br />

fileno _cifs_fileno Retrieves file association of a stream<br />

fopen _cifs_fopen Opens a stream<br />

fprintf _cifs_fprintf Writes <strong>for</strong>matted output to a stream<br />

fputc _cifs_fputc Writes a character to a stream<br />

fputs _cifs_fputs Writes multiple characters to a stream<br />

fread _cifs_fread Reads multiple byte strings from a stream<br />

freopen _cifs_freopen Changes the file association of a stream<br />

5–2 7859 6137–009


P<strong>OS</strong>IX API<br />

Name<br />

<strong>CIFS</strong> API Name<br />

Description<br />

fscanf _cifs_fscanf Reads <strong>for</strong>matted input from a stream<br />

fseek _cifs_fseek Sets the current position of a stream<br />

fsetpos _cifs_fsetpos Sets the current position of a stream<br />

fstat _cifs_fstat Retrieves in<strong>for</strong>mation about an open file<br />

Table of C APIs<br />

*fsync _cifs_fsync Forces writing of all buffered data <strong>for</strong> an open<br />

file<br />

ftell _cifs_ftell Retrieves current position of a stream<br />

*ftruncate _cifs_ftruncate Sets the length of a stream<br />

fwrite _cifs_fwrite Writes multiple byte strings to a stream<br />

getc _cifs_getc Gets next character from a stream<br />

getchar _cifs_getchar Gets next character from the st<strong>and</strong>ard input<br />

stream<br />

getcwd _cifs_getcwd Retrieves the current working directory<br />

getpwnam _cifs_getpwnam Determines the current state of a user in the<br />

database using the user's name<br />

getpwuid _cifs_getpwuid Determines the current state of a user in the<br />

database using the user's numeric identifier<br />

gets _cifs_gets Gets multiple characters from the st<strong>and</strong>ard input<br />

stream<br />

getuid _cifs_getuid Returns the numeric user ID value of the calling<br />

process<br />

istat _cifs_istat Retrieves in<strong>for</strong>mation about an inode<br />

link _cifs_link Associates a path name with an existing file<br />

lseek _cifs_lseek Sets current position of an open file<br />

(none) _cifs_mask Checks a string <strong>for</strong> matching a wild card<br />

specification<br />

mkdir _cifs_mkdir Creates a new directory<br />

mkfifo _cifs_mkfifo Creates a new first-in, first-out (FIFO) file<br />

(none) _cifs_new_process Initiates a new process environment within <strong>CIFS</strong><br />

open _cifs_open Opens a named file<br />

opendir _cifs_opendir Opens a directory<br />

**pack _cifs_pack Packs the underlying program file of a <strong>CIFS</strong> file<br />

or directory<br />

perror _cifs_perror Writes an error message to the st<strong>and</strong>ard error<br />

stream<br />

pipe _cifs_pipe Creates a pipe<br />

7859 6137–009 5–3


Table of C APIs<br />

P<strong>OS</strong>IX API<br />

Name<br />

<strong>CIFS</strong> API Name<br />

Description<br />

printf _cifs_printf Writes <strong>for</strong>matted data to the st<strong>and</strong>ard output<br />

stream<br />

putc _cifs_putc Writes a single character to a stream<br />

putchar _cifs_putchar Writes a character to the st<strong>and</strong>ard output stream<br />

puts _cifs_puts Writes multiple characters to the st<strong>and</strong>ard<br />

output stream<br />

read _cifs_read Reads data from an open file<br />

readdir _cifs_readdir Reads an entry from a directory<br />

*realpath _cifs_realpath Returns the fully resolved path <strong>for</strong> a specified<br />

file<br />

remove _cifs_remove Deletes an existing file<br />

rename _cifs_rename Renames an existing file<br />

rewind _cifs_rewind Sets the current position of a stream to zero<br />

rewinddir _cifs_rewinddir Repositions an open directory to the first entry<br />

rmdir _cifs_rmdir Deletes an empty directory<br />

scanf _cifs_scanf Reads <strong>for</strong>matted data from the st<strong>and</strong>ard input<br />

stream<br />

(none) _cifs_share Specifies the network-visible name <strong>for</strong> a<br />

directory<br />

sprintf _cifs_sprintf Writes <strong>for</strong>matted data to a string<br />

sscanf _cifs_sscanf Reads <strong>for</strong>matted data from a string<br />

stat _cifs_stat Retrieves in<strong>for</strong>mation about an existing named<br />

file<br />

strerror _cifs_strerror Returns the ELMS error message text <strong>for</strong> the<br />

specified error code<br />

tmpfile _cifs_tmpfile Creates a temporary stream<br />

tmpnam _cifs_tmpnam Retrieves a unique file name string<br />

*truncate _cifs_truncate Sets the length of a regular file<br />

umask _cifs_umask Sets the file mode creation mask inhibit bits<br />

ungetc _cifs_ungetc Returns a character to an input stream<br />

unlink _cifs_unlink Disassociates a path name from a file<br />

5–4 7859 6137–009


P<strong>OS</strong>IX API<br />

Name<br />

<strong>CIFS</strong> API Name<br />

Description<br />

Table of C APIs<br />

(none) _cifs_uname Returns <strong>CIFS</strong> subsystem version in<strong>for</strong>mation<br />

utime _cifs_utime Changes access <strong>and</strong> modification times<br />

vfprintf _cifs_vfprintf Writes <strong>for</strong>matted data to a stream<br />

vprintf _cifs_vprintf Writes <strong>for</strong>matted data to the st<strong>and</strong>ard output<br />

stream<br />

vsprintf _cifs_vsprintf Writes <strong>for</strong>matted data to a string<br />

write _cifs_write Writes data to an open file<br />

(none) _cifs_xlate Sets or retrieves translation modes <strong>for</strong> a<br />

directory<br />

Notes:<br />

• Interfaces flagged with an asterisk (*) are not part of the P<strong>OS</strong>IX st<strong>and</strong>ard, but are<br />

commonly available on most UNIX plat<strong>for</strong>ms.<br />

• Interfaces flagged with a double asterisk (**) are not part of the P<strong>OS</strong>IX st<strong>and</strong>ard but<br />

are part of <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong>.<br />

7859 6137–009 5–5


access()<br />

access()<br />

Application<br />

Use the access() function to determine if either of the following is true:<br />

• A file exists.<br />

• The calling process has permission to access a file.<br />

Synopsis<br />

int access(const char * path, int amode);<br />

Description<br />

The access() function checks file permissions or existence, where:<br />

path<br />

amode<br />

is a pointer to the path name of the file.<br />

determines what to check, which is either of the following:<br />

• File permissions<br />

The value is the bitwise inclusive OR of any of the following constants:<br />

− R_OK (Check <strong>for</strong> read permission)<br />

− W_OK (Check <strong>for</strong> write permission)<br />

− X_OK (Check <strong>for</strong> search/execute permission)<br />

• File existence<br />

The value is F_OK; that is, check whether the file or directory exists.<br />

Checking File Permissions<br />

The access() function checks each permission requested in amode. access() uses the<br />

real user ID <strong>and</strong> real group ID of the calling process to decide which file permission class<br />

(owner, group, or other) to check. In addition, to the permission bits maintained by <strong>CIFS</strong>,<br />

the access() function also verifies that the requested permission is allowed by <strong>OS</strong> <strong>2200</strong><br />

security.<br />

Return Values<br />

If all the specified access permissions are allowed or if the file exists (whichever was<br />

requested), the access() function returns 0. Otherwise, access() sets errno to identify the<br />

specific error <strong>and</strong> returns -1.<br />

5–6 7859 6137–009


Error Codes<br />

access()<br />

If any of the following conditions occurs, the access() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EACCES Either of the following errors occurred:<br />

• One or more permissions specified by amode are denied.<br />

• The calling process is denied search permission on a directory in<br />

the path name.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL An invalid value was specified <strong>for</strong> amode.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string<br />

ENOTDIR A component of the path prefix is not a directory.<br />

7859 6137–009 5–7


chdir()<br />

chdir()<br />

Application<br />

Use the chdir() function to change to a different current working directory.<br />

Synopsis<br />

int chdir(const char * path);<br />

Description<br />

The chdir() function changes the current working directory of the calling process, where<br />

path identifies the new directory.<br />

Return Values<br />

If the chdir() function completes successfully, it returns 0. Otherwise, chdir() sets errno<br />

to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the chdir() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES The calling process is denied search permission to a directory in the<br />

path name.<br />

EFAULT The pointer specified by path is invalid.<br />

ENOENT Either of the following errors occurred:<br />

• The directory does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name is not a directory.<br />

5–8 7859 6137–009


chmod()<br />

Application<br />

Use the chmod() function to change the file permissions of the mode <strong>for</strong> a file.<br />

Privilege Requirement<br />

chmod()<br />

For a process to change the file permissions or type of a program file, the user ID of the<br />

process must be equal to the user ID of the file.<br />

Synopsis<br />

int chmod(const char * path, mode_t mode);<br />

Description<br />

The chmod() function changes the file permission bits <strong>and</strong> program file type, where:<br />

path<br />

mode<br />

is a pointer to the path name of the file.<br />

contains the new settings <strong>for</strong> the file permissions.<br />

Open Files <strong>and</strong> Directory Streams<br />

Any process with an open directory stream or a file descriptor to an open file can<br />

continue accessing the stream or file, even if the chmod() function changes the<br />

permission bits.<br />

Changing File Permissions <strong>and</strong> Special File Attributes<br />

If the process is allowed to change the file permissions of a file (see “Privilege<br />

Requirement” in this subsection), chmod() sets the file permissions in the file mode to<br />

the values specified in mode. If the target of chmod() refers to a file in the <strong>OS</strong> <strong>2200</strong><br />

Master File Directory, the read-only <strong>and</strong> write-only attributes of that file are also changed<br />

to correspond to the <strong>CIFS</strong> file permissions.<br />

Return Values<br />

If the chmod() function completes successfully, it updates the st_atime field of the file or<br />

directory <strong>and</strong> returns 0. Otherwise, chmod() sets errno to identify the specific error <strong>and</strong><br />

returns -1.<br />

7859 6137–009 5–9


chmod()<br />

Error Codes<br />

If any of the following conditions occurs, the chmod() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EACCES The calling process is denied search permission to a directory in<br />

the path name.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL Any of the following errors occurred:<br />

• mode has undefined bits set.<br />

• mode has bits set that chmod() cannot change.<br />

• A path name component is longer than 4095 characters.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name is not a directory.<br />

EPERM Both of the following conditions are true:<br />

• The effective user ID does not match the owner of the file or<br />

directory.<br />

• The process is privileged.<br />

5–10 7859 6137–009


chown()<br />

Application<br />

chown()<br />

Use the chown() function to change the security attributes (user ID <strong>and</strong> group ID) of a<br />

file, assigning the file to a different owner <strong>and</strong> group. If the value of the <strong>CIFS</strong>$ACR<br />

environment variable is not blank, that value (public, private, or ACR name) is also applied<br />

to the specified file.<br />

For a process to change the security attributes of a file, one of the following must be<br />

true:<br />

• The user ID of the process is equal to the user ID of the file.<br />

• The process is privileged.<br />

Synopsis<br />

int chown(const char * path, uid_t owner, gid_t group);<br />

Description<br />

The chown() function changes the user ID <strong>and</strong> group ID of a file, where:<br />

path<br />

owner<br />

group<br />

identifies the file.<br />

contains the new user ID <strong>for</strong> the file. If owner = -1, the user ID is unchanged.<br />

contains the new group ID <strong>for</strong> the file. If group = -1, the group ID is unchanged. If<br />

both owner = -1 <strong>and</strong> group = -1, both the user ID <strong>and</strong> group ID are unchanged;<br />

there<strong>for</strong>e, chown() changes neither the st_atime field nor the file mode.<br />

Return Values<br />

If the chown() function completes successfully, it does the following:<br />

• Updates the st_atime field of the file<br />

• Returns 0<br />

Otherwise, chown() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

7859 6137–009 5–11


chown()<br />

Error Codes<br />

If any of the following conditions occurs, the chown() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EACCES The calling process is denied search permission to a<br />

directory in the path name.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL owner or group is a value that can never possibly be a<br />

valid user ID or group ID.<br />

ENAMETOOLONG A path name component is longer than 4095 characters.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name is not a directory.<br />

EPERM Both of the following conditions exist:<br />

• The effective user ID does not match the owner of<br />

the file or directory.<br />

• The process is not privileged.<br />

5–12 7859 6137–009


clearerr()<br />

Application<br />

clearerr()<br />

Use the clearerr() function to clear the end-of-file <strong>and</strong> error indicators <strong>for</strong> the stream.<br />

Synopsis<br />

void clearerr(FILE * stream);<br />

Description<br />

The clearerr() function clears the end-of-file <strong>and</strong> error indicators <strong>for</strong> a stream, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

The end-of-file <strong>and</strong> error indicators are cleared only at the following times:<br />

• When the file is opened<br />

• By an explicit call to one of the following functions:<br />

− clearerr()<br />

− fseek()<br />

− rewind()<br />

Return Values<br />

The clearerr() function returns no value.<br />

7859 6137–009 5–13


close()<br />

close()<br />

Application<br />

Use the close() function to release certain file attributes <strong>and</strong> prevent further access to a<br />

file through a specific file descriptor. Closing a file does the following:<br />

• Deallocates the specified file descriptor <strong>and</strong> makes it available <strong>for</strong> reuse by<br />

subsequent calls to other functions, such as open() <strong>and</strong> dup(). Reusing file<br />

descriptors is important <strong>for</strong> redirecting the st<strong>and</strong>ard files (st<strong>and</strong>ard input, st<strong>and</strong>ard<br />

output, <strong>and</strong> st<strong>and</strong>ard error) to a pipe, <strong>for</strong> example.<br />

• Removes all record locks the calling process holds on the file. You might want to<br />

close a file to clear all locks you set on it, then open the file again to access a<br />

different segment. This reduces lock conflicts <strong>for</strong> cooperating processes trying to<br />

access the same file.<br />

Synopsis<br />

int close(int fildes);<br />

Description<br />

The close() function removes access to an open file description through a certain file<br />

descriptor, where fildes identifies the file descriptor. That is, the calling process can no<br />

longer use that file descriptor <strong>for</strong> input <strong>and</strong> output operations to the original file.<br />

Additional Processing <strong>for</strong> the Last File Descriptor<br />

When fildes identifies the last file descriptor <strong>for</strong> the following file types, close() does the<br />

additional processing specified:<br />

• Pipe or FIFO file<br />

close() discards any data remaining in the pipe or FIFO file.<br />

• Open file description<br />

close() discards the open file description.<br />

• File whose link count is 0<br />

close() deletes the file <strong>and</strong> frees its space.<br />

Return Values<br />

If the close() function completes successfully, it returns 0. Otherwise, close() sets errno<br />

to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If the following condition occurs, the close() function returns -1 <strong>and</strong> sets errno to this<br />

value:<br />

EBADF fildes is not a valid file descriptor.<br />

EIO I/O error occurred while writing the file.<br />

5–14 7859 6137–009


closedir()<br />

Application<br />

closedir()<br />

Use the closedir() function to close an open directory stream <strong>and</strong> make it inaccessible to<br />

the calling process. If no other processes share this directory stream, access to the<br />

stream is closed.<br />

If a process terminates, all effects of closedir() occur <strong>for</strong> each directory stream open to<br />

the process.<br />

See opendir() <strong>for</strong> opening directory, readdir() <strong>for</strong> reading the next directory entry, <strong>and</strong><br />

rewinddir() <strong>for</strong> repositioning the stream at its beginning.<br />

Synopsis<br />

int closedir(DIR * dirp);<br />

Description<br />

The closedir() function closes access to the directory stream by the calling process,<br />

where dirp designates the directory stream to close. The directory stream must have<br />

been opened previously by the opendir() function.<br />

Return Values<br />

If the closedir() function completes successfully, it does the following:<br />

• Updates the st_atime field of the directory<br />

• Returns 0<br />

Otherwise, closedir() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the closedir() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EBADF dirp is not a valid directory stream<br />

EFAULT dirp is not a valid pointer.<br />

7859 6137–009 5–15


creat()<br />

creat()<br />

Application<br />

Use the creat() function to create <strong>and</strong> open a new regular file, specifying how you can<br />

access it <strong>and</strong> setting its file permissions.<br />

Synopsis<br />

int creat(const char * path, mode_t mode);<br />

Description<br />

The creat() function call is the same as a special case of open(), as follows:<br />

open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)<br />

See the open() function <strong>for</strong> details of the path <strong>and</strong> mode arguments.<br />

Caution<br />

Using creat() when a file of the same name exists truncates the file's length<br />

to 0.<br />

Return Values<br />

If the creat() function completes successfully, it returns the file descriptor <strong>for</strong> the new<br />

file. Otherwise, creat() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the creat() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

E1100FILE The system could not assign the <strong>OS</strong> <strong>2200</strong> file that contains the<br />

file's data space.<br />

EACCES Either of the following errors occurred:<br />

• The calling process is denied search permission on a directory<br />

in the path name.<br />

• The calling process is denied write permission <strong>for</strong> the file or the<br />

parent directory of the file.<br />

EAGAIN An attempt to create <strong>and</strong> open an imported file failed because the<br />

corresponding <strong>OS</strong> <strong>2200</strong> file existed but was rolled out or otherwise<br />

unavailable. This is a temporary condition; a subsequent attempt<br />

might succeed.<br />

EFAULT The pointer specified by path is invalid.<br />

EINTR The create operation was interrupted by a signal.<br />

5–16 7859 6137–009


EINVAL mode has undefined bits set.<br />

EIO An input/output error prevented completion of the request.<br />

EISDIR The path name resolves to a directory.<br />

EMFILE The calling process cannot create the file because the limit on the<br />

maximum number of open file descriptors <strong>for</strong> a process would be<br />

exceeded.<br />

ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not exist.<br />

• path points to an empty string.<br />

EN<strong>OS</strong>PC The directory or file system that is to contain the new file is out of<br />

available space.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

creat()<br />

7859 6137–009 5–17


dup()<br />

dup()<br />

Application<br />

Use the dup() function to create an additional file descriptor <strong>for</strong> an existing open file<br />

description. This capability is important <strong>for</strong> redirecting st<strong>and</strong>ard files to a pipe, <strong>for</strong><br />

example. The new file descriptor has the following properties:<br />

• Its value is the lowest number available <strong>for</strong> the process.<br />

• It shares the same open file description <strong>and</strong> file locks with the original file descriptor.<br />

You can also duplicate a file descriptor with the F_DUPFD option to the fcntl() function.<br />

See dup2() <strong>for</strong> associating a specific file descriptor with an open file description.<br />

Synopsis<br />

int dup(int fildes);<br />

Description<br />

The dup() function duplicates the file descriptor designated by fildes. The duplicated file<br />

descriptor occurs in the first available file descriptor location.<br />

Diagram<br />

The following diagram shows a duplicated file descriptor <strong>for</strong> an open file description:<br />

Process<br />

Return Values<br />

If the dup() function completes successfully, it returns the index of the newly created file<br />

descriptor. Otherwise, dup() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

dup( )<br />

File<br />

Descriptor<br />

fildes<br />

Open File<br />

Description<br />

If any of the following conditions occurs, the dup() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EBADF fildes is not a valid open file descriptor.<br />

EMFILE The calling process would exceed the maximum number of file<br />

descriptors allowed.<br />

5–18 7859 6137–009<br />

File


dup2()<br />

Application<br />

dup2()<br />

Use the dup2() function to associate a specific file descriptor index with an existing open<br />

file description. The new file descriptor shares the same open file description <strong>and</strong> file<br />

locks with the original file descriptor. See dup() <strong>for</strong> creating an additional file descriptor<br />

<strong>for</strong> the open file description.<br />

Synopsis<br />

int dup2(int fildes1, int fildes2);<br />

Description<br />

The dup2() function causes the file descriptor fildes2 to identify the same open file<br />

description as fildes1.<br />

If fildes2 exists <strong>and</strong> corresponds to an open file other than fildes1, dup2() first closes<br />

fildes2 (which can remove locks <strong>and</strong> the file itself; see the close() function). If fildes1 <strong>and</strong><br />

fildes2 are equal, dup2() does not duplicate or close any file descriptors.<br />

Diagram<br />

The following diagram shows a specific file descriptor associated with an open file<br />

description:<br />

Return Values<br />

If the dup2() function completes successfully, it returns the value of fildes2, a file<br />

descriptor. Otherwise, dup2() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

File<br />

Descriptor<br />

fildes1<br />

fildes2<br />

dup2( )<br />

Open File<br />

Description<br />

If the following condition occurs, the dup2() function returns -1 <strong>and</strong> sets errno to the<br />

corresponding value:<br />

EBADF One of the following errors occurred:<br />

• fildes1 is not a file descriptor.<br />

• fildes2 is either negative or greater than the maximum number of<br />

file descriptors allowed.<br />

7859 6137–009 5–19<br />

File


end_process()<br />

end_process()<br />

Application<br />

Use _cifs_end_process (<strong>and</strong> _cifs_new_process) to group activities into logical<br />

processes, where all activities (threads) of a process share a set of open files.<br />

Note: There is no P<strong>OS</strong>IX equivalent to _cifs_end_process.<br />

Synopsis<br />

int _cifs_end_process();<br />

Description<br />

See new_process(), later in this section.<br />

5–20 7859 6137–009


fclose()<br />

Application<br />

fclose()<br />

Use the fclose() function to write all remaining data in the buffer to a file <strong>and</strong> close the<br />

file.<br />

Synopsis<br />

int fclose(FILE * stream);<br />

Description<br />

The fclose() function flushes any output buffer <strong>for</strong> a stream <strong>and</strong> closes the associated<br />

file, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object. If this object was automatically allocated, fclose()<br />

deallocates it.<br />

Return Values<br />

The fclose() function returns 0 if it successfully closes the stream. Otherwise, if it<br />

detects errors or if the stream was already closed, fclose() returns a nonzero value.<br />

7859 6137–009 5–21


fcntl()<br />

fcntl()<br />

Application<br />

Use the fcntl() function to manage an open file in the following ways, which are<br />

described in following subsections:<br />

• Duplicate a file descriptor; see “File Descriptor Services.”<br />

• Retrieve in<strong>for</strong>mation about or change the values of the file status flags <strong>and</strong> access<br />

specification; see “File Status Flags <strong>and</strong> Access Specification Services.”<br />

• Manage advisory record locking services; see “Record Locking Services.”<br />

Synopsis<br />

int fcntl(int fildes, int cmd, ...);<br />

Description<br />

The fcntl() function per<strong>for</strong>ms file services, where:<br />

fildes<br />

cmd<br />

is a file descriptor <strong>for</strong> an open file.<br />

indicates which service to per<strong>for</strong>m. It can have any value in the following table.<br />

Service<br />

Duplicate file<br />

descriptor<br />

Get flags <strong>and</strong><br />

in<strong>for</strong>mation<br />

Set flags <strong>and</strong><br />

in<strong>for</strong>mation<br />

*Wait if blocked<br />

File<br />

Descriptor<br />

File Status <strong>and</strong><br />

Access<br />

Specification<br />

F_DUPFD – –<br />

– F_GETFL<br />

F_GETFD<br />

– F_SETFL<br />

F_SETFD<br />

Advisory Record<br />

Locking<br />

F_GETLK<br />

F_SETLK,<br />

F_SETLKW*<br />

See the following subsections <strong>for</strong> detailed in<strong>for</strong>mation about each type of service.<br />

parm-3<br />

is an optional argument of varying type whose value depends on cmd, as shown in<br />

the following table (see the following descriptions of the symbolic names <strong>for</strong> more<br />

in<strong>for</strong>mation about parm-3):<br />

5–22 7859 6137–009


If cmd is ... Then parm-3 is ...<br />

fcntl()<br />

F_DUPFD An integer giving the smallest desired value <strong>for</strong> the new file descriptor<br />

F_GETFD,<br />

F_GETFL<br />

F_SETFD,<br />

F_SETFL<br />

F_GETLK,<br />

F_SETLK,<br />

F_SETLKW<br />

Incorrect Third Argument<br />

Not required; ignored if supplied<br />

An integer giving the new setting <strong>for</strong> the close_on_exec or status flags<br />

<strong>for</strong> the specified file descriptor<br />

A pointer to the flock structure that describes the locking request (can<br />

be used to unlock or change an existing lock)<br />

The fcntl function fails if parm-3 is required (that is, if cmd is F_DUPFD, F_GETLK,<br />

F_SETFD, F_SETFL, F_SETLK, or F_SETLKW) but does not exist.<br />

Caution<br />

fcntl() cannot determine if the third argument has the wrong type. Even if the<br />

type is incorrect, fcntl() interprets the storage as the correct type, resulting in<br />

undefined <strong>and</strong> unpredictable behavior.<br />

Return Values<br />

If the fcntl() function completes successfully, its return value depends on cmd, as<br />

follows:<br />

If cmd is ... Then fcntl() returns ...<br />

F_DUPFD A new file descriptor<br />

F_GETFD,<br />

F_GETFL<br />

Any other value 0<br />

The values of the file status flags <strong>and</strong> file access<br />

specifications<br />

Otherwise, fcntl() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

7859 6137–009 5–23


fcntl()<br />

Error Codes<br />

If any of the following conditions occurs, the fcntl() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EAGAIN cmd is F_SETLK <strong>and</strong> one of the following is true:<br />

• l_type is F_WRLCK <strong>and</strong> another process owns a lock on some<br />

portion of the segment to be locked.<br />

• l_type is F_RDLCK <strong>and</strong> another process owns an exclusive lock<br />

on some portion of the segment to be locked.<br />

EBADF Any of the following errors occurred:<br />

• fildes is not a valid file descriptor.<br />

• The following conditions are all true:<br />

− cmd is F_SETLK or F_SETLKW.<br />

− l_type is F_RDLCK.<br />

− fildes is not a file descriptor open <strong>for</strong> reading.<br />

• The following conditions are all true:<br />

− cmd is F_SETLK or F_SETLKW.<br />

− l_type is F_WRLCK.<br />

− fildes is not a file descriptor open <strong>for</strong> writing.<br />

EDEADLK Both of the following conditions occurred:<br />

• cmd is F_SETLKW.<br />

• Suspending the process because of a conflict with the request<br />

would cause a deadlock.<br />

EFAULT Both of the following conditions occurred:<br />

• cmd is F_GETLK, F_SETLK, or F_SETLKW.<br />

• parm-3 is not a valid pointer.<br />

EINTR Both of the following conditions occurred:<br />

• cmd is F_SETLKW.<br />

• The process received a signal be<strong>for</strong>e the locking request was<br />

granted.<br />

5–24 7859 6137–009


EINVAL Any of the following errors occurred:<br />

• cmd is not one of the valid values listed.<br />

• cmd is F_DUPFD <strong>and</strong> parm-3 is less than 0 or greater than or<br />

equal to the maximum number of open files.<br />

fcntl()<br />

• cmd is F_GETLK, F_SETLK, or F_SETLKW, <strong>and</strong> the flock structure<br />

to which parm-3 points is invalid.<br />

• cmd is F_SETFD, <strong>and</strong> the value of parm-3 is not 0 or<br />

FD_CLOEXEC.<br />

• cmd is F_DUPFD, F_SETFL, F_GETLK, F_SETLK, or F_SETLKW<br />

<strong>and</strong> parm-3 is not specified.<br />

• cmd is F_SETFL, <strong>and</strong> the value of parm-3 has undefined bits set.<br />

EMFILE Both of the following conditions occurred:<br />

• cmd is F_DUPFD.<br />

• No file descriptors greater than or equal to parm-3 are available.<br />

ENOLCK Both of the following conditions occurred:<br />

The flock Structure<br />

• cmd is either F_SETLK or F_SETLKW.<br />

• Satisfying the lock or unlock request results in the number of<br />

locked regions <strong>for</strong> the process exceeding the maximum number<br />

of locks allowed <strong>for</strong> a process.<br />

The flock structure provides in<strong>for</strong>mation to the kernel about the locking request. It also<br />

gives the process in<strong>for</strong>mation about existing locks. The following table describes the<br />

flock structure, which is defined in :<br />

Member<br />

Name<br />

Member<br />

Type Description Values<br />

l_len off_t Number of consecutive<br />

bytes to be locked or<br />

unlocked<br />

l_pid pid_t Process ID of process<br />

owning a conflicting lock<br />

l_start off_t Distance to the first byte<br />

in the lock from the<br />

address specified by<br />

l_whence<br />

If positive, l_len bytes; if 0,<br />

to the end of the file<br />

(cannot be negative)<br />

Returned by F_GETLK<br />

Any integer (positive,<br />

negative, or 0) A,B<br />

7859 6137–009 5–25


fcntl()<br />

Member<br />

Name<br />

Member<br />

Type Description Values<br />

l_type short int Request type, one of<br />

• Exclusive lock<br />

• Shared lock<br />

• Unlock<br />

l_whence short int File address at which to<br />

add l_start to find the first<br />

byte in the lock; either<br />

• Current position<br />

• End of file<br />

• Beginning of file<br />

F_WRLCK, F_RDLCK,<br />

F_UNLCK C<br />

SEEK_CUR, SEEK_END,<br />

SEEK_SET D<br />

A – The result of applying l_start to l_whence must be ≥0. That is, the starting position of the lock<br />

cannot be be<strong>for</strong>e the beginning of the file.<br />

B – If an F_GETLK request finds a conflicting lock, the value of l_start identifies the first byte of<br />

the conflicting lock relative to the beginning of the file.<br />

C – If an F_GETLK request does not find a conflicting lock, the kernel changes the value of l_type<br />

to F_UNLCK.<br />

D – If an F_GETLK request finds a conflicting lock, the value of l_whence is SEEK_SET.<br />

Illustration<br />

Values in the flock structure determine how <strong>and</strong> where a lock is created on a file. Given<br />

specific values <strong>for</strong> the starting offset position (l_start) <strong>and</strong> length (l_len) of a desired lock,<br />

the value of l_whence determines whether the lock occurs at the beginning, current<br />

position, or end of a file, as shown in the following diagram:<br />

5–26 7859 6137–009


Locking <strong>and</strong> Unlocking Whole Files<br />

fcntl()<br />

A process can lock or unlock an entire file if it sets a lock of zero length <strong>and</strong> zero offset<br />

that starts at the beginning of the file, as shown by the following values:<br />

• l_len = 0<br />

• l_start = 0<br />

• l_whence = SEEK_SET<br />

Replacing <strong>and</strong> Merging Locks<br />

A successful F_SETLK or F_SETLKW request replaces the previous lock type <strong>for</strong> each<br />

byte in the specified region with the new lock type. Be<strong>for</strong>e returning, fcntl() merges<br />

adjacent locks of the same type that are owned by the requesting process.<br />

For example, suppose a process owns shared locks on bytes 0 through 5 <strong>and</strong> bytes 7<br />

through 9 in a file. The process requests a shared lock on byte 6 (or on a range including<br />

byte 6). The result is a single shared lock on bytes 0 through 9.<br />

File Descriptor Services<br />

The symbolic names in this subsection are the values <strong>for</strong> cmd that allow fcntl() to<br />

duplicate a file descriptor (F_DUPFD)<br />

F_DUPFD—Duplicate File Descriptor<br />

This service requires an integer type <strong>for</strong> parm-3. The fcntl() function creates <strong>and</strong> returns a<br />

new file descriptor with the following characteristics:<br />

• It is greater than or equal to parm-3.<br />

• It refers to the same open file description as fildes.<br />

File Descriptor Closure Mode Services<br />

The cmd settings in this subsection allow a program to control the disposition of open<br />

file descriptors when _cifs_new_process() creates a child process.<br />

F_GETFD—Get File Descriptor Closure Mode<br />

This service of the fcntl() function returns the setting of the close_on_exec field of the<br />

specified file descriptor. The return value is either 0 (file descriptor is copied to the new<br />

process) or FD_CLOEXEC (file descriptor is not copied to the new process).<br />

F_SETFD—Set File Descriptor Closure Mode<br />

This service of the fcntl() function requires an integer type <strong>for</strong> parm-3 containing either 0<br />

or FD_CLOEXEC. No other values are permitted.<br />

File Status Flags <strong>and</strong> Access Specification Services<br />

The symbolic names in this subsection are the values <strong>for</strong> cmd that allow fcntl() to<br />

• Retrieve the file status flags <strong>and</strong> file access specification (F_GETFL)<br />

• Set the file status flags (F_SETFL)<br />

7859 6137–009 5–27


fcntl()<br />

File status flags <strong>and</strong> the file access specification are associated with an open file<br />

description. They do not indicate anything about other open file descriptions that<br />

reference the same file.<br />

F_GETFL—Get File Status Flags <strong>and</strong> Access Specification<br />

The fcntl() function returns the following values associated with fildes (see the open()<br />

function <strong>for</strong> descriptions of its symbolic names):<br />

File Attribute Value Description<br />

File status flags O_APPEND<br />

O_DSYNC<br />

File access<br />

specification<br />

O_NONBLOCK<br />

O_SYNC<br />

O_RDONLY<br />

O_RDWR<br />

O_WRONLY<br />

Append mode<br />

Synchronize file data on read <strong>and</strong> write<br />

operations<br />

No delay<br />

Synchronize file data <strong>and</strong> access times on read<br />

<strong>and</strong> write operations<br />

Open <strong>for</strong> reading<br />

Open <strong>for</strong> reading <strong>and</strong> writing<br />

Open <strong>for</strong> writing<br />

parm-3 is not required <strong>for</strong> this service <strong>and</strong> is ignored if supplied.<br />

O_ACCMODE, which is defined in , is a mask that references all of the file<br />

access flags. By using O_ACCMODE to mask portions of the fcntl() result, you can<br />

determine the file access specification <strong>and</strong> file status flags from the fcntl() result. See<br />

the examples in this subsection <strong>for</strong> coding details.<br />

F_SETFL—Set File Status Flags<br />

This service requires an integer type <strong>for</strong> parm-3 containing the new settings <strong>for</strong> the file<br />

status flags in the open file description associated with fildes. For this service, fcntl()<br />

ignores other bits in parm-3.<br />

If the result of an AND operation between parm-3 <strong>and</strong> a file status constant is zero,<br />

fcntl() clears the corresponding file status flag in the open file description; otherwise,<br />

fcntl() sets the flag. In other words, you must set the flag in parm-3 if you want it set in<br />

the open file description; if the flag is not set in parm-3, it is cleared in the open file<br />

description. The following constants set the corresponding file status flag:<br />

• O_APPEND<br />

• O_DSYNC<br />

• O_NONBLOCK<br />

• O_SYNC<br />

If both the O_DSYNC <strong>and</strong> O_SYNC flags are set (see the open() function), the effect is<br />

the same as if only O_SYNC is set.<br />

Calling fcntl() with F_GETFL<br />

The following code shows how to call fcntl() to get the file status flags <strong>and</strong> file mode,<br />

where fd_a is an existing file descriptor:<br />

5–28 7859 6137–009


int fd_a;<br />

int result_a;<br />

result_a = fcntl(fd_a, F_GETFL);<br />

Interpreting the Results of Calling fcntl() with F_GETFL<br />

fcntl()<br />

To extract the file access specification from the result of F_GETFL, do an AND operation<br />

between the result <strong>and</strong> O_ACCMODE:<br />

int access_bits;<br />

access_bits = result_a & O_ACCMODE<br />

To extract the file status flags from the result of F_GETFL, do an AND operation<br />

between the result <strong>and</strong> the complement of O_ACCMODE:<br />

int status_bits;<br />

status_bits = result_a & ~O_ACCMODE;<br />

To determine if the file is open <strong>for</strong> reading from the result of F_GETFL, do an AND<br />

operation between the result <strong>and</strong> O_RDONLY:<br />

if (result_a & O_RDONLY)<br />

{ .<br />

. /* Code <strong>for</strong> readable file */<br />

}<br />

.<br />

To determine if the file is open <strong>for</strong> appending data from the result of F_GETFL, do an<br />

AND operation between the result <strong>and</strong> O_APPEND:<br />

if (result_a & O_APPEND)<br />

{ .<br />

. /* Code <strong>for</strong> appending data */<br />

.<br />

}<br />

7859 6137–009 5–29


fcntl()<br />

Calling fcntl() with F_SETFL<br />

The following code shows how to call fcntl() to set the O_APPEND, O_NONBLOCK, <strong>and</strong><br />

O_SYNC file status flags <strong>and</strong> clear the O_DSYNC flag, where fd_a is an existing file<br />

descriptor:<br />

int status_flags = O_APPEND | O_NONBLOCK | O_SYNC;<br />

fcntl(fd_a, F_SETFL, status_flags);<br />

Record Locking Services<br />

The symbolic names in this subsection are the values <strong>for</strong> cmd that allow fcntl() to<br />

retrieve (F_GETLK) or set (F_SETLK <strong>and</strong> F_SETLKW) advisory record locks on any file or<br />

directory. They require parm-3 to point to a flock structure.<br />

F_GETLK—Get Record-Locking In<strong>for</strong>mation<br />

The fcntl() function searches <strong>for</strong> a lock owned by another process that conflicts with the<br />

lock description (shared or exclusive) in the flock structure indicated by parm-3. That is,<br />

the type <strong>and</strong> location of an existing lock would prevent the requested lock from being<br />

created. The behavior of fcntl() depends on whether a conflicting lock exists, as follows:<br />

• A conflicting lock exists; fcntl() does the following:<br />

− Overwrites the flock structure with the in<strong>for</strong>mation retrieved about the<br />

conflicting lock<br />

− Sets l_start to the first byte of the conflicting lock, relative to the beginning of<br />

the file<br />

− Sets l_whence to SEEK_SET<br />

• No conflicting lock exists; fcntl() does the following:<br />

− Sets l_type to F_UNLCK<br />

− Leaves the rest of the flock structure unchanged<br />

If parm-3 points to a structure whose l_type field is F_UNLCK, it is not possible <strong>for</strong> a lock<br />

conflict to arise. There<strong>for</strong>e, fcntl() behaves the same as the second case.<br />

Conclusions About Using F_GETLK<br />

You can draw the following conclusions about using F_GETLK:<br />

• If you request an exclusive or shared lock <strong>and</strong> fcntl() returns a structure whose l_type<br />

field is F_UNLCK, then no conflicting lock existed at the time of the call. However,<br />

this does not guarantee that no conflicting lock exists if you try to set the same lock<br />

using F_SETLK, because another process can establish a conflicting lock in the<br />

interim.<br />

• An appropriate use <strong>for</strong> F_GETLK is to determine more in<strong>for</strong>mation about a lock that<br />

conflicts with your request to set a lock with F_SETLK. In particular, the process ID<br />

of the owner of the conflicting lock might be useful, depending on the application.<br />

• If your request has lock type F_UNLCK, using F_GETLK is meaningless.<br />

5–30 7859 6137–009


F_SETLK—Set Record-Locking In<strong>for</strong>mation<br />

fcntl()<br />

The fcntl() function sets or clears a lock on a file segment according to the description in<br />

the flock structure indicated by parm-3, as shown in the following table (the symbolic<br />

names are defined in ):<br />

If l_type is ... Then fcntl() uses l_whence, l_start, <strong>and</strong> l_len to ...<br />

F_RDLCK Establish a shared lock.<br />

F_WRLCK Establish an exclusive lock.<br />

F_UNLCK Remove any locks in the indicated range.<br />

If fcntl() cannot set the requested lock because of conflicts with existing locks, it fails.<br />

F_SETLKW—Set Record-Locking In<strong>for</strong>mation; Wait If Blocked<br />

This service is the same as F_SETLK, except that the process waits until the request can<br />

be satisfied or is interrupted. If the process is interrupted while waiting <strong>for</strong> a region to be<br />

unlocked, fcntl() fails <strong>and</strong> the lock is not created.<br />

Calling fcntl() with F_SETLK<br />

The following code shows how to call fcntl() to set an exclusive lock at the current<br />

read/write position in the file, where fd_a is an existing file descriptor:<br />

struct flock lock_to set;<br />

lock_to_set.l_len = 12;<br />

lock_to_set.l_start = 0;<br />

lock_to_set.l_type = F_WRLCK;<br />

lock_to_set.l_whence = SEEK_CUR;<br />

fcntl(fd_a, F_SETLK, &lock_to_set);<br />

Modifying Existing Locks<br />

If the calling process already has locks covering part of the segment indicated by the lock<br />

description, fcntl() modifies these locks as necessary. For example, if the process owns<br />

an exclusive lock on the first 10 bytes of the file <strong>and</strong> requests a shared lock on byte 5<br />

(l_start = 5), it then owns 3 distinct locks, as follows:<br />

• An exclusive lock on bytes 0 through 4<br />

• A shared lock on byte 5<br />

• An exclusive lock on bytes 6 through 9<br />

7859 6137–009 5–31


fcntl()<br />

Clearing Existing Locks<br />

You can clear all 3 locks in the previous example by unlocking the first 10 bytes of the<br />

file, as follows:<br />

struct flock lock_to_set;<br />

lock_to_set.l_len = 10;<br />

lock_to_set.l_start = 0;_<br />

lock_to_set.l_type = F_UNLCK;<br />

lock_to_set.l_whence = SEEK_SET;<br />

fcntl(fd_a, F_SETLK, &lock_to_set);<br />

5–32 7859 6137–009


fdatasync()<br />

Application<br />

fdatasync()<br />

Use the fdatasync() function to write to the device all data currently in a portion of the<br />

buffer cache <strong>for</strong> a file, thus protecting the data against loss due to a system outage. With<br />

fdatasync(), an application can synchronize all file updates at one time, instead of on<br />

every read or write operation. However, fdatasync() does not synchronize file access<br />

times.<br />

For a similar function that does synchronize file access times, see the fsync() function.<br />

For alternate methods of synchronizing disk data, see the discussions of the O_SYNC<br />

<strong>and</strong> O_DSYNC flags under the open() <strong>and</strong> fcntl() functions.<br />

Synopsis<br />

int fdatasync(int fildes);<br />

Description<br />

The fdatasync() function writes from the buffer cache to the device all data belonging to<br />

the specified file, where fildes specifies a regular file open <strong>for</strong> writing. The data written is<br />

that portion of the buffer cache associated with the file referenced by fildes.<br />

Return Values<br />

If the fdatasync() function completes successfully, it returns 0. Otherwise, fdatasync()<br />

sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the fdatasync() function returns -1 <strong>and</strong> sets<br />

errno to the corresponding value:<br />

EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

EINVAL Data synchronization is not supported <strong>for</strong> the type of file<br />

described by fildes.<br />

EIO The file could not be fully synchronized because of an I/O error.<br />

7859 6137–009 5–33


fdopen()<br />

fdopen()<br />

Application<br />

Use the fdopen() function to create a stream <strong>and</strong> associate a file descriptor with it.<br />

Synopsis<br />

FILE * fdopen(int fildes, const char * type);<br />

Description<br />

The fdopen() function creates a stream <strong>and</strong> associates a file descriptor with the stream,<br />

where:<br />

FILE<br />

fildes<br />

type<br />

is an opaque data type that describes an open instance of a file.<br />

is the file descriptor to associate with the stream.<br />

is a character string specifying the access mode <strong>for</strong> the file. It is the same as the<br />

type argument <strong>for</strong> the fopen() function. It must be a subset of the access mode of<br />

the initial open() function.<br />

The access mode prefixes “w” <strong>and</strong> “w+” do not cause truncation of the file. The file<br />

position indicator is set to the position indicated by the file offset associated with the file<br />

descriptor. Error <strong>and</strong> end-of-file indicators are cleared.<br />

Return Values<br />

If the fdopen() function completes successfully, it does the following:<br />

• Does not change the st_atime field<br />

• Returns a pointer to a stream<br />

Otherwise, fdopen() sets errno to identify the specific error <strong>and</strong> returns a null pointer.<br />

Error Codes<br />

If the following condition occurs, the fdopen() function returns -1 <strong>and</strong> sets errno to the<br />

corresponding value:<br />

EINVAL type is not a subset of the access mode of the initial open() function.<br />

5–34 7859 6137–009


feof()<br />

Application<br />

Use the feof() function to test whether a stream is at end of file.<br />

Synopsis<br />

int feof(FILE * stream);<br />

Description<br />

The feof() function tests the end-of-file indicator <strong>for</strong> a stream, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

Return Values<br />

The feof() function returns a nonzero value if the end-of-file indicator is set.<br />

feof()<br />

7859 6137–009 5–35


ferror()<br />

ferror()<br />

Application<br />

Use the ferror() function to test whether a read/write error occurred.<br />

Synopsis<br />

int ferror(FILE * stream);<br />

Description<br />

The ferror() function tests the read/write error indicator <strong>for</strong> a stream, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

Return Values<br />

The ferror() function returns a nonzero value if the read/write error indicator is set.<br />

5–36 7859 6137–009


fflush()<br />

Application<br />

fflush()<br />

Use the fflush() function to write all remaining data in the buffer to a file without closing<br />

the file.<br />

Synopsis<br />

int fflush(FILE * stream);<br />

Description<br />

The fflush() function causes any unwritten data <strong>for</strong> an output stream to be written to the<br />

file, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

Return Values<br />

The fflush() function returns a nonzero value if a write error occurs.<br />

7859 6137–009 5–37


fgetc()<br />

fgetc()<br />

Application<br />

Use the fgetc() function to obtain the next character from an input stream.<br />

Synopsis<br />

int fgetc(FILE * stream);<br />

Description<br />

The fgetc() function obtains the next character (if present) from an input stream, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object that fgetc() reads as unsigned char characters.<br />

The fgetc() function converts the character to an int <strong>and</strong> advances the associated file<br />

position indicator, if defined. The fgetc() function is not implemented as a macro.<br />

Return Values<br />

The fgetc() function returns the next character from the specified input stream. If the<br />

stream is at end of file, fgetc() sets the end-of-file indicator <strong>and</strong> returns EOF. If a read<br />

error occurs, fgetc() sets the error indicator <strong>and</strong> returns EOF.<br />

5–38 7859 6137–009


fgetpos()<br />

Application<br />

Use the fgetpos() function to obtain the current value of the file position indicator.<br />

Synopsis<br />

int fgetpos(FILE * stream, fpos_t * pos);<br />

Description<br />

The fgetpos() function obtains the current value of the file position indicator, where:<br />

FILE<br />

stream<br />

pos<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

is a pointer to a structure in which the value is returned.<br />

The fsetpos() function can use this structure.<br />

Return Values<br />

fgetpos()<br />

If it completes successfully, the fgetpos() function returns 0. Otherwise, fgetpos() sets<br />

errno to indicate the error <strong>and</strong> returns a nonzero value.<br />

7859 6137–009 5–39


fgets()<br />

fgets()<br />

Application<br />

Use the fgets() function to read the next characters from an input stream into an array.<br />

Synopsis<br />

char * fgets(char * s, int n, FILE * stream);<br />

Description<br />

The fgets() function reads the next n-1 characters from an input stream into an array,<br />

where:<br />

s<br />

n<br />

FILE<br />

stream<br />

is a pointer to the array that stores the characters read. A nul character is written<br />

immediately after the last character read into the array.<br />

specifies one more than the number of characters to read. That is, fgets() reads at<br />

most n-1 characters.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object to read. No additional characters are read after a new line<br />

indicator (that is retained) or after end of file.<br />

Return Values<br />

If it completes successfully, the fgets() function returns s. If end of file is encountered<br />

<strong>and</strong> no characters have been read into the array, the contents of the array remain<br />

unchanged <strong>and</strong> fgets() returns a null pointer. If a read error occurs during the operation,<br />

the array contents are indeterminate <strong>and</strong> fgets() returns a null pointer.<br />

5–40 7859 6137–009


fileno()<br />

Application<br />

Use the fileno() function to retrieve a file descriptor <strong>for</strong> a specific data stream.<br />

Synopsis<br />

int fileno(FILE * stream);<br />

Description<br />

The fileno() function retrieves a file descriptor, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object associated with the file descriptor.<br />

Return Values<br />

If the fileno() function completes successfully, it returns a file descriptor. Otherwise,<br />

fileno() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

fileno()<br />

If any of the following conditions occurs, the fileno() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EFAULT The pointer specified by stream is invalid.<br />

EINVAL The stream to which stream points is invalid.<br />

7859 6137–009 5–41


fopen()<br />

fopen()<br />

Application<br />

Use the fopen() function to open a path name <strong>and</strong> associate a stream with it.<br />

Synopsis<br />

FILE * fopen(const char * pathname, const char * type);<br />

Description<br />

The fopen() function opens a path name <strong>and</strong> associates a stream with it, where:<br />

FILE<br />

is an opaque data type that describes an open instance of a file.<br />

pathname<br />

type<br />

is a pointer to the path name to open.<br />

is a pointer to a string that begins with one of the sequences in the following table.<br />

Additional characters, separated from the given sequences by a comma, may follow<br />

these, but fopen() ignores them. The sequences may be in upper or lower case,<br />

although upper case might not be portable to other plat<strong>for</strong>ms.<br />

Sequence Description<br />

r Open existing text file <strong>for</strong> reading.<br />

w Create file <strong>for</strong> writing or truncate to 0 length.<br />

a Append; open file or create <strong>for</strong> writing at end-of-file.<br />

rb Open existing binary file <strong>for</strong> reading.<br />

wb Create binary file <strong>for</strong> writing or truncate to 0 length.<br />

ab Append; open binary file or create <strong>for</strong> writing at end-of-file.<br />

r+ Open existing file <strong>for</strong> update (reading <strong>and</strong> writing).<br />

w+ Create file <strong>for</strong> update or truncate to 0 length.<br />

a+ Append; open file or create <strong>for</strong> update, writing at end-of-file.<br />

r+b or rb+ Open existing binary file <strong>for</strong> update (reading <strong>and</strong> writing).<br />

w+b or wb+ Create binary file <strong>for</strong> update or truncate to 0 length.<br />

a+b or ab+ Append; open binary file or create <strong>for</strong> update, writing at endof-file.<br />

5–42 7859 6137–009


fopen()<br />

Note: The letter b in the type sequence is effective only when a file is created. In all<br />

other cases, the file retains its existing type (SDF or binary), <strong>and</strong> b, if present, is ignored.<br />

Appending Data to a File<br />

Opening a file with append mode (a, ab, a+, or a+b) <strong>for</strong>ces all subsequent writes to the<br />

file to the current end of file, regardless of previous calls to the fseek() function.<br />

Updating a File<br />

When you open a file <strong>for</strong> update, you can per<strong>for</strong>m both input <strong>and</strong> output operations on<br />

the associated stream. However, an output operation cannot be directly followed by an<br />

input operation without an intervening call to fseek(), rewind(), or fflush(). Similarly, an<br />

input operation cannot be directly followed by an output operation without an intervening<br />

call to fseek() or rewind(), unless the input operation encounters the end of the file.<br />

Default Permissions When Creating a File<br />

If the fopen() function creates a file, it assigns read <strong>and</strong> write permissions to the owner,<br />

group, <strong>and</strong> other permission classes by default. The following file mode specification <strong>for</strong><br />

the open() function is equivalent:<br />

S_IRUSR | S_IWUSR | S_IWGRP | S_IROTH | S_IWOTH<br />

Return Values<br />

If it completes successfully, the fopen() function returns a pointer to the object<br />

controlling the stream. Otherwise, fopen() returns a null pointer.<br />

7859 6137–009 5–43


fprintf()<br />

fprintf()<br />

Application<br />

Use the fprintf() function to write <strong>for</strong>matted output.<br />

Synopsis<br />

int fprintf(FILE * stream, const char * <strong>for</strong>mat, ...);<br />

Description<br />

The fprintf() function writes <strong>for</strong>matted output, where:<br />

FILE<br />

stream<br />

<strong>for</strong>mat<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> the output. A <strong>for</strong>matted output string can have a<br />

maximum of 32,767 characters.<br />

is a pointer that controls the output by specifying how subsequent arguments are<br />

converted be<strong>for</strong>e being output.<br />

Format Strings<br />

A <strong>for</strong>mat string contains two types of objects:<br />

• Plain characters<br />

Plain characters are copied unchanged to the output stream.<br />

• Conversion specifications<br />

Each conversion specification results in fetching 0 or more subsequent arguments.<br />

If the <strong>for</strong>mat is exhausted while arguments remain, the excess arguments are evaluated<br />

but otherwise ignored. The fprintf() function returns when it encounters the end of the<br />

<strong>for</strong>mat string.<br />

Conversion Specifications<br />

Each conversion specification is introduced by the percent (%) character. After the %<br />

character, the following characters appear in sequence:<br />

1. An optional field, integer$, where integer is a decimal integer value specifying the<br />

next argument to be converted <strong>for</strong> output.<br />

2. Zero or more flags that modify the meaning of the conversion specification.<br />

5–44 7859 6137–009


fprintf()<br />

3. An optional decimal integer, other than 0, specifying a minimum field width. If the<br />

converted value has fewer characters than the field width, it is padded with spaces<br />

on the left to the field width (or on the right if the left adjustment flag is specified).<br />

Note: If the first character after the percent (%) sign is 0, then it is a flag character,<br />

not a field width.<br />

4. An optional precision, in the <strong>for</strong>m of a period (.) followed by an optional decimal<br />

integer. If the integer is omitted, it is treated as 0. The padding specified by the<br />

precision overrides the padding specified by the field width. The precision specifies<br />

the following number:<br />

a. For d, i, o, u, x, <strong>and</strong> X conversions, the minimum number of digits to appear<br />

b. For e, E, <strong>and</strong> f conversions, the number of digits to appear after the decimal<br />

point<br />

c. For g <strong>and</strong> G conversions, the maximum number of significant digits<br />

d. For s conversions, the maximum number of characters to be printed from a<br />

string<br />

5. An optional h, l, L, or ll (lowercase double L) <strong>for</strong>mat character, which must appear as<br />

follows:<br />

a. h<br />

b. l<br />

c. L<br />

d. ll<br />

This letter specifies that a following d, i, o, u, x, or X conversion specifier applies<br />

to a short int or an unsigned short int argument. It means the argument has<br />

been promoted according to the integral promotions <strong>and</strong> its value is cast to short<br />

or unsigned short be<strong>for</strong>e printing.<br />

This letter specifies that a following d, i, o, u, x, or X conversion specifier applies<br />

to a long int or an unsigned long int argument. This letter specifies that a<br />

following n conversion specifier applies to a pointer to a long int argument.<br />

This letter specifies that a following e, E, f, g, or G conversion specifier applies to<br />

a long double argument.<br />

If h, l, or L appears with any other conversion specifier, it is ignored.<br />

These letters (lowercase double L) specify that a following d, I, o, x, or X<br />

conversion specifier applies to a long long int argument.<br />

6. A character that specifies the type of conversion to be applied.<br />

A field width or precision, or both, can be indicated by an asterisk (*) instead of a digit<br />

string. In this case, an int argument supplies the field width or precision. The arguments<br />

specifying field width or precision must appear be<strong>for</strong>e the argument (if any) to be<br />

converted. A negative field width argument is read as a - flag followed by a positive field<br />

width. A negative precision argument is the same as if it were omitted.<br />

7859 6137–009 5–45


fprintf()<br />

Precision <strong>and</strong> width can also be indicated by an asterisk (* ) followed by a decimal<br />

integer <strong>and</strong> the $ character, where the decimal integer specifies the position in the<br />

argument list of the integer argument containing the field width or precision.<br />

The following table lists the flag characters <strong>and</strong> their meanings.<br />

Flag<br />

Character Description<br />

- The result of the conversion is left justified within the field.<br />

+ The result of a signed conversion always begins with a plus or minus sign.<br />

Space If the first character of a signed conversion is not a sign, a space is placed be<strong>for</strong>e<br />

the result. If the space <strong>and</strong> + flags both appear, the space flag is ignored.<br />

# The result is converted to an alternate <strong>for</strong>m. For c, d, i, s, <strong>and</strong> u conversions, the<br />

flag has no effect.<br />

For o conversion, it increases the precision to <strong>for</strong>ce the first digit of the result to<br />

be 0.<br />

For x <strong>and</strong> X conversions, a nonzero result has 0x or 0X placed be<strong>for</strong>e it. For e, E,<br />

f, g, <strong>and</strong> G conversions, the result always contains a decimal point, even if no<br />

digits follow the decimal point (normally, a decimal point appears in the result of<br />

these conversions only if a digit follows it). For g <strong>and</strong> G conversions, trailing 0s<br />

are not removed from the result, as they normally are.<br />

Note: Other compilers that con<strong>for</strong>m to American National St<strong>and</strong>ard C might not<br />

ignore the # flag with c, d, i, s, or u conversions. For maximum portability, do not<br />

use the # flag with these conversions.<br />

0 For numeric conversions (d, i, o, u, x, X, e, E, f, g, G), the field width is padded<br />

with leading zeros following any indication of sign or base; the field is not padded<br />

with spaces.<br />

If the 0 <strong>and</strong> - flags both appear, the 0 flag is ignored. For d, i, o, u, x, <strong>and</strong> X<br />

conversions, the 0 flag is ignored if a precision is specified. For other conversions,<br />

the behavior is undefined if a precision is specified.<br />

Note: If the first character after the percent (%) sign is 0, then this character is a<br />

zero flag, not a field width.<br />

5–46 7859 6137–009


The following table lists the conversion specifiers <strong>and</strong> their meanings.<br />

Specifier Description<br />

c The least significant byte of the int argument is converted to a character<br />

<strong>and</strong> printed.<br />

d, i, o, u, x,<br />

X<br />

fprintf()<br />

The int argument is converted to signed decimal (d or i), unsigned octal<br />

(o), unsigned decimal (u), or unsigned hexadecimal notation (x or X). The<br />

letters abcdef are used <strong>for</strong> x conversion <strong>and</strong> the letters ABCDEF <strong>for</strong> X<br />

conversion. The precision specifies the minimum number of digits to<br />

appear. If the value being converted can be represented in fewer digits, it<br />

is exp<strong>and</strong>ed with leading 0s. The default precision is 1. The result of<br />

converting a 0 value with a precision of 0 is no characters.<br />

e, E The double argument is converted in the style [-]d.ddde+dd, where one<br />

digit occurs be<strong>for</strong>e the decimal point <strong>and</strong> the number of digits after the<br />

decimal point is equal to the precision.<br />

When the precision is missing, 6 digits are produced. If the precision is 0,<br />

no decimal point appears. The value is rounded to the appropriate number<br />

of digits.<br />

The E <strong>for</strong>mat code produces a number with E instead of e introducing the<br />

exponent. The exponent always contains at least 2 digits. However, if the<br />

magnitude to print is greater than or equal to 1E+100, additional exponent<br />

digits are printed as necessary.<br />

f The double argument is converted to decimal notation in the style<br />

[-]ddd.ddd, where the number of digits after the decimal point is equal to<br />

the precision specification.<br />

If the precision is missing, it is taken as 6; if the precision is explicitly 0, no<br />

decimal point appears. If a decimal point appears, at least one digit<br />

appears be<strong>for</strong>e it. The value is rounded to the appropriate number of<br />

digits.<br />

g, G For the g <strong>for</strong>mat code, the double argument is printed in style f or e. For a<br />

G <strong>for</strong>mat code, it is printed in style E. In each style, the precision specifies<br />

the number of significant digits.<br />

The style used depends on the value converted. Style e is used only if the<br />

exponent resulting from the conversion is less than -4 or greater than the<br />

precision. Trailing zeros are removed from the result. A decimal point<br />

appears only if it is followed by a digit.<br />

n The argument is taken to be an (int *) pointer to an integer into which is<br />

written the number of characters written to the output stream so far by<br />

this call to fprintf. No argument is converted.<br />

p The argument is taken to be a (void *) pointer to an object. The value of<br />

the pointer is printed as 24 octal digits.<br />

7859 6137–009 5–47


fprintf()<br />

Specifier Description<br />

s The argument is taken to be a (char *) pointer to a string. Characters from<br />

the string are written up to but not including the terminating NUL, or until<br />

the number of characters indicated by the precision is written. If the<br />

precision is missing, it is taken to be arbitrarily large so that all characters<br />

be<strong>for</strong>e the first NUL are printed.<br />

The maximum number of characters that can be printed <strong>for</strong> one %s<br />

conversion is 6999.<br />

% The character % is printed. No argument is converted.<br />

Considerations <strong>for</strong> Conversion Specifications<br />

If the conversion specifier is not one of the characters in the above table, character is<br />

printed <strong>and</strong> no argument is converted.<br />

If any argument is or points to an aggregate (except <strong>for</strong> an array of characters using %s<br />

conversion or any pointer using %p conversion), the behavior is undefined.<br />

A nonexistent or small field width does not cause truncation of a field. If the conversion<br />

result is wider than the field width, the field is exp<strong>and</strong>ed to contain the conversion result.<br />

Return Values<br />

If it completes successfully, the fprintf() function returns the number of characters<br />

transmitted. Otherwise, fprintf() returns a negative value.<br />

Examples<br />

Print a date <strong>and</strong> time in the <strong>for</strong>m “Tuesday, July 3, 10:02,” where weekday <strong>and</strong> month<br />

are pointers to strings:<br />

fprintf(stdout, "%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min);<br />

Print pi to five decimal places:<br />

fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0));<br />

5–48 7859 6137–009


fputc()<br />

Application<br />

Use the fputc() function to write a character to an output stream.<br />

Synopsis<br />

int fputc(int c, FILE * stream);<br />

Description<br />

The fputc() function writes a character to an output stream, where:<br />

c<br />

FILE<br />

stream<br />

specifies the character to write, after conversion to an unsigned char.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> output.<br />

fputc()<br />

The fputc() function writes the character at the position indicated by the associated file<br />

position indicator (if defined), advancing the indicator appropriately. If the file position<br />

indicator is not defined, the character is appended to the output stream.<br />

The fputc() function is not implemented as a macro.<br />

Return Values<br />

If it completes successfully, the fputc() function returns the character written. If a write<br />

error occurs, fputc() sets the error indicator <strong>and</strong> returns EOF.<br />

7859 6137–009 5–49


fputs()<br />

fputs()<br />

Application<br />

Use the fputs() function to write a string to an output stream.<br />

Synopsis<br />

int fputs(const char * s, FILE * stream);<br />

Description<br />

The fputs() function writes a string to an output stream, where:<br />

s<br />

FILE<br />

stream<br />

is a pointer to the string to write. The terminating nul character is not written.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> output.<br />

Return Values<br />

If it completes successfully, the fputs() function returns the number of characters<br />

written. Otherwise, fputs() returns EOF.<br />

5–50 7859 6137–009


fread()<br />

Application<br />

Use the fread() function to read elements from an input stream into an array.<br />

Synopsis<br />

size_t fread(void * ptr, size_t size, size_t nelem, FILE * stream);<br />

Description<br />

The fread() function reads elements from an input stream into an array, where:<br />

ptr<br />

size<br />

nelem<br />

FILE<br />

stream<br />

is a pointer to the array.<br />

specifies the size of an element in the array.<br />

specifies the number of elements to attempt to read.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> input.<br />

fread()<br />

The fread() function advances the file position indicator (if defined) by the number of<br />

bytes successfully read. If an error occurs, the resulting value of the file position indicator<br />

is indeterminate. If a partial element is read, its value is indeterminate. Use either the<br />

ferror() or feof() function to distinguish between a read error <strong>and</strong> end of file.<br />

Return Values<br />

If it completes successfully, the fread() function returns the number of elements read;<br />

this number can be less than nelem if a read error or end of file occurs. If either size or<br />

nelem is 0, fread() returns 0 <strong>and</strong> both the contents of the array <strong>and</strong> the state of the input<br />

stream remain unchanged.<br />

7859 6137–009 5–51


freopen()<br />

freopen()<br />

Application<br />

Use the freopen() function to open a path name <strong>and</strong> associate a stream with it. This<br />

function first attempts to close a file associated with the stream.<br />

The primary use of freopen() is to change the file associated with a st<strong>and</strong>ard text stream<br />

(stderr, stdin, or stdout) since those identifiers are not values that may be modified by<br />

the fopen() function.<br />

Synopsis<br />

FILE * freopen(const char * path, const char * type, FILE * stream);<br />

Description<br />

The freopen() function opens a path <strong>and</strong> associates a stream with it, where:<br />

FILE<br />

path<br />

type<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to the path name to open.<br />

is a pointer to a string that begins with one of the sequences in the table in fopen().<br />

Additional characters can follow these sequences, but freopen() ignores them.<br />

is a pointer to a FILE object to associate with the path name.<br />

The freopen() function first attempts to close any file associated with the specified<br />

stream, ignoring any failure to close the file successfully.<br />

Default Permissions When Creating a File<br />

If the freopen() function creates a file, it assigns read <strong>and</strong> write permissions to the<br />

owner, group, <strong>and</strong> other permission classes by default. The following file mode<br />

specification <strong>for</strong> the open() function is equivalent:<br />

S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH<br />

Return Values<br />

If it completes successfully, the freopen() function returns the value of stream.<br />

Otherwise, freopen() returns a null pointer.<br />

5–52 7859 6137–009


fscanf()<br />

Application<br />

Use the fscanf() function to read <strong>for</strong>matted input.<br />

Synopsis<br />

int fscanf(FILE * stream, const char * <strong>for</strong>mat, ...);<br />

Description<br />

The fscanf() function reads <strong>for</strong>matted input, where:<br />

FILE<br />

stream<br />

<strong>for</strong>mat<br />

is an opaque data type that describes an open instance of a file.<br />

fscanf()<br />

is a pointer to a FILE object <strong>for</strong> input. A <strong>for</strong>matted input string can have a maximum<br />

of 32,767 characters.<br />

controls the input by specifying how input text is converted <strong>for</strong> assignment.<br />

Subsequent arguments are pointers to the objects that receive the converted input.<br />

If there are insufficient argument pointers <strong>for</strong> the <strong>for</strong>mat, a signal is generated. If the<br />

program recovers from the signal, it treats it as if an asterisk flag were specified. If<br />

the <strong>for</strong>mat is exhausted while arguments remain, fscanf() evaluates the excess<br />

arguments but otherwise ignores them.<br />

Format Strings<br />

The <strong>for</strong>mat can contain the following code:<br />

• Any number of spaces, horizontal tabs, or newline characters that cause input to be<br />

read up to the next nonwhite-space character<br />

• An ordinary character (not %) that must match the next character of the input stream<br />

• Conversion specifications, consisting of the following sequence:<br />

− The character % or the character sequence % digit $ decimal-integer<br />

− An optional assignment-suppressing character *<br />

− An optional decimal integer that specifies the maximum field width<br />

− An optional h, l, L, or ll (lowercase double L) indicating the size of the receiving<br />

object<br />

See “Conversion Specifications” below.<br />

7859 6137–009 5–53


fscanf()<br />

Conversion Specifications<br />

A conversion specification directs the conversion of the next input field. Except <strong>for</strong> the<br />

conversion specifiers c <strong>and</strong> [, an input field is defined as a sequence of nonspace<br />

characters. It starts at the first character in the input that is not a white-space character<br />

(as specified by the isspace() function) <strong>and</strong> extends to the first conflicting character or<br />

until the field width, if specified, is exhausted.<br />

When the <strong>for</strong>m % decimal-integer $ is used, the decimal integer indicates to which<br />

argument in the argument list to assign the results of the conversion. If decimal-integer<br />

is n, the conversion results are assigned to the nth argument.<br />

The function places the result in the object pointed to by the subsequent argument,<br />

unless assignment suppression was indicated by an asterisk (*). The conversion specifier<br />

indicates the interpretation of the input field. The corresponding argument must be a<br />

pointer to an appropriate type.<br />

The following table lists the valid fscanf conversion specifiers.<br />

Specifier Description<br />

c A character is expected. The subsequent argument must be a pointer to<br />

a char. The normal skip over white space characters is suppressed in this<br />

case. To read the next nonspace character, use %1s. If a field width is<br />

given, the corresponding argument must refer to a character array. The<br />

indicated number of characters is read.<br />

d A decimal integer is expected. The subsequent argument must be a<br />

pointer to an integer.<br />

e, E, f, g, G A floating-point number is expected. The corresponding argument must<br />

be a pointer to a floating-point type. The input <strong>for</strong>mat is as described <strong>for</strong><br />

the strtod function.<br />

i An integer is expected. The corresponding argument must be a pointer to<br />

an integer. The input <strong>for</strong>mat is as described <strong>for</strong> the strtol function, with<br />

the value of 0 <strong>for</strong> the base argument.<br />

n No input is consumed. The subsequent argument must be a pointer to an<br />

integer into which is written the number of characters read from the<br />

input stream so far by this call to fscanf. This is not counted as a match<br />

input item.<br />

o An octal integer is expected. The subsequent argument must be a<br />

pointer to an integer.<br />

p A pointer is expected. The subsequent argument must be a pointer to a<br />

pointer to void. The <strong>for</strong>mat of the input field is an octal number of up to<br />

24 digits. It is the same as that produced by the %p conversion of<br />

fprintf().<br />

s A character string is expected. The subsequent argument must be a<br />

pointer to char that points to an array large enough to accept the string<br />

<strong>and</strong> a terminating NUL, which is added automatically. A space, a<br />

horizontal tab, or a newline character terminates the input field but is not<br />

part of the field.<br />

5–54 7859 6137–009


Specifier Description<br />

u An unsigned decimal integer is expected. The subsequent argument<br />

must be a pointer to an integer.<br />

x, X A hexadecimal integer is expected. The subsequent argument must be a<br />

pointer to an integer.<br />

fscanf()<br />

[ A string that is not to be delimited by spaces is expected. The normal<br />

skip over white-space characters is suppressed in this case. The<br />

subsequent argument must be a pointer to char just as <strong>for</strong> %s. The left<br />

bracket is followed by a set of characters followed by a right bracket. The<br />

characters between the brackets define the set that determines the input<br />

field string.<br />

If the first character after the left bracket is not a circumflex (^), the input<br />

field consists entirely of characters in the defining set. The first input<br />

character not in the defining set signals the end of the input field.<br />

If the first character after the left bracket is a circumflex (^), the input<br />

field consists entirely of characters not in the defining set. The first input<br />

character in the defining set signals the end of the input field.<br />

If the first character is a right bracket (possibly following a circumflex), it<br />

is assumed to be part of the set. A second right bracket is necessary to<br />

delimit the set. This means the set of characters cannot be empty.<br />

A NUL character is appended to the input.<br />

% A single % is expected in the input at this point. No assignment occurs.<br />

Considerations <strong>for</strong> Conversion Specifications<br />

Only the characters in the table above can be used as conversion specifiers. If you use<br />

any other character as a conversion specifier, the C compiler does not recognize it.<br />

Scanning terminates <strong>and</strong> the function returns the number of input items successfully<br />

read.<br />

The conversion specifiers d, i, o, u, <strong>and</strong> x can be preceded by l to indicate that the<br />

subsequent argument is a pointer to a long int rather than a pointer to an int, or by h to<br />

indicate a pointer to a short int, or by ll (lowercase double L) to indicate a pointer to a<br />

long long int.<br />

Similarly, the conversion specifiers e <strong>and</strong> f can be preceded by l to indicate that the<br />

subsequent argument is a pointer to a double rather than a pointer to a float, or by L to<br />

indicate a pointer to a long double.<br />

If fscanf() encounters the end of the file during a conversion, the conversion terminates.<br />

If conversion terminates on a conflicting input character, the offending character is left<br />

unread in the input stream. Trailing white-space characters (including a newline<br />

character) are unread unless matched in the control string. The compiler cannot directly<br />

determine the success of literal matches <strong>and</strong> suppressed assignments other than<br />

through the %n conversion.<br />

If a <strong>for</strong>mat does not have a corresponding argument, the <strong>for</strong>mat is treated as if an<br />

asterisk (*) flag were specified.<br />

7859 6137–009 5–55


fscanf()<br />

Return Values<br />

If it completes successfully, the fscanf() function returns the number of assigned input<br />

items (which can be fewer than provided <strong>for</strong>, or even 0, in the event of an early conflict<br />

between an input character <strong>and</strong> the <strong>for</strong>mat), or EOF if end of file is encountered be<strong>for</strong>e<br />

the first conflict or conversion. Otherwise, fscanf() returns when it encounters the end of<br />

the <strong>for</strong>mat string.<br />

5–56 7859 6137–009


fseek()<br />

Application<br />

Use the fseek() function to set the file position indicator <strong>for</strong> a stream.<br />

Synopsis<br />

int fseek(FILE * stream, long offset, int whence);<br />

Description<br />

The fseek() function sets the file position indicator <strong>for</strong> a stream, where:<br />

FILE<br />

stream<br />

offset<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

fseek()<br />

is a signed number specifying the number of characters to move the indicator from<br />

the starting position.<br />

whence<br />

specifies the starting position in the file, which can be one of the following values:<br />

SEEK_CUR The current position<br />

SEEK_END The end of the file<br />

SEEK_SET The beginning of the file<br />

The fseek() function clears the end-of-file indicator <strong>and</strong> undoes any effects of ungetc().<br />

After a call to fseek() <strong>for</strong> an update file, the next operation can be either input or output.<br />

Return Values<br />

The fseek() function returns a nonzero value <strong>for</strong> an improper request.<br />

7859 6137–009 5–57


fsetpos()<br />

fsetpos()<br />

Application<br />

Use the fsetpos() function to set the file position indicator <strong>for</strong> a stream.<br />

Synopsis<br />

int fsetpos(FILE * stream, const fpos_t * pos);<br />

Description<br />

The fsetpos() function sets the file position indicator <strong>for</strong> a stream, where:<br />

FILE<br />

stream<br />

pos<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

is a pointer to a structure containing the new value <strong>for</strong> the file position indicator. This<br />

structure must be obtained by a call to the fgetpos() function.<br />

Return Values<br />

If it completes successfully, the fsetpos() function returns 0. Otherwise, fsetpos() sets<br />

errno to indicate the error <strong>and</strong> returns a nonzero value.<br />

5–58 7859 6137–009


fstat()<br />

Application<br />

fstat()<br />

Use the fstat() function to retrieve in<strong>for</strong>mation about an open file. In particular, you can<br />

get in<strong>for</strong>mation about the file mode, security attributes, file size, <strong>and</strong> access times.<br />

The fstat() function uses a file descriptor to identify the file or directory. See the stat()<br />

function <strong>for</strong> a similar function that uses a path name.<br />

Synopsis<br />

int fstat(int fildes, struct stat * buf);<br />

Description<br />

The fstat() function returns in<strong>for</strong>mation about an open file in a stat structure, where:<br />

fildes<br />

buf<br />

is a file descriptor associated with an open file description.<br />

is a pointer to a stat structure in which fstat() returns the file in<strong>for</strong>mation.<br />

The stat Structure<br />

The stat structure identifies certain in<strong>for</strong>mation about a file or directory. The following<br />

table describes the stat structure, which is defined in . The size of struct stat is<br />

44 bytes.<br />

Field Name Type Offset Description<br />

st_mode mode_t 0 File mode.<br />

st_ino ino_t 4 File serial number.<br />

st_dev dev_t 8 Numeric identifier <strong>for</strong> the file system in which the<br />

file resides.<br />

st_nlink nlink_t 12 Number of links to the file or directory.<br />

st_uid uid_t 16 Owner user ID of file or directory.<br />

st_gid gid_t 20 Group group ID of file or directory.<br />

st_size off_t 24 Size, in bytes, <strong>for</strong> directories or regular files; bytes<br />

available to be read <strong>for</strong> pipe or FIFO files.<br />

st_rdev rdev_t 28 If the inode represents a device file, this value<br />

identifies the specific type of device that the inode<br />

controls. The values are<br />

1 = /dev/tty<br />

2 = st<strong>and</strong>ard input, output, or error device<br />

3 = /dev/null;<br />

4 = /dev/r<strong>and</strong>om or /dev/ur<strong>and</strong>om<br />

7859 6137–009 5–59


fstat()<br />

Field Name Type Offset Description<br />

st_atime time_t 32 Time of last access to file data.<br />

st_mtime time_t 36 Time of last data modification.<br />

st_ctime time_t 40 Time of file creation.<br />

Return Values<br />

If the fstat() function completes successfully, it returns 0. Otherwise, fstat() sets errno to<br />

identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the fstat() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EBADF fildes is not a valid file descriptor.<br />

EFAULT The address stored in path or buf is invalid.<br />

5–60 7859 6137–009


fsync()<br />

Application<br />

fsync()<br />

Use the fsync() function to write to the device all data currently in the buffer cache <strong>for</strong> a<br />

file, thus protecting the data against loss due to a system outage. With fsync(), an<br />

application can synchronize all file updates at one time, instead of on every read or write<br />

operation. The fsync() function also synchronizes file access times.<br />

For a similar function that does not synchronize file access times, see fdatasync(). For<br />

alternate methods of synchronizing disk data, see the discussions of the O_SYNC <strong>and</strong><br />

O_DSYNC flags under the open() <strong>and</strong> fcntl() functions.<br />

Synopsis<br />

int fsync(int fildes);<br />

Description<br />

The fsync() function writes from the buffer cache to the mass storage device all data<br />

belonging to the specified file, where fildes specifies a regular file open <strong>for</strong> writing.<br />

Return Values<br />

If the fsync() function completes successfully, it returns 0. Otherwise, fsync() sets errno<br />

to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the fsync() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

EINVAL Data synchronization is not supported <strong>for</strong> the type of file<br />

described by fildes.<br />

EIO The file could not be fully synchronized because of an I/O<br />

error.<br />

7859 6137–009 5–61


ftell()<br />

ftell()<br />

Application<br />

Use the ftell() function to obtain the current value of the file position indicator <strong>for</strong> a<br />

stream.<br />

Synopsis<br />

long ftell(FILE * stream);<br />

Description<br />

The ftell() function obtains the current value in bytes of the file position indicator <strong>for</strong> a<br />

stream, relative to the beginning of the file, where:<br />

FILE<br />

stream<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object.<br />

Return Values<br />

The ftell() function returns the current value of the file position indicator <strong>for</strong> the stream,<br />

relative to the beginning of the file.<br />

5–62 7859 6137–009


ftruncate()<br />

Application<br />

The ftruncate() function sets the end-of-file position <strong>for</strong> an open file.<br />

Synopsis<br />

int ftruncate(int fildes, off_t length);<br />

Description<br />

ftruncate()<br />

A file referenced by the descriptor fildes has its size (in bytes) set to length. If the file<br />

was previously longer than the length specified, those bytes are no longer accessible. If<br />

the file was previously shorter than the length specified, bytes between the old<br />

end-of-file <strong>and</strong> the specified length are read as zeroes. For ftruncate(), the calling<br />

program must have the file open <strong>for</strong> writing.<br />

For files stored in SDF <strong>for</strong>mat, the length value of 34359738367 (defined as INT_MAX in<br />

the limits.h header file) has special meaning. <strong>CIFS</strong> treats this as an indication that it must<br />

recalculate the actual size of the file when it is next read based on the position of the<br />

EOF record, rather than pad the file with zeroes.<br />

Return Values<br />

Upon successful completion, the function returns a value of 0. If unsuccessful, it returns<br />

a value of -1 <strong>and</strong> sets errno to the appropriate value.<br />

7859 6137–009 5–63


fwrite()<br />

fwrite()<br />

Application<br />

Use the fwrite() function to write elements from an array to an output stream.<br />

Synopsis<br />

size_t fwrite(const void * ptr, size_t size, size_t nelem, FILE * stream);<br />

Description<br />

The fwrite() function writes elements from an array to an output stream, where:<br />

ptr<br />

size<br />

nelem<br />

FILE<br />

stream<br />

is a pointer to the array.<br />

specifies the size of an element in the array.<br />

specifies the number of elements to write.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> output.<br />

The fwrite() function advances the file position indicator by the number of bytes<br />

successfully written. If an error occurs, the resulting value of the file position indicator is<br />

indeterminate.<br />

Return Values<br />

If it completes successfully, the fwrite() function returns the number of elements<br />

written; this number is less than nelem only if a write error occurs.<br />

5–64 7859 6137–009


getc()<br />

Application<br />

Use the getc() function to obtain the next character from an input stream.<br />

Synopsis<br />

int getc(FILE * stream);<br />

Description<br />

The getc() function is equivalent to fgetc().<br />

Return Values<br />

The getc() function returns the next character from the specified input stream. If the<br />

stream is at end of file, getc() sets the end-of-file indicator <strong>and</strong> returns EOF. If a read<br />

error occurs, getc() sets the error indicator <strong>and</strong> returns EOF.<br />

getc()<br />

7859 6137–009 5–65


getchar()<br />

getchar()<br />

Application<br />

Use the getchar() function to obtain the next character from st<strong>and</strong>ard input.<br />

Synopsis<br />

int getchar();<br />

Description<br />

The getchar() function is equivalent to calling getc() with the argument stdin (st<strong>and</strong>ard<br />

input).<br />

Return Values<br />

The getchar() function returns the next character from st<strong>and</strong>ard input. If st<strong>and</strong>ard input is<br />

at end of file, getchar() sets the end-of-file indicator <strong>and</strong> returns EOF. If a read error<br />

occurs, getchar() sets the error indicator <strong>and</strong> returns EOF.<br />

5–66 7859 6137–009


getcwd()<br />

Application<br />

Use the getcwd() function to identify a process' current working directory. You can<br />

specify where the in<strong>for</strong>mation is returned.<br />

Synopsis<br />

char * getcwd(char * path, size_t size);<br />

Description<br />

getcwd()<br />

The getcwd() function identifies the absolute path name of the current working directory<br />

of the calling process, where:<br />

path<br />

size<br />

is a pointer to the path name; it is one of the following:<br />

• A pointer to a character array of length size<br />

The getcwd() function returns the path name of the current working directory in<br />

path.<br />

• A null pointer<br />

The getcwd() function puts the path name of the current working directory in<br />

allocated storage. getcwd() calls malloc(size) to get the storage. You can use the<br />

free() function to release the storage when it is no longer needed.<br />

is the size in bytes of the character array to which path points. If the path name of<br />

the working directory has more characters in it than size allows, an error occurs.<br />

Return Values<br />

If the getcwd() function completes successfully, it returns a pointer to the absolute path<br />

name <strong>for</strong> the current working directory. Otherwise, getcwd() sets errno to identify the<br />

specific error <strong>and</strong> returns a null pointer.<br />

Error Codes<br />

If any of the following conditions occurs, the getcwd() function returns a null pointer <strong>and</strong><br />

sets errno to the corresponding value:<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL size is less than or equal to 0.<br />

ENOMEM The pointer specified by path is null <strong>and</strong> no<br />

memory space is available to the process.<br />

ERANGE size is greater than 0 but less than the<br />

length of the path name plus 1.<br />

7859 6137–009 5–67


getpwnam()<br />

getpwnam()<br />

Application<br />

Use the getpwnam() function to retrieve the numeric identifier <strong>for</strong> a user, given the user<br />

name.<br />

Synopsis<br />

struct passwd * getpwname(const char * name);<br />

Description<br />

The getpwnam() function retrieves in<strong>for</strong>mation about a <strong>CIFS</strong> user, based on the supplied<br />

user name. The in<strong>for</strong>mation is returned in a passwd structure located in a static data area<br />

that each call to getpwnam() overwrites.<br />

Note: getpwnam() is not case sensitive.<br />

Return Values<br />

If the getpwnam() function completes successfully, it returns a pointer to the passwd<br />

structure <strong>for</strong> the specified user name. Otherwise, getpwnam() sets errno to identify the<br />

specific error <strong>and</strong> returns a null pointer.<br />

Error Codes<br />

If any of the following conditions occurs, the getpwnam() function returns a null pointer<br />

<strong>and</strong> sets errno to the corresponding value:<br />

EFAULT Detected an invalid address in an argument of a function<br />

call.<br />

EINVAL name contains an invalid character.<br />

EIO An I/O error prevented successful completion.<br />

ENAMETOOLONG name exceeds 12 characters in length, not counting the<br />

trailing nul character.<br />

ENOENT One of the following errors occurred:<br />

• name is a null string.<br />

• The specified user name is not known to <strong>CIFS</strong>.<br />

5–68 7859 6137–009


getpwuid()<br />

Application<br />

getpwuid()<br />

Use the getpwuid() function to retrieve the symbolic name <strong>for</strong> a user, given the numeric<br />

user identifier.<br />

Synopsis<br />

struct passwd * getpwuid(uid_t uid);<br />

Description<br />

The getpwuid() function retrieves in<strong>for</strong>mation about a <strong>CIFS</strong> user, based on the supplied<br />

numeric identifier. The in<strong>for</strong>mation is returned in a passwd structure located in a static<br />

data area that each call to getpwuid() overwrites.<br />

The passwd Structure<br />

The passwd structure passes in<strong>for</strong>mation about <strong>CIFS</strong> users. Functions that create,<br />

modify, <strong>and</strong> inspect user in<strong>for</strong>mation use the passwd structure. The following table<br />

describes struct passwd, which is defined in .<br />

Member<br />

Name<br />

Member<br />

Type Description<br />

pw_name char * A pointer to the user ID name (the <strong>OS</strong> <strong>2200</strong> user ID). The user<br />

name is one of the following:<br />

• The generic user ID name cifs_generic<br />

• to 12 lowercase characters, excluding the terminating nul<br />

character, where each character is one of the following:<br />

− letter<br />

− digit<br />

− period (.)<br />

− minus sign (-)<br />

− dollar sign ($)<br />

pw_uid uid_t The numeric user ID associated with the user, assigned by <strong>CIFS</strong>.<br />

Note: Other fields in the password structure are reserved <strong>for</strong> internal use by <strong>CIFS</strong>.<br />

Return Values<br />

If the getpwuid() function completes successfully, it returns a pointer to the passwd<br />

structure <strong>for</strong> the specified user name. Otherwise, getpwuid() sets errno to identify the<br />

specific error <strong>and</strong> returns a null pointer.<br />

7859 6137–009 5–69


getpwuid()<br />

Error Codes<br />

If any of the following conditions occurs, the getpwuid() function returns a null pointer<br />

<strong>and</strong> sets errno to the corresponding value:<br />

EINVAL The user ID specified in uid is outside the range known to <strong>CIFS</strong>.<br />

Valid uid values are greater than zero <strong>and</strong> less than the current<br />

highest one registered with <strong>CIFS</strong>.<br />

EIO An I/O error prevented successful completion.<br />

ENOENT A user with the numeric user ID value of uid is not known to<br />

<strong>CIFS</strong>.<br />

5–70 7859 6137–009


gets()<br />

Application<br />

Use the gets() function to read a string of characters from st<strong>and</strong>ard input into an array.<br />

Synopsis<br />

char * gets(char * s);<br />

Description<br />

gets()<br />

The gets() function reads characters from the st<strong>and</strong>ard input stream (stdin) into the array<br />

to which s points, until it encounters the end of the file or a newline character. gets()<br />

discards any newline character <strong>and</strong> writes a nul character immediately after the last<br />

character in the array.<br />

Return Values<br />

If it completes successfully, the gets() function returns the array s. If gets() encounters<br />

end of file be<strong>for</strong>e reading any characters into the array, the contents of the array remain<br />

unchanged <strong>and</strong> gets() returns a null pointer. If a read error occurs, the contents of the<br />

array are indeterminate <strong>and</strong> gets() returns a null pointer.<br />

7859 6137–009 5–71


getuid()<br />

getuid()<br />

Application<br />

Use the getuid() function to retrieve the numeric user ID of the current process.<br />

Synopsis<br />

uid_t getuid();<br />

Description<br />

The getuid() function retrieves the user ID value <strong>for</strong> the currently executing process. All<br />

threads of a process share the same numeric user ID.<br />

Return Values<br />

The getuid() function returns –1 <strong>and</strong> sets errno if the function fails; otherwise, it returns<br />

the <strong>CIFS</strong> user ID number <strong>for</strong> the current process.<br />

5–72 7859 6137–009


istat()<br />

Application<br />

Use the istat() function to retrieve <strong>CIFS</strong>-unique in<strong>for</strong>mation about a file or directory.<br />

Synopsis<br />

int istat(ino_t ino, struct _istat * ibuf, size_t size);<br />

Description<br />

istat()<br />

If ino corresponds to a valid file serial number, the function places up to size bytes of the<br />

following in<strong>for</strong>mation into the ibuf area. The ino argument is typically obtained from the<br />

st_ino field of the stat structure returned by a stat() or fstat() function.<br />

Field Name Type Offset Description<br />

st_cycle int 0 <strong>OS</strong> <strong>2200</strong> absolute F-cycle of this<br />

file.<br />

st_cycle_chain ino_t 4 Inode number of the next <strong>OS</strong> <strong>2200</strong><br />

F-cycle of this same file name.<br />

st_alt_os_dir_ino ino_t 8 Inode number of the alternate<br />

<strong>OS</strong> <strong>2200</strong> directory version of this<br />

file name.<br />

st_os<strong>2200</strong> int 12 Indicates where a directory inode<br />

appears in the /os<strong>2200</strong> hierarchy.<br />

Can contain the following values:<br />

0 Not in the /os<strong>2200</strong> hierarchy<br />

1 The /os<strong>2200</strong> directory<br />

2 An immediate subdirectory<br />

(qualifier) of /os<strong>2200</strong><br />

3 A program or data file in the<br />

/os<strong>2200</strong> hierarchy<br />

st_owner[13] char 16 Owner of the file. For owned files,<br />

this is the <strong>OS</strong> <strong>2200</strong> user ID. For<br />

unowned files, this is the project or<br />

account, depending on the value of<br />

the configuration variable PRIVAC.<br />

st_directory[7] char 29 The <strong>OS</strong> <strong>2200</strong> MFD containing this<br />

file; either STD or SHARED.<br />

st_contain[38] char 36 For regular files, the name of the<br />

underlying <strong>OS</strong> <strong>2200</strong> file container.<br />

The field contains a null string <strong>for</strong><br />

other file types.<br />

7859 6137–009 5–73


istat()<br />

Field Name Type Offset Description<br />

st_element_name[13] char 74 The element name associated with<br />

the file; null string if the file is not<br />

stored as an <strong>OS</strong> <strong>2200</strong> element.<br />

st_element_version[1<br />

3]<br />

st_element_type short<br />

int<br />

st_element_sub_type short<br />

int<br />

char 87 The element version associated<br />

with the file; not used if the file is<br />

not stored as an <strong>OS</strong> <strong>2200</strong> element.<br />

100 The type of the underlying<br />

element, either 1, 5, 6, or 7. Not<br />

used if the file is not stored as an<br />

<strong>OS</strong> <strong>2200</strong> element.<br />

102 The subtype of the underlying<br />

symbolic or omnibus element; not<br />

used <strong>for</strong> other element types or if<br />

the file is not stored as an <strong>OS</strong> <strong>2200</strong><br />

element.<br />

st_share[32] char 104 For directories, the network share<br />

name assigned to it; a null string if<br />

the directory is not shared.<br />

st_acr[8] char 136 The ACR name associated with a<br />

file.<br />

The size of struct_istat is 144 bytes. The data is stored in the order listed; whatever does<br />

not fit in size bytes is discarded.<br />

Return Values<br />

If successful, the function returns zero; if an error is encountered, it returns -1 <strong>and</strong> sets<br />

errno to an appropriate value.<br />

5–74 7859 6137–009


link()<br />

Application<br />

link()<br />

Use the link() function to create new directory entries <strong>for</strong> a file, allowing you to reference<br />

one file in multiple ways. The new entries can be in the same directory or in different<br />

directories.<br />

link() increases the link count of the referenced file by 1.<br />

Synopsis<br />

int link(const char * path1, const char * path2);<br />

Description<br />

The link() function creates a new directory entry (link), provided the process has the<br />

necessary permissions (see “Permissions Required” in this subsection), where:<br />

path1<br />

path2<br />

is a pointer to the name of an existing regular or FIFO file.<br />

is a pointer to the path name <strong>for</strong> the new link <strong>for</strong> the file named by path1. The<br />

directory in which the new link is created must be in the same file system as path1.<br />

Diagrams<br />

The link() function causes both directory entries to refer to the same physical file. In the<br />

following diagrams, both link_1 <strong>and</strong> link_2 refer to the same file, whether they are in the<br />

same directory or not.<br />

link ("/dir_1/link_1", "/dir_2/link_2")<br />

dir_1<br />

link_1<br />

7859 6137–009 5–75<br />

file<br />

dir_2<br />

link_2


link()<br />

Permissions Required<br />

The calling process must have all the following permissions to create the link:<br />

• Search permission <strong>for</strong> all the path1 component directories<br />

• Search permission <strong>for</strong> all the path2 component directories<br />

• Write permission to the parent directory of the new file<br />

Return Values<br />

If the link() function completes successfully, it does the following:<br />

• Updates the st_atime field of the path1 file<br />

• Updates the st_mtime field of the path2 directory<br />

• Returns 0<br />

Otherwise, link() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the link() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a component of<br />

either path name.<br />

• The calling process is denied write permission to the path2 directory.<br />

EEXIST The link named by path2 already exists.<br />

EFAULT The pointer specified by path1 or path2 is invalid.<br />

EIO An I/O error occurred.<br />

link ("/dir_1/link_1", "/dir_1/link_2")<br />

dir_1<br />

link_1<br />

link_2<br />

EMLINK The number of links to the file named by path1 exceeds the C st<strong>and</strong>ard<br />

value INT_MAX.<br />

ENOENT Any of the following errors occurred:<br />

• A directory in either path name does not exist.<br />

• The file in path1 does not exist.<br />

• Either path1 or path2 points to an empty string.<br />

5–76 7859 6137–009<br />

file


EN<strong>OS</strong>PC The path2 directory to contain the link has too many entries.<br />

ENOTDIR A component of either path name prefix is not a directory.<br />

EPERM The file named by path1 is a directory or a character file.<br />

link()<br />

7859 6137–009 5–77


lseek()<br />

lseek()<br />

Application<br />

Use the lseek() function to set the read/write offset <strong>for</strong> an open file at a specific position<br />

in the file. You can also set the read/write offset beyond the end of existing data in the<br />

file without increasing the file size; however, a write operation at that location increases<br />

the file size.<br />

Definition<br />

The read/write offset is the file address at which the next read() or write() operation<br />

starts.<br />

Synopsis<br />

off_t lseek(int fildes, off_t offset, int whence);<br />

Description<br />

The lseek() function sets the read/write offset <strong>for</strong> an open file description, where:<br />

fildes<br />

offset<br />

is a file descriptor.<br />

specifies the new location of the read/write offset from the beginning, current<br />

position, or end of a file, as shown in the following table <strong>and</strong> diagram.<br />

whence<br />

specifies whether the read/write offset is calculated from the beginning, current<br />

position, or end of a file. See the following table <strong>and</strong> diagram <strong>for</strong> the valid values <strong>for</strong><br />

whence <strong>and</strong> their relationships to offset.<br />

Value of<br />

whence<br />

How the Read/Write Offset Is<br />

Calculated<br />

SEEK_CUR* Current offset value plus offset bytes<br />

SEEK_END* Size of the file plus offset bytes<br />

SEEK_SET* offset bytes from the beginning of the<br />

file<br />

*Defined in <br />

5–78 7859 6137–009


Illustration<br />

lseek()<br />

Given a value <strong>for</strong> offset, the value of whence determines whether the read/write offset<br />

occurs at the beginning, current position, or end of a file. The following diagram shows<br />

the possible new positions of the read/write offset:<br />

Beginning<br />

of File<br />

Reading Unwritten Areas<br />

If a file contains unwritten gaps, reading these areas returns bytes with the value 0.<br />

However, files created outside of <strong>CIFS</strong> can contain unwritten data that is not detectable;<br />

reading these areas returns bytes with indeterminate values.<br />

Function Behavior <strong>for</strong> Different File Types<br />

All calls to lseek() fail <strong>for</strong> the following file types:<br />

• Pipes<br />

1<br />

2<br />

3<br />

offset<br />

• FIFO files<br />

For some types of files, a read/write offset is not meaningful; <strong>for</strong> these files, the<br />

read/write offset returned by lseek() is undefined.<br />

Portability Issue<br />

In other implementations, the return type off_t can be unsigned. To test <strong>for</strong> an error in a<br />

portable way, compare the result with (off_t)-1.<br />

Return Values<br />

whence = SEEK_END<br />

Current<br />

Position<br />

End<br />

of File<br />

offset offset<br />

1 2 3<br />

whence = SEEK_SET<br />

whence = SEEK_CUR<br />

If the lseek() function completes successfully, it returns the new read/write offset<br />

location in bytes from the beginning of the file. Otherwise, lseek() sets errno to identify<br />

the specific error <strong>and</strong> returns the cast value (off_t)-1.<br />

7859 6137–009 5–79


lseek()<br />

Error Codes<br />

If any of the following conditions occurs, the lseek() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EBADF fildes is not a valid file descriptor.<br />

EINVAL One of the following errors occurred:<br />

• whence is invalid.<br />

• The resulting read/write offset would be<br />

invalid (that is, negative).<br />

ESPIPE fildes is associated with a pipe or FIFO file.<br />

5–80 7859 6137–009


mask()<br />

Application<br />

mask()<br />

Use the _cifs_mask() function to determine whether or not a given string matches a wild<br />

card pattern.<br />

Note: There is no P<strong>OS</strong>IX equivalent to _cifs_mask().<br />

Synopsis<br />

boolean_t _cifs_mask(const char * name, const char * mask);<br />

Description<br />

The _cifs_mask() function checks the name parameter <strong>for</strong> con<strong>for</strong>mance with the mask<br />

parameter. The mask parameter may contain the wild card characters asterisk (*) <strong>and</strong><br />

question mark (?). A question mark matches a single occurrence of any character; an<br />

asterisk matches zero or more occurrences of any character. Other characters in mask<br />

must be a case-insensitive match to ones in the corresponding positions of name in<br />

order <strong>for</strong> the function to return a TRUE result. For example, the name “abcdef”<br />

con<strong>for</strong>ms to “abc*” <strong>and</strong> “aBc???”, but not to “abc?” Wild card characters may be mixed<br />

in any order <strong>and</strong> with any other characters.<br />

Return Values<br />

The _cifs_mask() function returns TRUE if name con<strong>for</strong>ms to mask, FALSE if it does not.<br />

7859 6137–009 5–81


mkdir()<br />

mkdir()<br />

Application<br />

Use the mkdir() function to create a new directory, setting its file permissions <strong>and</strong><br />

security attributes. The directory is empty except <strong>for</strong> its dot <strong>and</strong> dot-dot entries. Once<br />

the directory is created, you can make directory entries.<br />

Synopsis<br />

int mkdir(const char * path, mode_t mode);<br />

Description<br />

The mkdir() function creates a directory containing only the dot <strong>and</strong> dot-dot entries,<br />

where:<br />

path<br />

mode<br />

is a pointer to the new directory.<br />

contains the settings <strong>for</strong> file permissions <strong>for</strong> the new directory, which are first<br />

modified by the file mode creation mask of the calling process. In addition to the<br />

permission bits, you can specify the creation of a Large Element Program File<br />

(LEPF). The LEPF setting is specified by using the S_LEPF constant, <strong>and</strong> a normal<br />

program file by S_NPF.<br />

File Mode Attributes<br />

The mkdir() function also sets the following attributes in the file mode <strong>for</strong> the directory:<br />

• The user ID of the new directory to the effective user ID of the calling process<br />

• The group ID of the new directory, to the effective group ID of the process<br />

Return Values<br />

If the mkdir() function completes successfully, it does the following:<br />

• Sets the file permissions, user ID, <strong>and</strong> group ID <strong>for</strong> the new directory, as discussed<br />

in the preceding paragraphs<br />

• Sets the st_atime, st_ctime, <strong>and</strong> st_mtime fields of the new directory<br />

• Updates the st_atime <strong>and</strong> st_mtime fields of the parent directory<br />

• Returns 0<br />

Otherwise, mkdir() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

5–82 7859 6137–009


Error Codes<br />

mkdir()<br />

If any of the following conditions occurs, the mkdir() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES The calling process is denied one of the following:<br />

• Search permission to a directory in the path name<br />

• Write permission on the parent directory of the new directory<br />

EEXIST A directory with the same path name already exists.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL mode has undefined bits set.<br />

EMLINK The link count of the parent directory exceeds the C st<strong>and</strong>ard value<br />

INT_MAX.<br />

ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not exist.<br />

• path points to an empty string.<br />

EN<strong>OS</strong>PC Either of the following errors occurred:<br />

• The parent directory has too many entries.<br />

• The file system does not have enough space to hold the new<br />

directory.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

7859 6137–009 5–83


mkfifo()<br />

mkfifo()<br />

Application<br />

Use the mkfifo() function to create a new first-in-first-out (FIFO) file, setting its file<br />

permissions <strong>and</strong> security attributes. The new FIFO is empty.<br />

Synopsis<br />

int mkfifo(const char * path, mode_t mode);<br />

Description<br />

The mkfifo() function creates a FIFO file, where:<br />

path<br />

mode<br />

is a pointer to the name of the new FIFO file.<br />

contains the file permission settings <strong>for</strong> the new FIFO file, which are first modified<br />

by the file mode creation mask of the calling process.<br />

File Mode Attributes<br />

The mkfifo() function also sets the following attributes in the file mode:<br />

• The user ID of the new FIFO file to the effective user ID of the calling process<br />

• The group ID of the new FIFO file to the effective group-ID of the process<br />

Return Values<br />

If the mkfifo() function completes successfully, it does the following:<br />

• Sets the file permissions, user ID, <strong>and</strong> group ID <strong>for</strong> the new FIFO file, as discussed<br />

in the preceding paragraphs<br />

• Sets the st_atime, st_ctime, <strong>and</strong> st_mtime fields of the new FIFO file<br />

• Updates the st_atime <strong>and</strong> st_mtime fields of the parent directory<br />

• Returns 0<br />

Otherwise, mkfifo() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

5–84 7859 6137–009


Error Codes<br />

mkfifo()<br />

If any of the following conditions occurs, the mkfifo() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EACCES The calling process is denied one of the following:<br />

• Search permission to a component of the path name<br />

• Write permission to the parent directory of the new<br />

file<br />

EEXIST A file with the same path name already exists.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL mode has bits set that are either undefined or not file<br />

permission bits.<br />

ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not exist.<br />

• path points to an empty string.<br />

EN<strong>OS</strong>PC Either of the following errors occurred:<br />

• The parent directory has too many entries.<br />

• The file system does not have enough resources <strong>for</strong><br />

file allocation.<br />

ENOTDIR A component of the path prefix is not a directory.<br />

EROFS The parent directory exists on a read-only file system.<br />

7859 6137–009 5–85


new_process()<br />

new_process()<br />

Application<br />

Use _cifs_new_process (<strong>and</strong> _cifs_end_process) to group activities into logical<br />

processes, where all activities (threads) of a process share a set of open files.<br />

Note: There is no P<strong>OS</strong>IX equivalent to _cifs_new_process.<br />

Synopsis<br />

int _cifs_new_process();<br />

Description<br />

All threads (<strong>OS</strong> <strong>2200</strong> activities) of a program making use of <strong>CIFS</strong> services normally share<br />

open file descriptors <strong>and</strong> a current directory setting. This collection of file in<strong>for</strong>mation <strong>and</strong><br />

the threads that share it is known as a process. If a program needs separate sets of file<br />

descriptors, or multiple current directories, it can use the _cifs_new_process() function to<br />

create additional processes. The thread that invokes _cifs_new_process() becomes the<br />

first thread <strong>for</strong> the new process. A thread spawned by another thread (using the<br />

tskstart() function in the UCS Runtime System library) always belongs to the same<br />

process as the spawning thread, <strong>and</strong> may not change that association other than by<br />

creating a new process.<br />

When _cifs_new_process() is invoked, the new process starts with copies of all open file<br />

descriptors (except those marked with FD_CLOEXEC by the F_SETFD comm<strong>and</strong> of the<br />

fcntl() function) <strong>and</strong> the current directory setting of the process to which the invoking<br />

thread previously belonged. Subsequent open(), close(), etc., requests have no effect on<br />

any other process of the program.<br />

The _cifs_end_process() function can be used to in<strong>for</strong>m <strong>CIFS</strong> that its services are no<br />

longer required by the set of threads making up the process. This happens automatically<br />

when all threads of a process terminate, but can be <strong>for</strong>ced at an earlier time if desired by<br />

program logic.<br />

Return Values<br />

Returns a value of zero if successful <strong>and</strong> a value -1 if any errors are detected (with errno<br />

set to the appropriate value).<br />

5–86 7859 6137–009


open()<br />

Application<br />

open()<br />

Use the open() function to open a file, specifying how you can access the file <strong>and</strong> setting<br />

special attributes. Opening a file does the following:<br />

• Creates an open file description <strong>and</strong> corresponding file descriptor <strong>for</strong> this unique<br />

instance of the open file.<br />

Note: The new open file description is not shared by any other process on the<br />

system; the file descriptor identifies this open file description only.<br />

• Can create the file, if it does not already exist. In this case, you must also specify the<br />

file permissions <strong>for</strong> the file mode. See also the creat() function.<br />

Synopsis<br />

int open(const char * path, int oflag[, mode_t mode]);<br />

Description<br />

The open() function opens a file, where:<br />

path<br />

oflag<br />

mode<br />

is a pointer to the name of the file to be opened.<br />

sets the access specification <strong>and</strong> file status flags in the open file description. See<br />

“The oflag Argument” in a following subsection <strong>for</strong> the valid values <strong>for</strong> oflag.<br />

is an optional argument of type mode_t that sets the file permissions when a new<br />

file is created (see the file status flag O_CREAT). See “The mode Argument” in a<br />

following subsection <strong>for</strong> the valid values <strong>for</strong> mode.<br />

Results of Opening a File<br />

The open() function does the following:<br />

1. Sets the initial read/write offset to the start of the file<br />

2. Selects the numerically lowest available file descriptor <strong>for</strong> the process<br />

3. Returns the file descriptor so that other I/O functions can access the file<br />

7859 6137–009 5–87


open()<br />

Example<br />

The following code statement opens a file that does not currently exist:<br />

fd_inventory = open("/books/novels/f inventory", O_CREAT | O_RDWR,<br />

S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP);<br />

The statement does the following tasks:<br />

• Creates the file f_inventory in the directory /books/novels<br />

• Opens the file <strong>for</strong> reading <strong>and</strong> writing<br />

• Assigns read <strong>and</strong> write permission <strong>for</strong> the owner <strong>and</strong> group classes<br />

• Captures the file descriptor returned by open() in fd_inventory<br />

The following code shows an alternate solution <strong>for</strong> this example. It has the advantage of<br />

declaring variables with specific values that can be used in other open operations.<br />

int oflags = O_CREAT | O_RDWR;<br />

int perms = S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;<br />

fd_inventory = open("/books/novels/f_inventory", oflags, perms);<br />

Files Affected by open()<br />

A process must open a file be<strong>for</strong>e reading from or writing to it. The open() function<br />

opens the following types of files:<br />

• Regular files<br />

• FIFO files<br />

• Directories (<strong>for</strong> reading only)<br />

Note: The open() function can also create a regular file if it does not exist. The other<br />

types of files must exist be<strong>for</strong>e open() can access them.<br />

Return Values<br />

If the open() function completes successfully, it does the following:<br />

• Updates the following time in<strong>for</strong>mation fields if O_CREAT is set <strong>and</strong> the file does not<br />

exist:<br />

− The st_atime, st_ctime, <strong>and</strong> st_mtime fields <strong>for</strong> the file<br />

− The st_atime <strong>and</strong> st_mtime fields <strong>for</strong> the parent directory<br />

• Updates the st_atime <strong>and</strong> st_mtime time in<strong>for</strong>mation fields <strong>for</strong> the file if O_TRUNC is<br />

set <strong>for</strong> an existing file<br />

• Returns the file descriptor<br />

Otherwise, open() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

5–88 7859 6137–009


Error Codes<br />

open()<br />

If any of the following conditions occur, the open() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES Any of the following access errors occurred:<br />

• The calling process is denied search permission on one or more<br />

directories in path.<br />

• The file exists <strong>and</strong> the permissions specified by oflag are<br />

denied.<br />

• The file does not exist <strong>and</strong> write permission is denied <strong>for</strong> the<br />

parent directory of the file to be created.<br />

• O_TRUNC is specified <strong>and</strong> write permission is denied.<br />

EAGAIN A resource is temporarily unavailable. Either the calling process<br />

attempted to open a file that was rolled out with O_NONBLOCK<br />

set, or the wait time specified by the <strong>CIFS</strong>$WAITROLBAK<br />

environment variable expired. This is a temporary condition <strong>and</strong> a<br />

subsequent call might complete normally.<br />

EBUSY A resource is temporarily unavailable. Either the calling process<br />

attempted to open a file that was exclusively assigned with<br />

O_NONBLOCK set, or the wait time specified by the<br />

<strong>CIFS</strong>$WAITXUSE environment variable expired. This is a temporary<br />

condition <strong>and</strong> a subsequent call might complete normally.<br />

EEXIST O_CREAT <strong>and</strong> O_EXCL are set <strong>and</strong> the file exists.<br />

EFAULT The pointer specified by path is invalid.<br />

EINTR The open() operation was interrupted by a signal.<br />

EINVAL Any of the following errors occurred:<br />

• O_CREAT is specified <strong>and</strong> mode is missing.<br />

• An open() function call with read-only access <strong>and</strong> O_TRUNC<br />

specified is not valid. The two options are incompatible.<br />

• oflag has neither the O_RDONLY, the O_WRONLY, nor the<br />

O_RDWR flags set. One of these flags must be set.<br />

• An open() function call with more than one of S_1100SDF <strong>and</strong><br />

S_1100BIN specified is not valid. A file cannot have more than<br />

one of these attributes.<br />

• An open() function call <strong>for</strong> a FIFO file with read/write access is<br />

not valid.<br />

• Either oflag or mode has undefined bits set.<br />

EIO An input/output error occurred.<br />

EISDIR The file is a directory <strong>and</strong> oflag specifies write access.<br />

EMFILE The calling process is attempting to open a file <strong>and</strong> the limit on the<br />

maximum number of open file descriptors <strong>for</strong> a process would be<br />

exceeded.<br />

7859 6137–009 5–89


open()<br />

ENOENT Either of the following errors occur:<br />

• O_CREAT is not set <strong>and</strong> the file does not exist.<br />

• O_CREAT is set <strong>and</strong> either<br />

− A directory in the path name does not exist.<br />

− path points to an empty string.<br />

EN<strong>OS</strong>PC The directory or file system that is to contain the new file is out of<br />

available space.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

ENXIO O_NONBLOCK <strong>and</strong> O_WRONLY are set <strong>for</strong> a FIFO file <strong>and</strong> no<br />

process has the file open <strong>for</strong> reading.<br />

The oflag Argument<br />

The oflag argument is the bitwise inclusive OR operation of the following values:<br />

• An access specification value<br />

• Any combination of values <strong>for</strong> file status flags<br />

Access Specification Values<br />

The following symbolic constants are valid access specifications:<br />

O_RDONLY Open the file <strong>for</strong> reading only.<br />

O_WRONLY Open the file <strong>for</strong> writing only.<br />

O_RDWR Open the file <strong>for</strong> reading <strong>and</strong> writing. (This is the same as<br />

specifying both O_RDONLY <strong>and</strong> O_WRONLY.)<br />

File Status Flag Values<br />

The following symbolic constants are valid file status flags:<br />

O_APPEND The read/write offset is set to the end of the file be<strong>for</strong>e each write<br />

operation.<br />

O_CREAT The open() function<br />

• Creates a regular file with path as its path name<br />

• Sets ownership of the regular file, as follows:<br />

− Sets the user ID of the file to the effective user ID of the process<br />

− Sets the group ID of the file to the effective group ID of the<br />

process<br />

When O_CREAT is set, open() requires a third argument, mode, of type<br />

mode_t. The file permission attributes are set to the value in mode minus<br />

the attributes set in the process' file mode creation mask (see the<br />

umask() function). The mode argument does not affect whether the file is<br />

opened <strong>for</strong> read or write access or both.<br />

O_DSYNC The open() function opens the file <strong>for</strong> synchronized read <strong>and</strong> write<br />

operations.<br />

5–90 7859 6137–009


open()<br />

The kernel implements a buffering system <strong>for</strong> the file data in volatile<br />

storage. I/O buffering increases the speed at which data can be accessed<br />

<strong>and</strong> changed, but it also increases the risk of lost data due to a system<br />

failure. When file I/O operations are not synchronized, it is possible <strong>for</strong> file<br />

data to reside in volatile storage <strong>for</strong> some period of time without being<br />

written to a disk device.<br />

Setting the O_DSYNC flag<br />

• Causes any data written through the file descriptor to also be written<br />

to the disk device be<strong>for</strong>e the write() function returns<br />

• Ensures that any data read from a file descriptor is written to the disk<br />

device be<strong>for</strong>e the read() function returns that data<br />

O_EXCL Use O_EXCL with O_CREAT to ensure that the file does not already exist,<br />

as follows:<br />

If O_EXCL is ... And O_CREAT is ... Then ...<br />

Set Set open() fails if the file exists.<br />

Set Not set open() ignores O_EXCL.<br />

Not set Set open() opens the file if it already exists;<br />

otherwise, open() creates the file.<br />

Not set Not set open() opens the file if it already exists;<br />

otherwise, open() fails.<br />

O_NONBLOCK This value determines whether open() waits <strong>for</strong> certain file<br />

availability or fails, as follows:<br />

If O_NONBLOCK is ...<br />

And the file type<br />

is ... Then...<br />

Set Regular open() fails if the <strong>OS</strong> <strong>2200</strong> file<br />

container is rolled out or otherwise<br />

temporarily unavailable.<br />

Set FIFO For read-only access, open() returns<br />

without a delay.<br />

For write-only access, open() fails if no<br />

process has the file open <strong>for</strong> reading.<br />

7859 6137–009 5–91


open()<br />

If O_NONBLOCK is ...<br />

And the file type<br />

is ... Then...<br />

Not set Regular The process waits if the <strong>OS</strong> <strong>2200</strong> file<br />

container is rolled out or exclusively<br />

assigned. The maximum wait time can<br />

be specified by the<br />

<strong>CIFS</strong>$WAITROLBAK <strong>and</strong><br />

<strong>CIFS</strong>$WAITXUSE environment<br />

variables.<br />

Not set FIFO For read-only access, open() waits until<br />

a process opens the file <strong>for</strong> writing.<br />

For write-only access, open() waits<br />

until a process opens the file <strong>for</strong><br />

reading.<br />

O_NONBLOCK This has no effect when opening any other type of file.<br />

O_SYNC This value has the same effect as O_DSYNC, with the addition<br />

of ensuring that file access times are updated on the disk device<br />

be<strong>for</strong>e returning from read() or write() requests on the file<br />

descriptor. Setting both O_SYNC <strong>and</strong> O_DSYNC has the same<br />

effect as setting only O_SYNC.<br />

O_TRUNC This value truncates the file length to zero, leaving the file mode<br />

<strong>and</strong> file owner unchanged. This affects only a regular file opened<br />

with write-only or read/write access. A call to open() with readonly<br />

access <strong>and</strong> O_TRUNC set returns an error.<br />

5–92 7859 6137–009


The mode Argument<br />

The mode argument is type mode_t. It is the bitwise inclusive OR operation of the<br />

following attributes <strong>for</strong> a newly created file (see Section 3 <strong>for</strong> a discussion of the<br />

attributes in the file mode):<br />

• File permission attributes<br />

Permission<br />

Class<br />

Read Write<br />

Permission Attributes<br />

Search/<br />

Execute<br />

open()<br />

Read/Write/<br />

Search/Execute<br />

Owner S_IRUSR S_IWUSR S_IXUSR S_IRWXU<br />

Group S_IRGRP S_IWGRP S_IXGRP S_IRWXG<br />

Other S_IROTH S_IWOTH S_IXOTH S_IRWXO<br />

• File <strong>for</strong>mat attributes<br />

− Binary <strong>for</strong>mat: S_1100BIN<br />

− System data <strong>for</strong>mat (SDF): S_1100SDF<br />

7859 6137–009 5–93


opendir()<br />

opendir()<br />

Application<br />

Use the opendir() function to open a directory stream, making it accessible to the calling<br />

process at the first directory entry. You must first open a directory stream be<strong>for</strong>e doing<br />

anything with it.<br />

See closedir() <strong>for</strong> closing an open directory, readdir() <strong>for</strong> reading the next directory entry,<br />

<strong>and</strong> rewinddir() <strong>for</strong> repositioning the stream at its beginning.<br />

Synopsis<br />

DIR * opendir(const char * dirname);<br />

Description<br />

The opendir() function opens a directory stream <strong>and</strong> positions the stream to the first<br />

directory entry, where dirname identifies the directory to open.<br />

Return Values<br />

If the opendir() function completes successfully, it returns a pointer to a directory stream.<br />

Otherwise, opendir() sets errno to identify the specific error <strong>and</strong> returns a null pointer.<br />

Error Codes<br />

If any of the following conditions occurs, the opendir() function returns a null pointer <strong>and</strong><br />

sets errno to the corresponding value:<br />

EACCES One of the following errors occurred:<br />

• Search permission is denied <strong>for</strong> a component of the path name<br />

prefix of dirname.<br />

• Read permission is denied <strong>for</strong> the directory itself.<br />

EFAULT dirname is not a valid pointer.<br />

EIO An I/O error occurred on a directory in the path name.<br />

EMFILE The calling process would exceed the maximum number of file<br />

descriptors allowed.<br />

ENOENT One of the following errors occurred:<br />

• The directory does not exist.<br />

• dirname is an empty string.<br />

ENOMEM Memory could not be allocated <strong>for</strong> the DIR object.<br />

ENOTDIR A component of dirname is not a directory.<br />

5–94 7859 6137–009


pack()<br />

Application<br />

pack()<br />

Use the pack() function to pack the underlying <strong>OS</strong> <strong>2200</strong> program files of <strong>CIFS</strong> directories.<br />

Synopsis<br />

int pack(const char *path);<br />

Description<br />

The pack() function packs the underlying <strong>OS</strong> <strong>2200</strong> program file of a <strong>CIFS</strong> file or directory.<br />

This recovers unused TOC space <strong>and</strong> file text space resulting from the program file<br />

having deleted elements. The action is directly analogous to a FURPUR @PACK. Any<br />

existing relocatable <strong>and</strong> PROC entry point tables will be preserved.<br />

Notes:<br />

• The pack operation requires <strong>CIFS</strong> to have exclusive use (@ASG,AX) of a file while it<br />

is being packed. The program file must not be assigned to any run or name section,<br />

including the run doing the pack() API call. (An EBUSY status is returned.)<br />

• Unlike the -pr option of the <strong>CIFS</strong>UT touch comm<strong>and</strong>, the pack () API does not have<br />

recursive capabilities. Only one program file can be packed <strong>for</strong> each API call. The<br />

<strong>CIFS</strong> pack is a safe pack; if the system in that goes down or an X-keyin to the run is<br />

done during the pack. The contents of the program file are preserved, except in<br />

extremely rare circumstances.<br />

path<br />

is a pointer to the path name of a file or directory<br />

Return Values<br />

pack() returns a zero value if any of the following conditions are true:<br />

• If it can pack the underlying program file.<br />

• If the pack is already packed.<br />

• If it is not able to pack productively.<br />

• If there is no underlying program file.<br />

If there is an error, then pack() returns a -1 <strong>and</strong> sets errno to an appropriate value.<br />

Error Codes<br />

The following are the possible errno values on an error return:<br />

EACCES Access to a file or directory is denied.<br />

EFAULT The path pointer caused a fault in <strong>CIFS</strong>, an IGDM.<br />

ENAMETOOLONG The path name length is too long.<br />

7859 6137–009 5–95


pack()<br />

ENOENT The named file or directory does not exist or <strong>CIFS</strong> could not<br />

assign the program file.<br />

ENOTDIR A component of the path prefix is not a directory.<br />

EPERM Access to a file or directory is denied.<br />

EBUSY The program file is rolled-out or assigned to someone else. <strong>CIFS</strong><br />

requires exclusive access to the file.<br />

ENONMEM Buffer space was unavailable.<br />

EIO An IO error occurred on the backing program file.<br />

E1100CORRUPT A basic error in the program file, such as the text <strong>for</strong> elements<br />

being out of order.<br />

E1100INTERNAL An internal error occurred in <strong>CIFS</strong>.<br />

5–96 7859 6137–009


perror()<br />

Application<br />

Use the perror() function to print a message corresponding to an error that occurred.<br />

Synopsis<br />

void perror(const char * s);<br />

Description<br />

perror()<br />

The perror() function associates the error number in errno with an error message <strong>and</strong><br />

writes a line to the st<strong>and</strong>ard error file, where a line is the message followed by a newline<br />

character.<br />

The argument s is a pointer to a string specified to precede the message. If s is not the<br />

null pointer <strong>and</strong> the character to which s points is not the nul character, perror() writes<br />

the following sequence be<strong>for</strong>e writing the message:<br />

1. The string to which s points<br />

2. A colon <strong>and</strong> a space<br />

The contents of the error message strings are the same as those returned by a call to<br />

strerror () with the argument errno.<br />

Return Values<br />

The perror() function returns no value.<br />

7859 6137–009 5–97


pipe()<br />

pipe()<br />

Application<br />

Use the pipe() function to create a pipe to transmit data between processes. Pipes are<br />

temporary entities that help processes communicate with each other. Pipes have a<br />

”read end” <strong>and</strong> a ”write end,” which are located by file descriptors returned by pipe().<br />

When using a pipe, one process writes data to it <strong>and</strong> another process reads the data on<br />

a First-In-First-Out (FIFO) basis; or one process can pipe data to itself.<br />

The pipe() function also initializes the O_NONBLOCK flags as clear; (see the open()<br />

function) <strong>for</strong> both file descriptors. You can set these flags with the fcntl() function (see<br />

the fcntl() function.) See “Redirecting St<strong>and</strong>ard Files to Pipes” <strong>for</strong> in<strong>for</strong>mation on using<br />

pipes.<br />

Synopsis<br />

int pipe(int fildes[2]);<br />

Description<br />

The pipe() function creates a pipe <strong>and</strong> returns its file descriptors in the fildes array,<br />

where:<br />

fildes[0]<br />

fildes[1]<br />

is the file descriptor <strong>for</strong> the read end of the pipe.<br />

is the file descriptor <strong>for</strong> the write end of the pipe.<br />

Return Values<br />

If the pipe() function completes successfully, it does the following:<br />

• Initializes the st_atime, st_ctime, <strong>and</strong> st_mtime fields of the pipe<br />

• Returns 0<br />

Otherwise, pipe() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If the following condition occurs, the pipe() function returns -1 <strong>and</strong> sets errno to the<br />

corresponding value:<br />

EMFILE The calling process would exceed the maximum number of file<br />

descriptors allowed.<br />

5–98 7859 6137–009


Redirecting St<strong>and</strong>ard Files to Pipes<br />

Using C St<strong>and</strong>ard Files<br />

pipe()<br />

To agree on the file descriptors <strong>for</strong> a pipe, programs follow the convention of using the C<br />

st<strong>and</strong>ard files to correspond to the pipe's file descriptors, as follows:<br />

C St<strong>and</strong>ard File Program Name<br />

St<strong>and</strong>ard input file (stdin) STDIN_FILENO 0<br />

St<strong>and</strong>ard output file<br />

(stdout)<br />

STDOUT_FILENO 1<br />

St<strong>and</strong>ard error file (stderr) STDERR_FILENO 2<br />

Redirecting St<strong>and</strong>ard Files<br />

File<br />

Descriptor<br />

In your program, you can redirect the st<strong>and</strong>ard files to one end of a pipe. For example, to<br />

redirect STDOUT_FILENO to the write end of a pipe, do the following procedure:<br />

1. Close STDOUT_FILENO, making its file descriptor available <strong>for</strong> reuse.<br />

2. Duplicate the write end of the pipe. The kernel always chooses the lowest available<br />

number <strong>for</strong> a new file descriptor, which is the one previously assigned to<br />

STDOUT_FILENO.<br />

3. Close the original write end of the pipe, leaving STDOUT_FILENO as the write end.<br />

7859 6137–009 5–99


printf()<br />

printf()<br />

Application<br />

Use the printf() function to write <strong>for</strong>matted output to the st<strong>and</strong>ard output.<br />

Synopsis<br />

int printf(const char * <strong>for</strong>mat, ...);<br />

Description<br />

The printf() function is equivalent to calling fprintf() using stdout as the file pointer, as<br />

follows:<br />

fprintf(stdout, <strong>for</strong>mat, ...);<br />

See fprintf() <strong>for</strong> a description of the <strong>for</strong>mat argument.<br />

Return Values<br />

If it completes successfully, the printf() function returns the number of characters<br />

transmitted. Otherwise, printf() returns a negative value.<br />

5–100 7859 6137–009


putc()<br />

Application<br />

Use the putc() function to write characters to an output stream.<br />

Synopsis<br />

int putc(int c, FILE * stream);<br />

Description<br />

The putc() function is equivalent to fputc().<br />

Return Values<br />

putc()<br />

If it completes successfully, the putc() function returns the character written. If a write<br />

error occurs, putc() sets the error indicator <strong>and</strong> returns EOF.<br />

7859 6137–009 5–101


putchar()<br />

putchar()<br />

Application<br />

Use the putchar() function to write a character to st<strong>and</strong>ard output.<br />

Synopsis<br />

int putchar(int c);<br />

Description<br />

The putchar() function is equivalent to calling putc() with the second argument stdout<br />

(st<strong>and</strong>ard output).<br />

Return Values<br />

If it completes successfully, the putchar() function returns the character written. If a<br />

write error occurs, putchar() sets the error indicator <strong>and</strong> returns EOF.<br />

5–102 7859 6137–009


puts()<br />

Application<br />

Use the puts() function to write a string of characters to st<strong>and</strong>ard output.<br />

Synopsis<br />

int puts(const char * s);<br />

Description<br />

puts()<br />

The puts() function writes the string to which s points to the st<strong>and</strong>ard output stream<br />

(stdout), appending a newline character to the output. The nul character terminating the<br />

array is not written.<br />

Return Values<br />

If it completes successfully, the puts() function returns 0. Otherwise, puts() returns EOF.<br />

7859 6137–009 5–103


ead()<br />

read()<br />

Application<br />

Use the read() function to read data from a file at the current read/write position. Use the<br />

lseek() function to reposition the read/write offset, if necessary. See the following<br />

subsections <strong>for</strong> more in<strong>for</strong>mation: “Determining the Number of Bytes Read,” “Starting<br />

Position <strong>for</strong> Different File Types,” <strong>and</strong> “Reading Different File Types.”<br />

Synopsis<br />

ssize_t read(int fildes, void * buf, size_t nbyte);<br />

Description<br />

The read() function reads data from a file into a buffer, where:<br />

fildes<br />

buf<br />

nbyte<br />

is a file descriptor.<br />

is a pointer to the buffer that receives the data as it is read.<br />

is the number of bytes to be read, which is limited by the size of a data bank.<br />

Return Values<br />

If the read() function completes successfully, it does the following:<br />

• Updates the st_atime field of the file (see the fstat() <strong>and</strong> stat() functions), if it reads<br />

any bytes<br />

• Increments the read/write offset by the number of bytes actually read<br />

• Returns the number of bytes actually read <strong>and</strong> placed into the buffer<br />

Otherwise, read() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the read() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EAGAIN The file descriptor's O_NONBLOCK flag is set <strong>and</strong> no data is available.<br />

EBADF fildes is not a valid file descriptor open <strong>for</strong> reading.<br />

5–104 7859 6137–009


EFAULT One of the following errors occurred:<br />

• buf points to an invalid address, <strong>and</strong> nbyte is greater than 0.<br />

• buf is valid, but (buf+(nbyte-1)) points to an invalid address.<br />

EIO An I/O error occurred during processing of the request.<br />

Determining the Number of Bytes Read<br />

The read() function returns the number of bytes actually read <strong>and</strong> stored in the buffer,<br />

which is never greater than nbyte. The following paragraphs relate this return value to<br />

the input value of nbyte.<br />

Return Value = nbyte<br />

The read() function read <strong>and</strong> stored the exact number of bytes requested.<br />

Return Value < nbyte<br />

The value returned is less than nbyte if one of the following statements is true:<br />

• Fewer than nbyte bytes remain between the read/write offset <strong>and</strong> the end of the<br />

file.<br />

read()<br />

• The file is a pipe or FIFO that has fewer than nbyte bytes immediately available <strong>for</strong><br />

reading.<br />

Return Value = 0<br />

The value returned is 0 if one of the following statements is true:<br />

• The value of nbyte is 0; the function has no other effects.<br />

• The value of nbyte is not 0, but the read/write offset is at the end of file (EOF).<br />

Starting Position <strong>for</strong> Different File Types<br />

The file type determines which byte in the file is the first to be read, as shown in the<br />

following paragraphs.<br />

Regular Files<br />

The read() function starts at the position given by the read/write offset associated with<br />

the open file description corresponding to fildes. Be<strong>for</strong>e returning, read() increases the<br />

read/write offset by the number of bytes read.<br />

Pipes <strong>and</strong> FIFO Files<br />

The read() function starts at the current position associated with the file corresponding to<br />

fildes. The value of the read/write offset has no meaning <strong>for</strong> these file types.<br />

If the starting position is at or beyond the current end of file (EOF), the function returns 0<br />

<strong>and</strong> stores nothing into the buffer. Subsequent read operations attempt to read from the<br />

device again, unless EOF is a hard EOF mark on stdin. In this case, all subsequent read<br />

operations return 0 <strong>and</strong> store no data into the buffer.<br />

7859 6137–009 5–105


ead()<br />

Reading Different File Types<br />

The file type determines the behavior of the read() function, as shown in the following<br />

paragraphs.<br />

Empty Pipe or FIFO File<br />

The read() function per<strong>for</strong>ms as follows:<br />

• If no process has the pipe or FIFO open <strong>for</strong> writing, read() returns 0 to indicate the<br />

end of the file.<br />

• If some process has the pipe or FIFO open <strong>for</strong> writing <strong>and</strong> the O_NONBLOCK flag<br />

<strong>for</strong> the open file description corresponding to fildes is set (see the open() <strong>and</strong> fcntl()<br />

functions), read() returns <strong>and</strong> sets errno to EAGAIN.<br />

• If some process has the pipe or FIFO open <strong>for</strong> writing <strong>and</strong> the O_NONBLOCK flag is<br />

clear, read() waits until some data is written or the pipe or FIFO is closed by all<br />

processes that have the pipe or FIFO open <strong>for</strong> writing.<br />

S_1100BIN File Created Outside of <strong>CIFS</strong><br />

These files can contain areas of unwritten data that are indistinguishable from valid data.<br />

Reading these areas results in bytes with indeterminate values. A process must never<br />

assume these areas are zero-filled.<br />

S_1100SDF File<br />

The read() function per<strong>for</strong>ms as follows:<br />

• Translates Fieldata images to ASCII<br />

• Removes all SDF attributes from the text returned, so the process cannot use this<br />

attribute to read SDF line numbers<br />

5–106 7859 6137–009


eaddir()<br />

Application<br />

readdir()<br />

Use the readdir() function to read the current entry in a directory stream (that is, the<br />

entry at the current position); readdir() then positions the directory stream at the next<br />

entry. The dirent structure passes in<strong>for</strong>mation about the directory entry, if a current entry<br />

exists. Be<strong>for</strong>e reading a directory stream, you must open it.<br />

You can distinguish the end of the directory from error cases; see “Finding the End of<br />

the Directory” in this subsection.<br />

See opendir() <strong>for</strong> opening a directory stream, closedir() <strong>for</strong> closing an open directory, <strong>and</strong><br />

rewinddir() <strong>for</strong> repositioning a directory stream at its beginning.<br />

Synopsis<br />

struct dirent * readdir(DIR * dirp);<br />

Description<br />

The readdir() function reads the next entry in a directory stream, where dirp is a pointer<br />

to the directory stream from which to read the directory entry. The directory stream<br />

must have been opened previously by opendir().<br />

The dirent Structure<br />

The dirent structure passes the location of the file <strong>for</strong> each entry in a directory stream.<br />

The following table describes type struct dirent, which is defined in .<br />

Member<br />

Name Member Type Description<br />

d_ino ino_t File serial number, unique <strong>for</strong> the file in its file<br />

system<br />

d_name char * Nul-terminated file name<br />

Note: Other fields in the dirent structure are reserved <strong>for</strong> internal use by <strong>CIFS</strong>.<br />

Calling readdir() Repeatedly<br />

If a process opens a directory <strong>and</strong> then repeatedly calls readdir() on the directory stream,<br />

readdir() returns one entry <strong>for</strong> each file continuously in the directory from the time of the<br />

opendir() call. This includes one entry <strong>for</strong> the dot file (d_name is “ . “) <strong>and</strong> one entry <strong>for</strong><br />

the dot-dot file (d_name is “ .. “).<br />

Every time readdir() reads the same directory stream, it overwrites the previous directory<br />

entry returned.<br />

Multiple Directory Streams<br />

Per<strong>for</strong>ming readdir() on one directory stream never interferes with entries in other<br />

directory streams.<br />

7859 6137–009 5–107


eaddir()<br />

Sharing Directory Streams with Child Processes<br />

When a process calls tskstart() <strong>and</strong> _cifs_new_process(), it shares with its child both its<br />

directory streams <strong>and</strong> its open file descriptions. Either the parent or the child process<br />

can read entries first. Either process can rewind the shared directory stream with<br />

rewinddir(). If one process changes the positioning of a shared directory stream, that<br />

change is immediately visible to the other process.<br />

Finding the End of the Directory<br />

Use the following procedure to distinguish the end of the directory from error cases:<br />

1. Set errno to 0.<br />

2. Call readdir().<br />

3. Check the value of errno if readdir() returns a null pointer.<br />

• If errno equals 0, readdir() reached the end of the directory.<br />

• If errno does not equal 0, readdir() returned an error.<br />

See “Return Values” below to see when readdir() returns a null pointer.<br />

Return Values<br />

If the readdir() function completes successfully, it does the following:<br />

• Updates the st_atime of the directory each time the directory is actually read. The<br />

function can store several entries <strong>for</strong> one call in the buffer <strong>and</strong> not do actual read<br />

operations <strong>for</strong> other calls. The update to st_atime is not written to nonvolatile<br />

storage until the directory stream is closed by one of the following events:<br />

− A call to closedir()<br />

− Process termination<br />

• Returns one of the following:<br />

− A pointer to a directory entry<br />

− A null pointer, if no more entries exist. In this case, readdir() does not change the<br />

value of errno.<br />

Otherwise, readdir() sets errno to identify the specific error <strong>and</strong> returns a null pointer.<br />

Error Codes<br />

If any of the following conditions occurs, the readdir() function returns a null pointer <strong>and</strong><br />

sets errno to the corresponding value:<br />

EBADF dirp does not point to a valid DIR object representing a directory stream.<br />

EFAULT dirp is not a valid pointer.<br />

5–108 7859 6137–009


ealpath()<br />

Application<br />

The realpath() function returns the fully-resolved, absolute path of a specified file.<br />

Synopsis<br />

char * realpath(char * file_name, char * resolved_name, ...)<br />

Description<br />

realpath()<br />

The function attempts to find the full path in which file_name resides, <strong>and</strong> returns the<br />

result in resolved_name. An integer third argument (optional) can be used to specify the<br />

size of the resolved_name string area; if it is zero or not given, the default size is 1024.<br />

Return Values<br />

Upon successful completion, the function returns a pointer to resolved_name. If<br />

unsuccessful, it returns NULL <strong>and</strong> sets errno to an appropriate value. If the return value<br />

is NULL <strong>and</strong> errno is ENOENT, resolved_name has been filled in with the fully-exp<strong>and</strong>ed<br />

path, but the file in question does not exist. In all other cases where NULL is returned,<br />

the contents of resolved_name are indeterminate.<br />

7859 6137–009 5–109


emove()<br />

remove()<br />

Application<br />

Use the remove() function to remove any type of named file, including an empty<br />

directory.<br />

Synopsis<br />

int remove(const char * pathname);<br />

Description<br />

The remove() function causes a file to be removed, where path points to the name of the<br />

file. If the file is open, any subsequent input or output operations to the file do not fail.<br />

Subsequent attempts to open the file fail unless the file is re-created.<br />

Return Values<br />

If the remove() function completes successfully, it returns 0. Otherwise, remove()<br />

returns a nonzero value <strong>and</strong> sets errno to an appropriate value.<br />

5–110 7859 6137–009


ename()<br />

Application<br />

rename()<br />

Use the rename() function to change the path name of an existing file. The new entry<br />

can be in the same directory or in different directories. If it is in the same directory, the<br />

file name must be unique.<br />

If the new path name also resolves to an existing file, the link to that file is removed<br />

be<strong>for</strong>e the name is reused; this possibly removes the unlinked file from the file system<br />

(see “General Rules <strong>for</strong> Renaming Files” in this subsection).<br />

See the link() function <strong>for</strong> creating new directory entries <strong>for</strong> a file <strong>and</strong> the unlink() function<br />

<strong>for</strong> removing file links.<br />

Synopsis<br />

int rename(const char * old, const char * new);<br />

Description<br />

The rename() function changes the path name of an existing file, where:<br />

old<br />

new<br />

is a pointer to the file to rename.<br />

is a pointer to the new path name to attach to the file.<br />

Neither old nor new can refer to a character file.<br />

Example 1<br />

The following example illustrates a simple rename operation within a directory:<br />

7859 6137–009 5–111


ename()<br />

Example 2<br />

The following diagram illustrates a simple rename operation between two directories:<br />

Example 3<br />

The following diagram illustrates a complex rename operation, where the new path<br />

name resolves to an existing file. The existing link to /dir_2/file_2 is removed first; then<br />

the rename operation is similar to example 2, with a different file name.<br />

General Rules <strong>for</strong> Renaming Files<br />

The following general rules apply to renaming files:<br />

• If the old <strong>and</strong> new path names resolve to the same file, rename() returns<br />

successfully without making any changes.<br />

• If the old <strong>and</strong> new path names do not resolve to the same file, the following rules<br />

apply:<br />

− The process must have write-access permission to the directory containing the<br />

link to the old file.<br />

− The process must have write-access permission to the directory that contains<br />

the new link.<br />

• If the new path name resolves to an existing file, the file is unlinked from the last<br />

directory in the new path name be<strong>for</strong>e its name is reused <strong>for</strong> old.<br />

5–112 7859 6137–009


ename()<br />

If no other links to the file exist, the file is removed from the file hierarchy as soon as<br />

all references to it are closed (see the close() function). The dot <strong>and</strong> dot-dot entries<br />

cannot be manipulated by the rename() <strong>and</strong> rmdir() functions. These entries are<br />

automatically deleted from a directory when its last link is removed.<br />

Special Rules <strong>for</strong> Renaming a Directory<br />

The following special rules apply to renaming a directory:<br />

• The process must have write-access permission to the old directory.<br />

• If the new path name exists in the file system, it must resolve to a directory.<br />

• If the new path name resolves to an existing directory, the process must have writeaccess<br />

permission to it <strong>and</strong> it must be empty.<br />

• The old path name must not resolve to a directory contained in the new path name.<br />

Special Rules <strong>for</strong> Renaming a Nondirectory File<br />

The new path name must not resolve to an existing directory.<br />

Return Values<br />

If the rename() function completes successfully, it does the following:<br />

• Updates the st_atime <strong>and</strong> st_mtime fields of the parent directory of each file<br />

• Returns 0<br />

Otherwise, rename() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the rename() function returns -1 <strong>and</strong> sets errno<br />

to the corresponding value:<br />

EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a component of<br />

either path name.<br />

• The calling process is denied write permission to directories<br />

containing either old or new.<br />

• The calling process is denied write permission to directories to<br />

which either old or new point.<br />

EEXIST The link named by new is a directory with entries other than dot <strong>and</strong> dotdot;<br />

that is, it is not an empty directory.<br />

EFAULT The pointer specified by old or new is invalid.<br />

EINVAL One of the following errors occurred:<br />

• The directory path name in new contains the directory name in old.<br />

• The last component of either old or new is either dot or dot-dot.<br />

EISDIR The path name in new resolves to a directory, <strong>and</strong> the path name in old<br />

resolves to a file that is not a directory.<br />

7859 6137–009 5–113


ename()<br />

ENOENT<br />

Either of the following errors occurred:<br />

• The link named by old does not exist.<br />

• Either old or new points to an empty string.<br />

EN<strong>OS</strong>PC The parent directory of new has too many entries.<br />

ENOTDIR Either of the following errors occurred:<br />

• A component of either path name prefix is not a directory.<br />

• old names a directory, <strong>and</strong> new names a file that is not a directory.<br />

5–114 7859 6137–009


ewind()<br />

Application<br />

rewind()<br />

Use the rewind() function to set the file position indicator to the beginning of a stream.<br />

Synopsis<br />

void rewind(FILE * stream);<br />

Description<br />

The rewind() function is equivalent to the following call to fseek():<br />

fseek(stream, OL, SEEK_SET);<br />

Detecting Error Cases<br />

Use the following procedure to detect error cases:<br />

1. Set errno to 0.<br />

2. Call rewind().<br />

3. Check the value of errno.<br />

• If errno equals 0, rewind() did not detect an error.<br />

• If errno does not equal 0, rewind() detected an error.<br />

Return Values<br />

The rewind() function returns no value. It clears the error indicator if no problems are<br />

encountered.<br />

7859 6137–009 5–115


ewinddir()<br />

rewinddir()<br />

Application<br />

Use the rewinddir() function to reposition a directory stream at its beginning. The<br />

rewinddir() function updates the directory stream to reflect the current state of the<br />

directory, making visible any directory entries added since the directory stream was<br />

opened.<br />

You can distinguish a successful call to rewinddir() from error cases; see “Detecting<br />

Error Cases” in this subsection.<br />

See opendir() <strong>for</strong> opening a directory, closedir() <strong>for</strong> closing an open directory, <strong>and</strong><br />

readdir() <strong>for</strong> reading the next directory entry.<br />

Synopsis<br />

void rewinddir(DIR * dirp);<br />

Description<br />

The rewinddir() function resets the position of the directory stream to its beginning,<br />

where dirp is a pointer to the directory stream to rewind. The directory stream must<br />

have been opened previously by opendir().<br />

Detecting Error Cases<br />

Use the following procedure to detect error cases:<br />

1. Set errno to 0.<br />

2. Call rewinddir().<br />

3. Check the value of errno.<br />

• If errno equals 0, rewinddir() did not detect an error.<br />

• If errno does not equal 0, rewinddir() detected an error.<br />

Return Values<br />

The rewinddir() function returns no value.<br />

Error Codes<br />

If any of the following conditions occurs, the rewinddir() function sets errno to the<br />

corresponding value:<br />

EBADF dirp does not point to a valid DIR object representing an open<br />

directory stream.<br />

EFAULT dirp is not a valid pointer.<br />

5–116 7859 6137–009


mdir()<br />

Application<br />

Use the rmdir() function to remove an empty directory from the file system.<br />

Synopsis<br />

int rmdir(const char * path);<br />

Description<br />

rmdir()<br />

The rmdir() function removes an empty directory <strong>and</strong> its dot <strong>and</strong> dot-dot entries, where<br />

path is a pointer to the directory to remove. The directory cannot be the system root<br />

directory.<br />

If any process has the directory open or has an open directory stream (see the opendir()<br />

function) when rmdir() removes the last link, the directory contents remain accessible<br />

until all references are closed.<br />

Return Values<br />

If the rmdir() function completes successfully, it does the following:<br />

• Updates the st_atime <strong>and</strong> st_mtime fields of the parent directory<br />

• Returns 0<br />

Otherwise, rmdir() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the rmdir() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a component of<br />

the path name.<br />

• The calling process is denied write permission to the parent directory<br />

of the directory to be removed.<br />

EEXIST path names a directory that is not empty.<br />

EFAULT The pointer specified by path is invalid.<br />

EINVAL The calling process is requesting that the dot or dot-dot entry in a directory<br />

be removed.<br />

EIO An I/O error prevented the completion of the function.<br />

ENOENT Either of the following errors occurred:<br />

• The directory does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name is not a directory.<br />

7859 6137–009 5–117


scanf()<br />

scanf()<br />

Application<br />

Use the scanf() function to read <strong>for</strong>matted input from the st<strong>and</strong>ard input.<br />

Synopsis<br />

int scanf(const char * <strong>for</strong>mat, ...);<br />

Description<br />

The scanf() function is equivalent to calling fscanf() using stdin as the file pointer, as<br />

follows:<br />

fscanf(stdin, <strong>for</strong>mat, ...);<br />

See fscanf() <strong>for</strong> a description of the <strong>for</strong>mat argument.<br />

Return Values<br />

If it completes successfully, the scanf() function returns either of the following:<br />

• The number of assigned input items, which can be 0 in the event of an early conflict<br />

between an input character <strong>and</strong> the <strong>for</strong>mat<br />

• EOF, if it encounters end of file be<strong>for</strong>e the first conflict or conversion<br />

Otherwise, scanf() returns when it encounters the end of the <strong>for</strong>mat string.<br />

5–118 7859 6137–009


share()<br />

Application<br />

share()<br />

Use _cifs_share() to specify the network-visible name <strong>for</strong> the given directory. The share<br />

name cannot be more than 31 characters long.<br />

Notes:<br />

• There is no P<strong>OS</strong>IX equivalent to _cifs_share().<br />

• Many network clients cannot access share names with more than 12 characters.<br />

Synopsis<br />

int _cifs_share(const char * path, const char * share_name);<br />

Description<br />

The path parameter must specify a directory to which the caller has full access. The<br />

share_name parameter must be NULL or point to a string of 31 or fewer characters from<br />

the printable ASCII set, not including the slash (/), back slash (\), question mark (?),<br />

asterisk (*), or comma (,) characters. If the share_name pointer is NULL or an empty<br />

string, the call removes network visibility <strong>for</strong> the directory. If the share_name string<br />

contains invalid characters, the network visibility <strong>for</strong> the directory is unchanged.<br />

Otherwise, the share_name becomes the network name <strong>for</strong> the directory, replacing any<br />

existing name.<br />

Return Values<br />

Returns a value of zero if successful <strong>and</strong> a value of -1 if any errors are detected (with<br />

errno set to the appropriate value).<br />

7859 6137–009 5–119


sprintf()<br />

sprintf()<br />

Application<br />

Use the sprintf() function to write <strong>for</strong>matted output to a character array.<br />

Synopsis<br />

int sprintf(char * s, const char * <strong>for</strong>mat, ...);<br />

Description<br />

The sprintf() function is equivalent to fprintf, except that the argument s specifies a<br />

character array to which the generated output is written (rather than to a stream). A nul<br />

character is appended after the characters are written, but the nul character is not<br />

counted as part of the returned sum.<br />

Return Values<br />

The sprintf() function returns the number of characters written to the array, not counting<br />

the terminating nul character.<br />

5–120 7859 6137–009


sscanf()<br />

Application<br />

Use the sscanf() function to read <strong>for</strong>matted input from a string.<br />

Synopsis<br />

int sscanf(const char * s, const char * <strong>for</strong>mat, ...);<br />

Description<br />

sscanf()<br />

The sscanf() function is equivalent to fscanf(), except that the argument s specifies a<br />

string from which the input is read (rather than from a stream). Reaching the end of the<br />

string is equivalent to encountering end of file <strong>for</strong> the fscanf() function.<br />

Return Values<br />

If it completes successfully, the sscanf() function returns the number of assigned input<br />

items (which can be 0 in the event of an early conflict between an input character <strong>and</strong><br />

the <strong>for</strong>mat). Otherwise, sscanf() returns when it encounters the end of the <strong>for</strong>mat string.<br />

7859 6137–009 5–121


stat()<br />

stat()<br />

Application<br />

Use the stat() function to retrieve in<strong>for</strong>mation about a named file. In particular, you can<br />

get in<strong>for</strong>mation about the file mode, security attributes, file size, <strong>and</strong> access times.<br />

The stat() function uses a path name to identify the file. See the fstat() function <strong>for</strong> a<br />

similar function that uses a file descriptor.<br />

Synopsis<br />

int stat(const char * path, struct stat * buf);<br />

Description<br />

The stat() function returns in<strong>for</strong>mation about a file in a stat structure, where:<br />

path<br />

buf<br />

is a pointer to the requested file.<br />

is a pointer to a stat structure in which stat() returns the file in<strong>for</strong>mation; see the<br />

fstat() function <strong>for</strong> the contents of the stat structure.<br />

The calling process does not need read, write, or execute permission to the file; but it<br />

must have search permission to all directories in the path name leading to the file. Refer<br />

to the fstat() function <strong>for</strong> a table that describes the stat structure.<br />

Return Values<br />

If the stat() function completes successfully, it returns 0. Otherwise, stat() sets errno to<br />

identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the stat() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES The calling process is denied search permission to a directory in the path<br />

name.<br />

EFAULT The pointer specified by path is invalid.<br />

ENOENT Either of the following errors occurred:<br />

• The file or directory does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

5–122 7859 6137–009


strerror()<br />

Application<br />

strerror()<br />

Use the strerror() function to retrieve the error message associated with a particular error<br />

number.<br />

Synopsis<br />

char * strerror(int errnum, ...);<br />

Description<br />

The strerror() function retrieves the ELMS text <strong>for</strong> the specified error number, errnum,<br />

using first the <strong>CIFS</strong> component, <strong>and</strong> then the URTS component if the message does not<br />

exist within <strong>CIFS</strong>. There are two optional arguments used to specify insert text <strong>for</strong> the<br />

requested message. The second argument (first additional) is an integer giving the<br />

number of inserts. The third argument (second additional) is an array of character<br />

pointers, where each pointer gives the location of an insert string appropriate <strong>for</strong> the<br />

message.<br />

Return Values<br />

The strerror() function returns a pointer to the retrieved message text with any inserts<br />

applied. This area is modifiable by the caller <strong>and</strong> is overwritten on subsequent calls to<br />

strerror().<br />

7859 6137–009 5–123


tmpfile()<br />

tmpfile()<br />

Application<br />

Use the tmpfile() function to create a temporary file <strong>for</strong> use while a program executes.<br />

Synopsis<br />

FILE * tmpfile();<br />

Description<br />

The tmpfile() function creates a temporary file, where FILE is an opaque data type that<br />

describes an open instance of a file. The file is opened <strong>for</strong> update <strong>and</strong> automatically<br />

removed at program termination.<br />

Default Permissions When Creating a File<br />

If the tmpfile() function creates a file, it assigns read <strong>and</strong> write permissions to the owner,<br />

group, <strong>and</strong> other permission classes by default. The following file mode specification <strong>for</strong><br />

the open() function is equivalent:<br />

S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH<br />

Return Values<br />

The tmpfile() function returns a pointer to the stream of the file that it created. If the file<br />

cannot be created, tmpfile() returns a null pointer.<br />

5–124 7859 6137–009


tmpnam()<br />

Application<br />

tmpnam()<br />

Use the tmpnam() function to generate a string to use as a file name that is different<br />

from any existing file name.<br />

Synopsis<br />

char * tmpnam(char * s);<br />

Description<br />

The tmpnam() function generates a string that is not the same as the name of an existing<br />

file, where s is a pointer to an array <strong>for</strong> the results.<br />

The tmpnam() function generates a different string each time it is called.<br />

Note: Files created using strings generated by the tmpnam() function are temporary<br />

only in the sense that their names must not conflict with those generated by<br />

conventional naming rules <strong>for</strong> the implementation. You must still use the remove()<br />

function to remove such files when their use is ended <strong>and</strong> be<strong>for</strong>e program termination.<br />

Return Values<br />

If s is a null pointer, tmpnam() leaves its result in an internal static object <strong>and</strong> returns a<br />

pointer to that object. Subsequent calls to tmpnam() can modify the same object.<br />

If s is not null, it is assumed to point to an array of at least L_tmpnam characters.<br />

tmpnam() writes its result in that array <strong>and</strong> returns the argument as its value.<br />

7859 6137–009 5–125


truncate()<br />

truncate()<br />

Application<br />

Use the truncate() function to set the end-of-file position <strong>for</strong> an existing regular file.<br />

Synopsis<br />

int truncate(const char * path, off_t length);<br />

Description<br />

A regular file whose name is given by path has its size (in bytes) set to length. If the file<br />

was previously longer than the length specified, those bytes are no longer accessible. If<br />

the file was previously shorter than the length specified, bytes between the old<br />

end-of-file <strong>and</strong> the specified length are read as zeroes. For truncate(), the caller must<br />

have write access to the file.<br />

For files stored in SDF <strong>for</strong>mat, the length value of 34359738367 (defined as INT_MAX in<br />

the limits.h header file) has special meaning. <strong>CIFS</strong> treats this as an indication that it must<br />

recalculate the actual size of the file when it is next read based on the position of the<br />

EOF record, rather than pad the file with zeroes.<br />

Return Values<br />

Upon successful completion, the function returns a value of 0. If unsuccessful, it returns<br />

a value of -1 <strong>and</strong> sets errno to the appropriate value.<br />

5–126 7859 6137–009


umask()<br />

Application<br />

umask()<br />

Use the umask() function to create the file mode creation mask <strong>for</strong> the calling process<br />

<strong>and</strong> save its previous version.<br />

Synopsis<br />

mode_t umask(mode_t cmask);<br />

Description<br />

The umask() function sets the file mode creation mask, where cmask contains the value<br />

<strong>for</strong> the mask.<br />

The file mode creation mask is a process attribute that limits the permissions the<br />

process can attach to a file. The mask is a set of attributes corresponding to read, write,<br />

<strong>and</strong> search/execute permissions <strong>for</strong> each of the owner, group, <strong>and</strong> other permission<br />

classes. If an attribute is set in the mask, that permission is denied when files are<br />

created. For example, to prohibit anyone in the group <strong>and</strong> other permission classes from<br />

writing to a file, set the corresponding attributes in the file mode creation mask be<strong>for</strong>e<br />

creating the file.<br />

Functions that create files request file permissions through a mode argument in the call<br />

statement. However, they first apply the file mode creation mask to turn off<br />

corresponding permissions that are set in the mode argument. For example, if the<br />

attributes <strong>for</strong> group <strong>and</strong> other write permissions are set in the file mode creation mask,<br />

those permissions are not set <strong>for</strong> files created subsequently.<br />

Note: To apply the file mode creation mask, functions per<strong>for</strong>m a bitwise AND<br />

operation between the value of mode <strong>and</strong> the complement of the file mode creation<br />

mask.<br />

Setting the File Mode Creation Mask<br />

You can set the file mode creation mask using any of the symbolic constants <strong>for</strong> the<br />

individual or group permission settings, as follows:<br />

mode_t fmc_mask; /* Previous mask value */<br />

fmc_mask = umask(S_IWGRP | S_IRWXO);<br />

The previous code sets the file mode creation mask to contain both of the following:<br />

• Write access by the group class<br />

• Any access by the other class<br />

The mask, then, prohibits those permissions <strong>for</strong> functions that apply the mask to the<br />

mode argument.<br />

7859 6137–009 5–127


umask()<br />

Return Values<br />

The umask() function returns the previous value of the file mode creation mask.<br />

Error Codes<br />

The umask() function returns no error conditions.<br />

5–128 7859 6137–009


uname()<br />

Application<br />

Use the _cifs_uname() function to retrieve version in<strong>for</strong>mation about the <strong>CIFS</strong><br />

subsystem.<br />

Note: There is no P<strong>OS</strong>IX equivalent to _cifs_uname().<br />

Synopsis<br />

int _cifs_uname(char * cifs_bdi, char * cifs_name);<br />

Description<br />

uname()<br />

The _cifs_uname() function returns version in<strong>for</strong>mation about the <strong>CIFS</strong> subsystem. The<br />

cifs_bdi parameter receives the bank descriptor index (BDI) of the subsystem gate bank,<br />

in symbolic <strong>for</strong>m. The space pointed to by cifs_bdi must be able to hold 8 characters.<br />

The cifs_name parameter is filled with the subsystem name, the date <strong>and</strong> time of the<br />

subsystem construction, <strong>and</strong> the build number. The cifs_name area must be at least 48<br />

characters long.<br />

Return Values<br />

The _cifs_uname() function returns zero <strong>for</strong> successful completions or -1 <strong>for</strong> errors.<br />

When an error is detected, errno is set to an appropriate value.<br />

7859 6137–009 5–129


ungetc()<br />

ungetc()<br />

Application<br />

Use the ungetc() function to return a character to the input stream, causing the next read<br />

operation to read that character.<br />

Synopsis<br />

int ungetc(int c, FILE * stream);<br />

Description<br />

The ungetc() function pushes a character back onto the input stream, where:<br />

c<br />

FILE<br />

stream<br />

specifies the character.<br />

is an opaque data type that describes an open instance of a file.<br />

is a pointer to a FILE object <strong>for</strong> input. The external storage corresponding to the<br />

stream is unchanged.<br />

The character is returned by the next read on that stream, provided no intervening call to<br />

fseek() erases all memory of pushed-back characters.<br />

Notes:<br />

• ungetc() at end of file is legal; it causes feof() to return false until the character is reread.<br />

• ungetc() does not change the value of the file pointer.<br />

• ungetc() is not allowed <strong>for</strong> output operations.<br />

Return Values<br />

If it completes successfully, the ungetc() function returns the character pushed back to<br />

the input stream. Otherwise, ungetc() returns EOF.<br />

5–130 7859 6137–009


unlink()<br />

Application<br />

unlink()<br />

Use the unlink() function to remove a link from a named, nondirectory file, which<br />

decreases the file's link count by 1. If the link count becomes 0, unlink() deletes the file<br />

from the file system.<br />

See the rename() function <strong>for</strong> changing the name of a file <strong>and</strong> the link() function <strong>for</strong><br />

creating new directory entries <strong>for</strong> a file.<br />

Synopsis<br />

int unlink(const char * path);<br />

Description<br />

The unlink() function removes a link from a file, where path is a pointer to the file link to<br />

be removed. Path cannot point to a directory; use rmdir() to remove a directory.<br />

If a process has the file open when it is being removed, that process can continue to<br />

access the file through the open file descriptor.<br />

Return Values<br />

If the unlink() function completes successfully, it does the following:<br />

• Updates the st_atime <strong>and</strong> st_mtime fields of the parent directory<br />

• Updates the st_atime field of the file, if the file's link count is not 0<br />

• Returns 0<br />

Otherwise, unlink() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

Error Codes<br />

If any of the following conditions occurs, the unlink() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a component of<br />

the path name.<br />

• The calling process is denied write permission to the directory<br />

containing the link to be removed.<br />

EFAULT The pointer specified by path is invalid.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

7859 6137–009 5–131


utime()<br />

utime()<br />

Application<br />

Use the utime() function to change the access time <strong>and</strong> modification time of a file, using<br />

either the current system time or an arbitrary time setting. You can retrieve these values<br />

into a stat structure using the stat() function.<br />

These times are also changed by functions that per<strong>for</strong>m input <strong>and</strong> output operations on<br />

the file; check the paragraphs under “Return Values” <strong>for</strong> each function to see which<br />

time fields the function updates, if any.<br />

Privilege Requirement<br />

For a process to change the access time <strong>and</strong> modification time of a file, one of the<br />

following must be true:<br />

• The process is privileged.<br />

• The effective user ID of the process is equal to the owning user ID of the file.<br />

Synopsis<br />

int utime(const char * path, const struct utimbuf * times);<br />

Description<br />

The utime() function sets the access time <strong>and</strong> modification time of a file to either the<br />

current time or the values in the utimbuf structure, where:<br />

path<br />

times<br />

is a pointer to the file.<br />

controls how utime() sets the access time <strong>and</strong> modification time; it is one of the<br />

following:<br />

• A null pointer<br />

utime() sets both the access time <strong>and</strong> modification time of the file to the current<br />

system time if<br />

− The calling process is allowed to change the times (see “Privilege<br />

Requirement” in this subsection)<br />

− The calling process has write permission to the file.<br />

• A pointer to a utimbuf structure<br />

utime() sets the access time <strong>and</strong> modification time of the file to the values in the<br />

structure if the calling process is allowed to change the times (see “Privilege<br />

Requirement” in this subsection). Whether the process has write permission to<br />

the file is immaterial.<br />

5–132 7859 6137–009


The utimbuf Structure<br />

The following table describes the utimbuf structure, which is defined in the header<br />

:<br />

Member<br />

Name<br />

Member<br />

Type* Description **<br />

actime time_t This value is put into the st_atime field of the file.<br />

modtime time_t This value is put into the st_mtime field of the file.<br />

* Type time_t is an arithmetic type capable of representing a time value.<br />

** Time values are measured in seconds from 00:00:00 January 1, 1970, local time.<br />

Setting Values in the utimbuf Structure<br />

utime()<br />

The following program fragment sets the values in the utimbuf structure to the current<br />

time, using the time() function. It then uses these values to update the st_atime <strong>and</strong><br />

st_mtime fields <strong>for</strong> the file /my_dir/my_file.<br />

#include <br />

#include <br />

#include <br />

...<br />

time_t time_of_day;<br />

...<br />

{ struct utimbuf file_times;<br />

time_of_day = time_of_day;<br />

file_times.actime = time_of_day;<br />

file_times.modtime = time_of_day;<br />

utime("/my_dir/my_file", &file_times);<br />

}<br />

...<br />

Return Values<br />

If the utime() function completes successfully, it returns 0; otherwise, utime() sets errno<br />

to identify the specific error <strong>and</strong> returns -1.<br />

7859 6137–009 5–133


utime()<br />

Error Codes<br />

If any of the following conditions occurs, the utime() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EACCES Either of the following errors occurred:<br />

• The calling process is denied search permission on a directory in<br />

the path name.<br />

• times is a null pointer, <strong>and</strong> all of the following are true:<br />

− The effective user ID of the calling process does not match<br />

the user ID of the owner of the file.<br />

− The calling process is denied write permission to the file.<br />

− The process is not privileged.<br />

EFAULT The pointer specified by path is invalid.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

EPERM All of the following are true:<br />

• times is not null.<br />

• The effective user ID of the calling process does not match the<br />

file's owner.<br />

• The process is not privileged.<br />

5–134 7859 6137–009


vfprintf()<br />

Application<br />

Use the vfprintf() function to write <strong>for</strong>matted output.<br />

Synopsis<br />

int vfprintf(FILE * stream, const char * <strong>for</strong>mat, va_list arg);<br />

Description<br />

vfprintf()<br />

The vfprintf() function is equivalent to fprintf(). The variable argument list is replaced by<br />

arg, which has been initialized by va_start() <strong>and</strong> possibly by subsequent calls to va_arg().<br />

The vfprintf() function does not call va_end().<br />

Return Values<br />

If it completes successfully, the vfprintf() function returns the number of characters<br />

transmitted. Otherwise, vfprintf() returns a negative value.<br />

7859 6137–009 5–135


vprintf()<br />

vprintf()<br />

Application<br />

Use the vprintf() function to write <strong>for</strong>matted output to the st<strong>and</strong>ard output.<br />

Synopsis<br />

int vprintf(const char * <strong>for</strong>mat, va_list arg);<br />

Description<br />

The vprintf() function is equivalent to printf(). The variable argument list is replaced by<br />

arg, which has been initialized by va_start() <strong>and</strong> possibly by subsequent calls to va_arg().<br />

The vprintf() function does not call va_end().<br />

Return Values<br />

If it completes successfully, the vprintf() function returns the number of characters<br />

transmitted. Otherwise, vprintf() returns a negative value.<br />

5–136 7859 6137–009


vsprintf()<br />

Application<br />

Use the vsprintf() function to write <strong>for</strong>matted output to a character array.<br />

Synopsis<br />

int vsprintf(char * s, const char * <strong>for</strong>mat, va_list arg);<br />

Description<br />

vsprintf()<br />

The vsprintf() function is equivalent to sprintf(). The variable argument list is replaced by<br />

arg, which has been initialized by va_start() <strong>and</strong> possibly by subsequent calls to va_arg().<br />

The vsprintf() function does not call va_end().<br />

Return Values<br />

If it completes successfully, the vsprintf() function returns the number of characters<br />

written to the array, not counting the terminating nul character.<br />

7859 6137–009 5–137


write()<br />

write()<br />

Application<br />

Use the write() function to write data to a file at the current read/write position. Use the<br />

lseek() function to reposition the read/write offset. See the following subsections <strong>for</strong><br />

more in<strong>for</strong>mation: “Determining the Number of Bytes Written,” “Starting Position <strong>for</strong><br />

Different File Types,” “Writing Different File Types,” <strong>and</strong> “Translating Special<br />

Characters.”<br />

Synopsis<br />

ssize_t write(int fildes, const void * buf, size_t nbyte);<br />

Description<br />

The write() function writes data from a buffer to an open file, where:<br />

fildes<br />

buf<br />

nbyte<br />

is a file descriptor.<br />

is a pointer to the buffer holding the data.<br />

is the number of bytes to be written, which is limited by the size of a data bank.<br />

Attempting to Write Beyond the Limits<br />

The write() function fails if the file position exceeds the maximum size of the file.<br />

Return Values<br />

If the write() function completes successfully, it does the following:<br />

• Updates the st_atime <strong>and</strong> st_mtime fields (see the fstat() <strong>and</strong> stat() functions) of the<br />

file, if the function wrote any bytes<br />

• Returns the number of bytes actually written to the file<br />

Otherwise, write() sets errno to identify the specific error <strong>and</strong> returns -1.<br />

5–138 7859 6137–009


Error Codes<br />

write()<br />

If any of the following conditions occurs, the write() function returns -1 <strong>and</strong> sets errno to<br />

the corresponding value:<br />

EAGAIN The O_NONBLOCK flag is set, the calling process is writing to a pipe<br />

or FIFO, <strong>and</strong> one of the following conditions occurred:<br />

• The pipe or FIFO is full.<br />

• The pipe or FIFO does not have nbyte space available.<br />

EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

EFAULT One of the following errors occurred:<br />

• buf points to an invalid address, <strong>and</strong> nbyte is greater than 0.<br />

• buf is valid, but (buf+(nbyte-1)) points to an invalid address.<br />

EFBIG The calling process is attempting to write at a starting position beyond<br />

the highest position allowed <strong>for</strong> the file.<br />

EIO A disk error occurred.<br />

EPIPE One of the following errors occurred:<br />

• An attempt is made to write to a pipe or FIFO file that is not open<br />

<strong>for</strong> reading by any process.<br />

• While waiting <strong>for</strong> room in a pipe, all file descriptors open <strong>for</strong><br />

reading the pipe are closed.<br />

Determining the Number of Bytes Written<br />

The write() function returns the number of bytes actually written from the buffer to the<br />

file, which is never greater than nbyte. The following paragraphs relate this return value<br />

to the input value of nbyte.<br />

Return Value = nbyte > 0<br />

The write() function wrote <strong>and</strong> stored the exact number of bytes requested.<br />

Return Value < nbyte<br />

The value returned is less than nbyte if one of the following statements is true:<br />

• Fewer than nbyte bytes can be written without exceeding the maximum size of the<br />

file.<br />

• The file is a pipe or FIFO that has fewer than nbyte bytes immediately available <strong>for</strong><br />

writing.<br />

Return Value = 0<br />

The value returned is 0 if the value of nbyte is 0.<br />

Starting Position <strong>for</strong> Different File Types<br />

The file type determines the first byte in the file to be written, as shown in the following<br />

paragraphs.<br />

7859 6137–009 5–139


write()<br />

Regular Files<br />

The function starts at the current position of the read/write offset associated with the<br />

open file description corresponding to fildes. Be<strong>for</strong>e returning, write() increases the<br />

read/write offset by the number of bytes written to the file.<br />

If the O_APPEND flag associated with the open file description corresponding to fildes is<br />

set, the read/write offset is set to the end of the file immediately be<strong>for</strong>e each write<br />

operation.<br />

Writing data to locations beyond the end of the file causes the file to exp<strong>and</strong><br />

automatically.<br />

Pipes <strong>and</strong> FIFO Files<br />

The function starts at the current position associated with the file corresponding to<br />

fildes.<br />

Writing to Different File Types<br />

The file type determines the behavior of the write() function, as shown in the following<br />

paragraphs.<br />

Regular Files<br />

Data accumulates in buffers, which are written to nonvolatile storage when all processes<br />

have closed the file (see the close() function).<br />

Pipes <strong>and</strong> FIFO Files<br />

Pipes <strong>and</strong> FIFO files have a storage capacity of 7,168 bytes to store data until it is read.<br />

No data is written to nonvolatile storage.<br />

If the pipe or FIFO file is full, a process must wait <strong>for</strong> data to be read from it be<strong>for</strong>e<br />

writing data to it. The O_NONBLOCK flag associated with the open file description<br />

corresponding to fildes (see the open() <strong>and</strong> fcntl() functions) determines the behavior of<br />

write() <strong>for</strong> pipes <strong>and</strong> FIFO files, as follows:<br />

5–140 7859 6137–009


O_NONBLOCK<br />

Set write() does one of the<br />

following:<br />

Value of nbyte<br />

≤ 7,168* > 7,168**<br />

• Successfully writes all<br />

the data<br />

• Returns an error<br />

condition if there is not<br />

room <strong>for</strong> all the data<br />

Clear write() waits <strong>for</strong> room in<br />

the file <strong>for</strong> all the data<br />

write() does one of the<br />

following:<br />

• Writes as much data as<br />

immediately possible <strong>and</strong><br />

returns the number of<br />

bytes written. (If the pipe<br />

or FIFO file is empty,<br />

write() transfers 7,168<br />

bytes.)<br />

• Returns an error condition<br />

if the pipe or FIFO file is<br />

full.<br />

write()<br />

write() transfers data to the<br />

pipe, not returning until one of<br />

the following occurs:<br />

• The nbyte bytes are<br />

written<br />

• If the pipe is empty,<br />

write() transfers at least<br />

7,168 bytes be<strong>for</strong>e<br />

returning.<br />

* If a process writes 7,168 bytes or less to a pipe, the data in the pipe is guaranteed to be<br />

contiguous.<br />

** If a process writes more than 7,168 bytes to a pipe, the data can alternate with data from<br />

other processes writing to the pipe.<br />

The call returns an error condition if one of the following occurs:<br />

• No process has the pipe open <strong>for</strong> reading.<br />

• While write() is waiting <strong>for</strong> data to be read from a pipe, all file descriptors open <strong>for</strong><br />

reading the pipe are closed.<br />

Translating Special Characters<br />

The newline (\n) characters have special meaning <strong>for</strong> a write operation when fildes refers<br />

to stdout, stderr, or an SDF file. The newline character causes write() to write the<br />

characters preceding the newline since the end of the last line as either of the following:<br />

• One line to stdout or stderr<br />

• One image to the SDF file<br />

7859 6137–009 5–141


xlate()<br />

xlate()<br />

Application<br />

Use the _cifs_xlate() function to set or retrieve the translation attributes <strong>for</strong> a directory.<br />

Note: There is no P<strong>OS</strong>IX equivalent to _cifs_xlate().<br />

Synopsis<br />

int _cifs_xlate(const char * path, enum xlate_func func, char * ccs_in,<br />

char * ccs_out);<br />

Description<br />

The path parameter specifies the directory <strong>for</strong> which translation in<strong>for</strong>mation is set or<br />

retrieved. The func setting must be one of the following: XLATE_GET, XLATE_SET_IN,<br />

XLATE_SET_OUT, or XLATE_SET_BOTH.<br />

For XLATE_GET, ccs_in <strong>and</strong> ccs_out specify where to return the coded character set<br />

(CCS) names <strong>for</strong> the directory; the resulting values will be empty strings if translation is<br />

not enabled <strong>for</strong> the specified directory.<br />

For XLATE_SET_IN <strong>and</strong> XLATE_SET_BOTH, ccs_in is the CCS name used to establish<br />

the translation mode <strong>for</strong> files written into the directory; an empty string turns off<br />

translation.<br />

For XLATE_SET_OUT, ccs_out is the CCS name used to establish the translation mode<br />

<strong>for</strong> files read from the directory; an empty string turns off translation.<br />

See the <strong>CIFS</strong>UT xlate comm<strong>and</strong> <strong>for</strong> a list of valid CCS names.<br />

Return Values<br />

If the _cifs_xlate() function completes successfully, it returns zero. Otherwise, it returns<br />

-1 <strong>and</strong> sets an errno value.<br />

Error Codes<br />

If errors are detected, _cifs_xlate() returns -1 <strong>and</strong> sets errno to an appropriate value.<br />

Some of the possible values are:<br />

ECCSNAME One or both of the requested CCS names is not known to<br />

<strong>CIFS</strong>.<br />

ENOTDIR The requested path is not a directory.<br />

5–142 7859 6137–009


Section 6<br />

COBOL Program Interfaces<br />

This section lists the COBOL copy procs <strong>and</strong> application program interfaces (APIs)<br />

supplied by the <strong>CIFS</strong>LIB component.<br />

Table of UCOB COPY PROCS<br />

The following table lists the UCOB COPY PROCS that are available to <strong>CIFS</strong> programs.<br />

These PROCS are in the element <strong>CIFS</strong>-DEF in the file SYS$LIB$*<strong>CIFS</strong>$LIB.<br />

Proc Name Description<br />

<strong>CIFS</strong>-AMODE Contains definitions <strong>for</strong> <strong>CIFS</strong>$ACCESS<br />

<strong>CIFS</strong>-API Contains definitions <strong>for</strong> the <strong>CIFS</strong> status definitions<br />

<strong>CIFS</strong>-DIR Contains definitions <strong>for</strong> a DIR variable <strong>for</strong> directory service<br />

subprograms<br />

<strong>CIFS</strong>-FCNTL Contains definitions <strong>for</strong> the cifs-flock-struct variable <strong>for</strong> file<br />

locking <strong>and</strong> cifs-fcntl-cmd variable <strong>for</strong> file control operations<br />

<strong>CIFS</strong>-FILE Contains definitions <strong>for</strong> a FILE variable <strong>for</strong> stream service<br />

subprograms<br />

<strong>CIFS</strong>-FP<strong>OS</strong> Contains definitions <strong>for</strong> the cifs-fpos variable <strong>for</strong> file positioning<br />

<strong>CIFS</strong>-MODE Contains definitions <strong>for</strong> the cifs-mode variable <strong>for</strong> <strong>CIFS</strong>$OPEN,<br />

<strong>CIFS</strong>$CHMOD, <strong>and</strong> so on<br />

<strong>CIFS</strong>-OFLAG Contains definitions <strong>for</strong> the cifs-oflag variable <strong>for</strong> <strong>CIFS</strong>$OPEN<br />

<strong>CIFS</strong>-STAT Contains definitions <strong>for</strong> the cifs-stat <strong>and</strong> cifs-istat data item <strong>for</strong><br />

<strong>CIFS</strong>$STAT <strong>and</strong> <strong>CIFS</strong>$ISTAT<br />

<strong>CIFS</strong>-XLATE Contains definitions <strong>for</strong> the cifs-xlate variable <strong>for</strong> <strong>CIFS</strong>$XLATE<br />

comm<strong>and</strong>s<br />

7859 6137–009 6–1


Table of UCOB APIs<br />

Table of UCOB APIs<br />

The following UCOB APIs are available <strong>for</strong> use from <strong>CIFS</strong> programs.<br />

<strong>CIFS</strong> Call Parameters<br />

CALL "<strong>CIFS</strong>$ACCESS" USING PATH, <strong>CIFS</strong>-AMODE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CHDIR" USING PATH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CHMOD" USING PATH, <strong>CIFS</strong>-MODE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CHOWN" USING PATH, OWNER, GROUP, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CLEARERR" USING <strong>CIFS</strong>-FILE<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>E" USING FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>EDIR" USING <strong>CIFS</strong>-DIR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CREAT" USING PATH, <strong>CIFS</strong>-MODE, NEW-FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$DUP" USING OLD-FD, NEW-FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$DUP2" USING FD-1, FD-2, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FCL<strong>OS</strong>E" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FCNTL" USING FD, FCNTL-CMD, CMD-PARAM, RETURN-VALUE,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FDATASYNC" USING FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FDOPEN" USING FD, TYPE, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FEOF" USING <strong>CIFS</strong>-FILE, EOF-FLAG<br />

CALL "<strong>CIFS</strong>$FERROR" USING <strong>CIFS</strong>-FILE, ERROR-FLAG<br />

CALL "<strong>CIFS</strong>$FFLUSH" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FGETC" USING <strong>CIFS</strong>-FILE, NEXT-CHAR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FGETP<strong>OS</strong>" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-FP<strong>OS</strong>, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FGETS" USING STRING, MAX-CHARS, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FILENO" USING <strong>CIFS</strong>-FILE, FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FOPEN" USING PATH, TYPE-STRING, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING CHARS-OUT, <strong>CIFS</strong>-FILE, FORMAT-STRING[, ITEM...]<br />

CALL "<strong>CIFS</strong>$FPUTC" USING CHAR, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FPUTS" USING STRING, <strong>CIFS</strong>-FILE, CHARS-OUT, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FREAD" USING BUFFER, ELT-SIZE, ELT-COUNT, <strong>CIFS</strong>-FILE, ELTS-READ,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FREOPEN" USING PATH, TYPE-STRING, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FSCANF" USING ITEMS-SCANNED, <strong>CIFS</strong>-FILE, FORMAT-STRING[, ITEM...]<br />

CALL "<strong>CIFS</strong>$FSEEK" USING <strong>CIFS</strong>-FILE, OFFSET, WHENCE, <strong>CIFS</strong>-STATUS<br />

6–2 7859 6137–009


<strong>CIFS</strong> Call Parameters<br />

CALL "<strong>CIFS</strong>$FSETP<strong>OS</strong>" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-FP<strong>OS</strong>, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FSTAT" USING FD, <strong>CIFS</strong>-STAT, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FSYNC" USING FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FTELL" USING <strong>CIFS</strong>-FILE, OFFSET, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FTRUNCATE" USING FD, LENGTH, <strong>CIFS</strong>-STATUS<br />

Table of UCOB APIs<br />

CALL "<strong>CIFS</strong>$FWRITE" USING BUFFER, ELT-SIZE, ELT-COUNT, <strong>CIFS</strong>-FILE, ELTS-WRITTEN,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$GETC" USING <strong>CIFS</strong>-FILE, NEXT-CHAR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$GETCHAR" USING NEXT-CHAR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$GETCWD" USING PATH-BUFFER, MAX-SIZE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$GETS" USING STRING, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$ISTAT" USING INO, <strong>CIFS</strong>-ISTAT, SIZE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$LINK" USING PATH1, PATH2, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$LSEEK" USING FD, OFFSET, WHENCE, NEW-OFFSET, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$MASK" USING NAME, MASK, RESULT<br />

CALL "<strong>CIFS</strong>$MKDIR" USING PATH, <strong>CIFS</strong>-MODE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$MKFIFO" USING PATH, <strong>CIFS</strong>-MODE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$OPEN" USING PATH, <strong>CIFS</strong>-OFLAG, <strong>CIFS</strong>-MODE, NEW-FD, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$OPENDIR" USING PATH, <strong>CIFS</strong>-DIR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$PACK" USING PATH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS, MSG-STR<br />

CALL "<strong>CIFS</strong>$PIPE" USING FD-PAIR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$PRINTF" USING CHARS-OUT, FORMAT-STRING[, ITEM...]<br />

CALL "<strong>CIFS</strong>$PUTC" USING CHAR, <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$PUTCHAR" USING CHAR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$PUTS" USING STRING, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$READ" USING FD, BUFFER, BYTES-TO-READ, BYTES-READ, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$READDIR" USING <strong>CIFS</strong>-DIR, ENTRY-INO, ENTRY-NAME, MAX-LEN, TRUE-LEN,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$REMOVE" USING PATH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$RENAME" USING OLD-PATH, NEW-PATH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$REWIND" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$REWINDDIR" USING <strong>CIFS</strong>-DIR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$RMDIR" USING PATH, <strong>CIFS</strong>-STATUS<br />

7859 6137–009 6–3


Table of UCOB APIs<br />

<strong>CIFS</strong> Call Parameters<br />

CALL "<strong>CIFS</strong>$SCANF" USING ITEMS-SCANNED, FORMAT-STRING[, ITEM...]<br />

CALL "<strong>CIFS</strong>$SHARE" USING PATH, SHARE-NAME, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$SPRINTF" USING CHARS-OUT, DEST-STRING, FORMAT-STRING[, ITEM…]<br />

CALL "<strong>CIFS</strong>$SSCANF" USING ITEMS-SCANNED, SCAN-STRING, FORMAT-STRING[, ITEM...]<br />

CALL "<strong>CIFS</strong>$STAT" USING PATH, <strong>CIFS</strong>-STAT, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$STDERR" USING <strong>CIFS</strong>-FILE<br />

CALL "<strong>CIFS</strong>$STDIN" USING <strong>CIFS</strong>-FILE<br />

CALL "<strong>CIFS</strong>$STDOUT" USING <strong>CIFS</strong>-FILE<br />

CALL "<strong>CIFS</strong>$STRERROR" USING ERRNUM, MESSAGE-STRING[, INSERT-STRING…]<br />

CALL "<strong>CIFS</strong>$TMPFILE" USING <strong>CIFS</strong>-FILE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$TMPNAM" USING NAME-STRING, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$TRUNCATE" USING PATH, LENGTH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$UMASK" USING NEW-<strong>CIFS</strong>-MODE, OLD-<strong>CIFS</strong>-MODE, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$UNAME" USING <strong>CIFS</strong>-SS-BDI, <strong>CIFS</strong>-SS-NAME, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$UNGETC" USING PREV-CHAR, <strong>CIFS</strong>-FILE, RTN-CHAR, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$UNLINK" USING PATH, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$UTIME" USING PATH, <strong>CIFS</strong>-UTIMBUF, <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$WRITE" USING FD, BUFFER, BYTES-TO-WRITE, BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$XLATE" USING PATH, <strong>CIFS</strong>-XLATE, CCS-IN, CCS-OUT, <strong>CIFS</strong>-STATUS<br />

6–4 7859 6137–009


<strong>CIFS</strong>$ACCESS<br />

Application<br />

<strong>CIFS</strong>$ACCESS<br />

Use the cifs$access service subprogram to determine if either of the following is true:<br />

• A file exists.<br />

• The calling process has permission to access a file.<br />

Synopsis<br />

CALL "cifs$access" USING path, cifs-amode, cifs-status.<br />

Description<br />

The cifs$access service subprogram checks file permissions or existence, where:<br />

path<br />

is a nul-terminated character string that contains the path name of the file.<br />

cifs-amode<br />

is a 1-word ( 1(36) BINARY-1 ) item that is used to determine what condition to<br />

check <strong>for</strong>. Use the COBOL COPY PROC <strong>CIFS</strong>-AMODE in order to get the proper<br />

declarations. Set the following data items based upon the condition you are checking<br />

<strong>for</strong>:<br />

• File permissions<br />

Set the following variables that are within the <strong>CIFS</strong>-AMODE COPY PROC:<br />

− <strong>CIFS</strong>-AMODE-R-OK (Check <strong>for</strong> read permission)<br />

− <strong>CIFS</strong>-AMODE-W-OK (Check <strong>for</strong> write permission)<br />

− <strong>CIFS</strong>-AMODE-X-OK (Check <strong>for</strong> search/execute permission)<br />

• File existence<br />

cifs-status<br />

Set the variable <strong>CIFS</strong>-AMODE-F-OK in order to check whether the file or<br />

directory exists.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Checking File Permissions<br />

The cifs$access service subprogram checks each permission requested in cifs-amode.<br />

The service subprogram uses the real user ID <strong>and</strong> real group-ID of the calling process to<br />

decide which file permission class (owner, group, or other) to check.<br />

7859 6137–009 6–5


<strong>CIFS</strong>$ACCESS<br />

Return Values<br />

The cifs$access service subprogram returns 0 in the cifs-status parameter if all the<br />

specified access permissions are allowed or if the file exists (whichever was requested).<br />

Otherwise, cifs$access sets cifs-status to identify the specific error that was<br />

encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$access service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES Either of the following errors occurred:<br />

• One or more permissions specified by cifs-amode are denied.<br />

• The calling process is denied search permission on a directory<br />

in the path name.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-EINVAL An invalid value was specified <strong>for</strong> cifs-amode.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path prefix is not a directory.<br />

6–6 7859 6137–009


Example<br />

<strong>CIFS</strong>$ACCESS<br />

SPECIAL-NAMES.<br />

SYMBOLIC nul IS 1.<br />

:<br />

WORKING-STORAGE SECTION.<br />

COPY <strong>CIFS</strong>-API.<br />

COPY <strong>CIFS</strong>-AMODE.<br />

01 <strong>CIFS</strong>-AMODE PIC 1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-AMODE-BITS REDEFINES <strong>CIFS</strong>-AMODE.<br />

03 FILLER PIC 1(32) BINARY-1.<br />

03 <strong>CIFS</strong>-AMODE-F-OK PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-AMODE-R-OK PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-AMODE-W-OK PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-AMODE-X-OK PIC 1 BINARY-1.<br />

01 ARGUMENT-1.<br />

03 ARG1 PIC X(11).<br />

03 FILLER PIC X VALUE NUL.<br />

:<br />

MOVE 'aaaaa/b.txt' TO ARG1 OF ARGUMENT-1.<br />

MOVE 1 TO <strong>CIFS</strong>-AMODE-F-OK.<br />

CALL "<strong>CIFS</strong>$ACCESS" USING ARGUMENT-1,<br />

<strong>CIFS</strong>-AMODE,<br />

<strong>CIFS</strong>-STATUS.<br />

DISPLAY 'The <strong>CIFS</strong>-STATUS returned from <strong>CIFS</strong>$OPEN is ' <strong>CIFS</strong>-STATUS.<br />

* Check if an invalid file or path error was returned<br />

IF <strong>CIFS</strong>-ENOENT<br />

DISPLAY 'Invalid directory or file'.<br />

* If status returned is non-zero, call routine to print the error<br />

IF <strong>CIFS</strong>-STATUS NOT EQUAL 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS.<br />

7859 6137–009 6–7


<strong>CIFS</strong>$CHDIR<br />

<strong>CIFS</strong>$CHDIR<br />

Application<br />

Use the cifs$chdir service subprogram to change to a different current working directory.<br />

Synopsis<br />

CALL "cifs$chdir" USING path, cifs-status.<br />

Description<br />

The cifs$chdir service subprogram changes the current working directory of the calling<br />

process, where path identifies the new directory.<br />

path<br />

is a nul-terminated character string that contains the path name of the file.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$chdir service subprogram completes successfully, it returns a value of 0 in the<br />

cifs-status parameter. Otherwise, cifs$chdir sets cifs-status to identify the specific error<br />

that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$chdir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES<br />

The calling process is denied search permission to a directory<br />

in the path name.<br />

<strong>CIFS</strong>- EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-ENOENT<br />

Either of the following errors occurred:<br />

• The directory does not exist.<br />

• path points to an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name is not a directory.<br />

6–8 7859 6137–009


<strong>CIFS</strong>$CHMOD<br />

Application<br />

<strong>CIFS</strong>$CHMOD<br />

Use the cifs$chmod service subprogram to change the file permissions <strong>and</strong> program file<br />

types of the mode <strong>for</strong> a file.<br />

Privilege Requirement<br />

For a process to change the file permissions <strong>and</strong> program file types of a file, the user ID<br />

of the process must be equal to the user ID of the file.<br />

Synopsis<br />

CALL "cifs$chmod" USING path, cifs-mode, cifs-status.<br />

Description<br />

The cifs$chmod service subprogram changes the file permissions <strong>and</strong> program file types<br />

bits, where:<br />

path<br />

is a nul-terminated character string that contains the path name of the file that is to<br />

have its permissions modified.<br />

cifs-mode<br />

is a 1-word (1(36) BINARY-1) data item that contains the new settings <strong>for</strong> the file<br />

permissions <strong>and</strong> program file types. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong><br />

the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Open Files <strong>and</strong> Directory Streams<br />

Any process with an open directory stream or a file descriptor to an open file can<br />

continue accessing the stream or file, even if the cifs$chmod service subprogram<br />

changes the permission bits.<br />

7859 6137–009 6–9


<strong>CIFS</strong>$CHMOD<br />

Changing File Permissions <strong>and</strong> Special File Attributes<br />

If the process is allowed to change the file permissions of a file, cifs$chmod sets the file<br />

permissions in the file mode to the values specified in cifs-mode. The cifs-mode data<br />

item can be found in the COPY PROC <strong>CIFS</strong>-MODE, which looks as follows:<br />

Return Values<br />

01 <strong>CIFS</strong>-MODE PIC 1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-MODE-BITS REDEFINES <strong>CIFS</strong>-MODE.<br />

03 <strong>CIFS</strong>-MODE-1100BIN PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-1100SDF PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-DIRECT PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-LEPF PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-NPF PIC 1 BINARY-1.<br />

03 FILLER PIC 1(11) BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-SDF-ELEMENT PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-BIN-ELEMENT PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-UNKNOWN PIC 1 BINARY-1.<br />

03 FILLER PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-REGULAR PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-DIRECTORY PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-CHARACTER PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-PIPE PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-ISUID PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-ISGID PIC 1 BINARY-1.<br />

03 FILLER PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-IRWXU PIC 111 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-IRWXG PIC 111 BINARY-1.<br />

03 <strong>CIFS</strong>-MODE-IRWXO PIC 111 BINARY-1.<br />

77 <strong>CIFS</strong>-MODE-IREAD PIC 1(36) BINARY-1 VALUE 4.<br />

77 <strong>CIFS</strong>-MODE-IWRITE PIC 1(36) BINARY-1 VALUE 2.<br />

77 <strong>CIFS</strong>-MODE-IEXEC PIC 1(36) BINARY-1 VALUE 1.<br />

If the cifs$chmod service subprogram completes successfully, it returns a value of 0 in<br />

the cifs-status parameter <strong>and</strong> updates the time of last access <strong>for</strong> the file. Otherwise,<br />

cifs$chmod sets cifs-status to identify the specific error that was encountered.<br />

6–10 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$CHMOD<br />

If any of the following conditions occurs, the cifs$chmod service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES The calling process is denied search permission to a<br />

directory in the path name.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-EINVAL Any of the following errors occurred:<br />

• cifs-mode has undefined bits set.<br />

• cifs-mode has bits set that cifs$chmod cannot<br />

change.<br />

• A path name component is longer than 4095<br />

characters.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name is not a directory.<br />

<strong>CIFS</strong>-EPERM Both of the following conditions are true:<br />

• The effective user ID does not match the owner of<br />

the file or directory.<br />

• The process is privileged.<br />

7859 6137–009 6–11


<strong>CIFS</strong>$CHOWN<br />

<strong>CIFS</strong>$CHOWN<br />

Application<br />

Use the cifs$chown service subprogram to change the security attributes (user ID <strong>and</strong><br />

group ID) of a file, assigning the file to a different owner <strong>and</strong> group. If the value of the<br />

<strong>CIFS</strong>$ACR environment variable is not blank, that value (public, private, or ACR name)<br />

can also be applied to the specified file.<br />

For a process to change the security attributes of a file, one of the following must be<br />

true:<br />

• The user ID of the process is equal to the user ID of the file.<br />

• The process is privileged.<br />

Synopsis<br />

CALL "cifs$chown" USING path, owner, group, cifs-status.<br />

Description<br />

The cifs$chown service subprogram changes the user ID <strong>and</strong> group ID of a file, where:<br />

path<br />

owner<br />

group<br />

is a nul-terminated character string that contains the path name of the file.<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the new user ID <strong>for</strong> the file.<br />

If owner = -1, the user ID is unchanged.<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the new group ID <strong>for</strong> the file.<br />

If group = -1, the group ID is unchanged. If both owner = -1 <strong>and</strong> group = -1, both the<br />

user ID <strong>and</strong> group ID are unchanged; there<strong>for</strong>e, cifs$chown changes neither the time<br />

of last access field nor the file mode.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$chown service subprogram completes successfully, it does the following:<br />

• Updates the time of last access field of the file<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$chown sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–12 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$CHOWN<br />

If any of the following conditions occurs, the cifs$chown service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES The calling process is denied search permission to a<br />

directory in the path name.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-EINVAL owner or group is a value that can never possibly be a valid<br />

user ID or group ID.<br />

<strong>CIFS</strong>-<br />

ENAMETOOLONG<br />

A path name component is longer than 4095 characters.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name is not a directory.<br />

<strong>CIFS</strong>-EPERM Both of the following conditions exist:<br />

• The effective user ID does not match the owner of the<br />

file or directory.<br />

• The process is not privileged.<br />

7859 6137–009 6–13


<strong>CIFS</strong>$CLEARERR<br />

<strong>CIFS</strong>$CLEARERR<br />

Application<br />

Use the cifs$clearerr service subprogram to clear the end-of-file <strong>and</strong> error indicators <strong>for</strong><br />

the stream.<br />

Synopsis<br />

CALL "cifs$clearerr" USING cifs-file.<br />

Description<br />

The cifs$clearerr service subprogram clears the end-of-file <strong>and</strong> error indicators <strong>for</strong> a<br />

stream, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

The end-of-file <strong>and</strong> error indicators are cleared only at the following times:<br />

• When the file is opened<br />

• By an explicit call to one of the following service subprograms:<br />

− cifs$clearerr<br />

− cifs$fseek<br />

− cifs$rewind<br />

Return Values<br />

The cifs$clearerr service subprogram returns no value.<br />

6–14 7859 6137–009


<strong>CIFS</strong>$CL<strong>OS</strong>E<br />

Application<br />

<strong>CIFS</strong>$CL<strong>OS</strong>E<br />

Use the cifs$close service subprogram to release certain file attributes <strong>and</strong> prevent<br />

further access to a file through a specific file descriptor. Closing a file does the following:<br />

• Deallocates the specified file descriptor <strong>and</strong> makes it available <strong>for</strong> reuse by<br />

subsequent calls to other service subprograms, such as cifs$open <strong>and</strong> cifs$dup.<br />

Reusing file descriptors is important <strong>for</strong> redirecting the st<strong>and</strong>ard files (st<strong>and</strong>ard input,<br />

st<strong>and</strong>ard output, <strong>and</strong> st<strong>and</strong>ard error) to a pipe, <strong>for</strong> example.<br />

• Removes all record locks the calling process holds on the file. You might want to<br />

close a file to clear all locks you set on it, <strong>and</strong> then open the file again to access a<br />

different segment. This reduces lock conflicts <strong>for</strong> cooperating processes trying to<br />

access the same file.<br />

Synopsis<br />

CALL "cifs$close" USING fildes, cifs-status.<br />

Description<br />

The cifs$close service subprogram removes access to an open file description through a<br />

certain file descriptor, where fildes identifies the file descriptor. That is, the calling<br />

process can no longer use that file descriptor <strong>for</strong> input <strong>and</strong> output operations to the<br />

original file.<br />

fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be closed.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Additional Processing <strong>for</strong> the Last File Descriptor<br />

When fildes identifies the last file descriptor <strong>for</strong> the following file types, cifs$close does<br />

the additional processing specified:<br />

• Pipe or FIFO file<br />

cifs$close discards any data remaining in the pipe or FIFO file.<br />

• Open file description<br />

cifs$close discards the open file description.<br />

• File whose link count is 0<br />

cifs$close deletes the file <strong>and</strong> frees its space.<br />

7859 6137–009 6–15


<strong>CIFS</strong>$CL<strong>OS</strong>E<br />

Return Values<br />

If the cifs$close service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$close sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$close service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor.<br />

<strong>CIFS</strong>-EIO I/O error occurred while writing the file.<br />

6–16 7859 6137–009


<strong>CIFS</strong>$CL<strong>OS</strong>EDIR<br />

Application<br />

<strong>CIFS</strong>$CL<strong>OS</strong>EDIR<br />

Use the cifs$closedir service subprogram to close an open directory stream <strong>and</strong> make it<br />

inaccessible to the calling process. If no other processes share this directory stream,<br />

access to the stream is closed.<br />

If a process terminates, all effects of cifs$closedir occur <strong>for</strong> each directory stream open<br />

to the process.<br />

See cifs$opendir <strong>for</strong> opening directory, cifs$readdir <strong>for</strong> reading the next directory entry,<br />

<strong>and</strong> cifs$rewinddir <strong>for</strong> repositioning the stream at its beginning.<br />

Synopsis<br />

CALL "cifs$closedir" USING cifs-dir, cifs-status.<br />

Description<br />

The cifs$closedir service subprogram closes access to the directory stream by the calling<br />

process, where cifs-dir designates the directory stream to close. The directory stream<br />

must have been opened previously by the cifs$opendir service subprogram.<br />

cifs-dir<br />

is a 2-word (S1(72) BINARY-1) data item containing the directory stream to close.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-DIR <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$closedir service subprogram completes successfully, it does the following:<br />

• Updates the time of last access field <strong>for</strong> the directory<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$closedir sets cifs-status to identify the specific error that was<br />

encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$closedir service subprogram returns a<br />

nonzero value in the cifs-status parameter.<br />

7859 6137–009 6–17


<strong>CIFS</strong>$CL<strong>OS</strong>EDIR<br />

The following COBOL level 88 condition names (defined in the COBOL COPY PROC<br />

<strong>CIFS</strong>-API) can be checked in order to determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF cifs-dir is not a valid directory stream.<br />

<strong>CIFS</strong>-EFAULT cifs-dir is not a valid value.<br />

6–18 7859 6137–009


<strong>CIFS</strong>$CREAT<br />

Application<br />

<strong>CIFS</strong>$CREAT<br />

Use the cifs$creat service subprogram to create <strong>and</strong> open a new regular file, specifying<br />

how you can access it <strong>and</strong> setting its file permissions.<br />

Synopsis<br />

CALL "cifs$creat" USING path, cifs-mode, new-fd, cifs-status.<br />

Description<br />

The cifs$creat service subprogram call is the same as a special case of cifs$open, as<br />

follows:<br />

CALL "cifs$open" USING path, cifs-oflag, cifs-mode, new-fd, cifs-status.<br />

Where cifs-oflag has the fields <strong>CIFS</strong>-OFLAG-WRONLY, <strong>CIFS</strong>-OFLAG-CREAT <strong>and</strong> <strong>CIFS</strong>-<br />

OFLAG-TRUNC set.<br />

See the cifs$open service subprogram <strong>for</strong> details of the path, cifs-oflag <strong>and</strong> cifs-mode<br />

arguments.<br />

path<br />

is an alphanumeric variable that contains the name of the file to be opened.<br />

cifs-mode<br />

new-fd<br />

is a 1-word (1(36) BINARY-1) data item that sets the file permissions when a new file<br />

is created. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this<br />

variable. See “The cifs-mode Argument” <strong>and</strong> the <strong>CIFS</strong>-OFLAG-CREAT file status in<br />

the description of cifs$open <strong>for</strong> the valid values <strong>for</strong> cifs-mode.<br />

is a 1-word (S1(36) BINARY-1) data item into which the file description of the newly<br />

created file is placed.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Caution<br />

Using cifs$creat when a file of the same name exists truncates the file's<br />

length to 0.<br />

7859 6137–009 6–19


<strong>CIFS</strong>$CREAT<br />

Return Values<br />

If the cifs$creat service subprogram completes successfully, it returns the file descriptor<br />

<strong>for</strong> the new file into the new-fd parameter. Otherwise, cifs$creat sets cifs-status to<br />

identify the specific error that was encountered<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$creat service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-E1100FILE The system could not assign the <strong>OS</strong> <strong>2200</strong> file that contains the<br />

file's data space.<br />

<strong>CIFS</strong>-EACCES Either of the following errors occurred:<br />

• The calling process is denied search permission on a<br />

directory in the path name.<br />

• The calling process is denied write permission <strong>for</strong> the file<br />

or the parent directory of the file.<br />

<strong>CIFS</strong>-EAGAIN An attempt to create <strong>and</strong> open an imported file failed because<br />

the corresponding <strong>OS</strong> <strong>2200</strong> file existed but was rolled out or<br />

otherwise unavailable. This is a temporary condition; a<br />

subsequent attempt might succeed.<br />

<strong>CIFS</strong>-EFAULT The name specified by path is invalid.<br />

<strong>CIFS</strong>-EINTR The create operation was interrupted by a signal.<br />

<strong>CIFS</strong>-EINVAL cifs-mode has undefined bits set.<br />

<strong>CIFS</strong>-EIO An input/output error prevented completion of the request.<br />

<strong>CIFS</strong>-EISDIR The path name resolves to a directory.<br />

<strong>CIFS</strong>-EMFILE The calling process cannot create the file because the limit on<br />

the maximum number of open file descriptors <strong>for</strong> a process<br />

would be exceeded.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not exist.<br />

• path specifies an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC The directory or file system that is to contain the new file is out<br />

of available space.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name prefix is not a directory.<br />

6–20 7859 6137–009


<strong>CIFS</strong>$DUP<br />

Application<br />

<strong>CIFS</strong>$DUP<br />

Use the cifs$dup service subprogram to create an additional file descriptor <strong>for</strong> an existing<br />

open file description. This capability is important <strong>for</strong> redirecting st<strong>and</strong>ard files to a pipe,<br />

<strong>for</strong> example. The new file descriptor has the following properties:<br />

• Its value is the lowest number available <strong>for</strong> the process.<br />

• It shares the same open file description <strong>and</strong> file locks with the original file descriptor.<br />

You can also duplicate a file descriptor by setting the 88 level condition name<br />

<strong>CIFS</strong>-F-DUPFD to TRUE in the cifs$fcntl service subprogram. See the cifs$dup2 service<br />

subprogram <strong>for</strong> associating a specific file descriptor with an open file description.<br />

Synopsis<br />

CALL "cifs$dup" USING old-fildes, new-fildes, cifs-status.<br />

Description<br />

The cifs$dup service subprogram duplicates the file descriptor designated by old-fildes.<br />

The duplicated file descriptor occurs in the first available file descriptor location.<br />

old-fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be duplicated.<br />

new-fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the<br />

newly created file descriptor.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

7859 6137–009 6–21


<strong>CIFS</strong>$DUP<br />

Diagram<br />

The following diagram shows a duplicated file descriptor <strong>for</strong> an open file description:<br />

Return Values<br />

If the cifs$dup service subprogram completes successfully, it returns the index of the<br />

newly created file descriptor into the new-fildes parameter <strong>and</strong> it returns 0 in cifs-status.<br />

Otherwise, cifs$dup sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$dup service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF old-fildes is not a valid open file descriptor.<br />

<strong>CIFS</strong>-EMFILE The calling process exceeds the maximum number of file<br />

descriptors allowed.<br />

6–22 7859 6137–009


<strong>CIFS</strong>$DUP2<br />

Application<br />

<strong>CIFS</strong>$DUP2<br />

Use the cifs$dup2 service subprogram to associate a specific file descriptor index with<br />

an existing open file description. The new file descriptor shares the same open file<br />

description <strong>and</strong> file locks with the original file descriptor. See cifs$dup <strong>for</strong> creating an<br />

additional file descriptor <strong>for</strong> the open file description.<br />

Synopsis<br />

CALL "cifs$dup2" USING fildes1, fildes2, cifs-status.<br />

Description<br />

The cifs$dup2 service subprogram causes the file descriptor fildes2 to identify the same<br />

open file description as fildes1.<br />

If fildes2 exists <strong>and</strong> corresponds to an open file other than fildes1, cifs$dup2 first closes<br />

fildes2 (which can remove locks <strong>and</strong> the file itself; see the cifs$close service<br />

subprogram). If fildes1 <strong>and</strong> fildes2 are equal, cifs$dup2 does not duplicate or close any<br />

file descriptors.<br />

fildes1<br />

fildes2<br />

is a 1-word (S1(36) BINARY-1) data item which contains a file descriptor.<br />

is a 1-word (S1(36) BINARY-1) data item which contains a file descriptor.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

7859 6137–009 6–23


<strong>CIFS</strong>$DUP2<br />

Diagram<br />

The following diagram shows a specific file descriptor associated with an open file<br />

description:<br />

Return Values<br />

If the cifs$dup2 service subprogram completes successfully, it returns the value of<br />

fildes2, a file descriptor, <strong>and</strong> it returns 0 in cifs-status. Otherwise, cifs$dup sets<br />

cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$dup2 service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF One of the following errors occurred:<br />

• fildes1 is not a file descriptor.<br />

• fildes2 is either negative or greater than the maximum number<br />

of file descriptors allowed.<br />

6–24 7859 6137–009


<strong>CIFS</strong>$FCL<strong>OS</strong>E<br />

Application<br />

<strong>CIFS</strong>$FCL<strong>OS</strong>E<br />

Use the cifs$fclose service subprogram to write all remaining data in the buffer to a file<br />

<strong>and</strong> close the file.<br />

Synopsis<br />

CALL "cifs$fclose" USING cifs-file, cifs-status.<br />

Description<br />

The cifs$fclose service subprogram flushes any output buffer <strong>for</strong> a stream <strong>and</strong> closes<br />

the associated file, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item in which the value of the open instance of the file is stored.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fclose service subprogram successfully closes the stream, it returns 0 in the<br />

cifs-status argument. Otherwise, if it detects errors or if the stream was already closed,<br />

cifs$fclose returns a nonzero value in the cifs-status argument.<br />

7859 6137–009 6–25


<strong>CIFS</strong>$FCNTL<br />

<strong>CIFS</strong>$FCNTL<br />

Application<br />

Use the cifs$fcntl service subprogram to manage an open file in the following ways,<br />

which are described in following subsections:<br />

• Duplicate a file descriptor; see “File Descriptor Services.”<br />

• Retrieve in<strong>for</strong>mation about or change the values of the file status flags <strong>and</strong> access<br />

specification; see “File Status Flags <strong>and</strong> Access Specification Services.”<br />

• Manage advisory record locking services; see “Record Locking Services.”<br />

Synopsis<br />

CALL "cifs$fcntl USING fildes, cifs-fcntl-cmd, parm, return-value, cifsstatus.<br />

Description<br />

The cifs$fcntl service subprogram per<strong>for</strong>ms file services, where:<br />

fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of an<br />

open file.<br />

cifs-fcntl-cmd<br />

is a 1-word (1(36) BINARY-1) data item which indicates which service to per<strong>for</strong>m.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-FCNTL <strong>for</strong> the declaration of this variable. The<br />

cifs-fcntl-cmd field can be set to any of the COBOL level 88 names that are<br />

associated with it.<br />

It can have any value in the following table.<br />

Service<br />

Duplicate file<br />

descriptor<br />

Get flags <strong>and</strong><br />

in<strong>for</strong>mation<br />

Set flags <strong>and</strong><br />

in<strong>for</strong>mation<br />

*Wait if blocked<br />

File Descriptor<br />

File Status <strong>and</strong><br />

Access<br />

Specification<br />

<strong>CIFS</strong>-F-DUPFD – –<br />

– <strong>CIFS</strong>-F-GETFL<br />

<strong>CIFS</strong>-F-GETFD<br />

– <strong>CIFS</strong>-F-SETFL<br />

<strong>CIFS</strong>-F-SETFD<br />

Advisory Record<br />

Locking<br />

<strong>CIFS</strong>-F-GETLK<br />

<strong>CIFS</strong>-F-SETLK,<br />

<strong>CIFS</strong>-F-SETLKW*<br />

See the following subsections <strong>for</strong> detailed in<strong>for</strong>mation about each type of service.<br />

6–26 7859 6137–009


parm<br />

<strong>CIFS</strong>$FCNTL<br />

is an argument of varying type whose value depends on cifs-fcntl-cmd, as shown in<br />

the following table (see the following descriptions of the symbolic names <strong>for</strong> more<br />

in<strong>for</strong>mation about parm):<br />

If cifs-fcntl-cmd is ... Then parm is ...<br />

<strong>CIFS</strong>-F-DUPFD An integer giving the smallest desired value <strong>for</strong> the new file<br />

descriptor<br />

<strong>CIFS</strong>-F-GETFD,<br />

<strong>CIFS</strong>-F-GETFL<br />

<strong>CIFS</strong>-F-SETFD,<br />

<strong>CIFS</strong>-F-SETFL<br />

<strong>CIFS</strong>-F-GETLK, <strong>CIFS</strong>-F-<br />

SETLK, <strong>CIFS</strong>-F-SETLKW<br />

return-value<br />

Not required; it is ignored<br />

An integer giving the new setting <strong>for</strong> the status flags <strong>for</strong> the<br />

specified file descriptor<br />

The cifs-flock-struct group item that describes the locking<br />

request (can be used to unlock or change an existing lock)<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the return status.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Caution<br />

cifs$fcntl cannot determine if the third argument has the wrong type. Even if<br />

the type is incorrect, cifs$fcntl interprets the storage as the correct type,<br />

resulting in undefined <strong>and</strong> unpredictable behavior.<br />

Return Values<br />

If the cifs$fcntl service subprogram completes successfully, its return value in the<br />

argument return-value depends on cifs-fcntl-cmd, as follows:<br />

If cifs-fcntl-cmd is ... Then cifs$fcntl returns in return-value ...<br />

<strong>CIFS</strong>-F-DUPFD A new file descriptor<br />

<strong>CIFS</strong>-F-GETFD,<br />

<strong>CIFS</strong>-F-GETFL<br />

Any other value 0<br />

The values of the file status flags <strong>and</strong> file access<br />

specifications<br />

If the cifs$fcntl service subprogram completes successfully it returns 0 in cifs-status.<br />

Otherwise, cifs$fcntl sets cifs-status to identify the specific error that was encountered.<br />

7859 6137–009 6–27


<strong>CIFS</strong>$FCNTL<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fcntl service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EAGAIN cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETLK <strong>and</strong> one of the following is true:<br />

• L-TYPE is <strong>CIFS</strong>-F-WRLCK <strong>and</strong> another process owns a lock on<br />

some portion of the segment to be locked.<br />

• L-TYPE is <strong>CIFS</strong>-F-RDLCK <strong>and</strong> another process owns an<br />

exclusive lock on some portion of the segment to be locked.<br />

<strong>CIFS</strong>-EBADF Any of the following errors occurred:<br />

<strong>CIFS</strong>-EDEADL<br />

K<br />

• fildes is not a valid file descriptor.<br />

• The following conditions are all true:<br />

− cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETLK or <strong>CIFS</strong>-F-SETLKW.<br />

− L-TYPE is <strong>CIFS</strong>-F-RDLCK.<br />

− fildes is not a file descriptor open <strong>for</strong> reading.<br />

• The following conditions are all true:<br />

− cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETLK or <strong>CIFS</strong>-F-SETLKW.<br />

− L-TYPE is <strong>CIFS</strong>-F-WRLCK.<br />

− fildes is not a file descriptor open <strong>for</strong> writing.<br />

Both of the following conditions occurred:<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETLKW.<br />

• Suspending the process because of a conflict with the<br />

request would cause a deadlock.<br />

<strong>CIFS</strong>-EFAULT Both of the following conditions occurred:<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-GETLK, <strong>CIFS</strong>-F-SETLK, or <strong>CIFS</strong>-F-<br />

SETLKW.<br />

• parm is not a valid value.<br />

<strong>CIFS</strong>-EINTR Both of the following conditions occurred:<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETLKW.<br />

• The process received a signal be<strong>for</strong>e the locking request was<br />

granted.<br />

6–28 7859 6137–009


<strong>CIFS</strong>-EINVAL Any of the following errors occurred:<br />

• cifs-fcntl-cmd is not one of the valid values listed.<br />

<strong>CIFS</strong>$FCNTL<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-DUPFD <strong>and</strong> parm is less than 0 or<br />

greater than or equal to the maximum number of open files.<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-GETLK, <strong>CIFS</strong>-F-SETLK, or <strong>CIFS</strong>-F-<br />

SETLKW, <strong>and</strong> the cifs-flock-struct data item to which parm<br />

points is invalid.<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETFD, <strong>and</strong> the value of parm is not 0.<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-DUPFD, <strong>CIFS</strong>-F-SETFL, <strong>CIFS</strong>-F-GETLK,<br />

<strong>CIFS</strong>-F-SETLK, or <strong>CIFS</strong>-F-SETLKW <strong>and</strong> parm is not specified.<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-SETFL, <strong>and</strong> the value of parm has<br />

undefined bits set.<br />

<strong>CIFS</strong>-EMFILE Both of the following conditions occurred:<br />

• cifs-fcntl-cmd is <strong>CIFS</strong>-F-DUPFD.<br />

• No file descriptors greater than or equal to parm are available.<br />

<strong>CIFS</strong>-ENOLCK Both of the following conditions occurred:<br />

The cifs-flock-struct data item<br />

• cifs-fcntl-cmd is either <strong>CIFS</strong>-F-SETLK or <strong>CIFS</strong>-F-SETLKW.<br />

• Satisfying the lock or unlock request results in the number of<br />

locked regions <strong>for</strong> the process exceeding the maximum<br />

number of locks allowed <strong>for</strong> a process.<br />

The cifs-flock-struct data item provides in<strong>for</strong>mation to the kernel about the locking<br />

request. It also gives the process in<strong>for</strong>mation about existing locks. The following table<br />

describes the cifs-flock-struct data item, which is defined in the COBOL COPY PROC<br />

<strong>CIFS</strong>-FCNTL:<br />

Member<br />

Name Description Values<br />

l-len Number of<br />

consecutive bytes to<br />

be locked or unlocked<br />

l-pid Process ID of process<br />

owning a conflicting<br />

lock<br />

If positive, l-len bytes; if 0, to the end of the file<br />

(cannot be negative)<br />

Returned by <strong>CIFS</strong>-F-GETLK<br />

7859 6137–009 6–29


<strong>CIFS</strong>$FCNTL<br />

Member<br />

Name Description Values<br />

l-start Distance to the first<br />

byte in the lock from<br />

the address specified<br />

by l-whence<br />

l-type Request type, one of<br />

• Exclusive lock<br />

• Shared lock<br />

• Unlock<br />

l-whence File address at which<br />

to add l-start to find<br />

the first byte in the<br />

lock; either<br />

Illustration<br />

• Current position<br />

• End of file<br />

• Beginning of<br />

file<br />

Any integer (positive, negative, or 0)<br />

Notes:<br />

• The result of applying –l-start to<br />

l-whence must be ≥ 0. That is, the<br />

starting position of the lock cannot be<br />

be<strong>for</strong>e the beginning of the file.<br />

• If an <strong>CIFS</strong>-F-GETLK request finds a<br />

conflicting lock, the value of l-start<br />

identifies the first byte of the<br />

conflicting lock relative to the<br />

beginning of the file.<br />

<strong>CIFS</strong>-F-WRLCK, <strong>CIFS</strong>-F-RDLCK, <strong>CIFS</strong>-F-UNLCK<br />

Note: If an <strong>CIFS</strong>-F-GETLK request does not<br />

find a conflicting lock, the kernel changes the<br />

value of l-type to <strong>CIFS</strong>-F-UNLCK.<br />

<strong>CIFS</strong>-SEEK-CUR-WHENCE, <strong>CIFS</strong>-SEEK-END-<br />

WHENCE, <strong>CIFS</strong>-SEEK-SET-WHENCE<br />

Note: If an <strong>CIFS</strong>-F-GETLK request finds a<br />

conflicting lock, the value of l-whence is <strong>CIFS</strong>-<br />

SEEK-SET-WHENCE.<br />

Values in the flock structure determine how <strong>and</strong> where a lock is created on a file. Given<br />

specific values <strong>for</strong> the starting offset position (l-start) <strong>and</strong> length (l-len) of a desired lock,<br />

the value of l-whence determines whether the lock occurs at the beginning, current<br />

position, or end of a file, as shown in the following diagram:<br />

6–30 7859 6137–009


Locking <strong>and</strong> Unlocking Whole Files<br />

<strong>CIFS</strong>$FCNTL<br />

A process can lock or unlock an entire file if it sets a lock of zero length <strong>and</strong> zero offset<br />

that starts at the beginning of the file, as shown by the following values:<br />

• l-len = 0<br />

• l-start = 0<br />

• l-whence = <strong>CIFS</strong>-SEEK-SET-WHENCE<br />

Replacing <strong>and</strong> Merging Locks<br />

A successful <strong>CIFS</strong>-F-SETLK or <strong>CIFS</strong>-F-SETLKW request replaces the previous lock type<br />

<strong>for</strong> each byte in the specified region with the new lock type. Be<strong>for</strong>e returning, cifs$fcntl<br />

merges adjacent locks of the same type that are owned by the requesting process.<br />

For example, suppose a process owns shared locks on bytes 0 through 5 <strong>and</strong> bytes 7<br />

through 9 in a file. The process requests a shared lock on byte 6 (or on a range including<br />

byte 6). The result is a single shared lock on bytes 0 through 9.<br />

File Descriptor Services<br />

The symbolic names in this subsection are the values <strong>for</strong> cifs-fcntl-cmd that allow<br />

cifs$fcntl to duplicate a file descriptor (<strong>CIFS</strong>-F-DUPFD).<br />

<strong>CIFS</strong>-F-DUPFD —Duplicate File Descriptor<br />

This service requires an integer type <strong>for</strong> parm. The cifs$fcntl service subprogram creates<br />

<strong>and</strong> returns a new file descriptor with the following characteristics:<br />

• It is greater than or equal to parm.<br />

• It refers to the same open file description as fildes.<br />

7859 6137–009 6–31


<strong>CIFS</strong>$FCNTL<br />

File Descriptor Closure Mode Services<br />

The <strong>CIFS</strong>-F-GETFD <strong>and</strong> <strong>CIFS</strong>-F-SETFD flags can be used to set up multiactivity programs,<br />

but are currently not supported <strong>for</strong> COBOL.<br />

File Status Flags <strong>and</strong> Access Specification Services<br />

The symbolic names in this subsection are the values <strong>for</strong> cifs-fcntl-cmd that allow<br />

cifs$fcntl to<br />

• Retrieve the file status flags <strong>and</strong> file access specification (<strong>CIFS</strong>-F-GETFL)<br />

• Set the file status flags (<strong>CIFS</strong>-F-SETFL)<br />

File status flags <strong>and</strong> the file access specification are associated with an open file<br />

description. They do not indicate anything about other open file descriptions that<br />

reference the same file.<br />

<strong>CIFS</strong>-F-GETFL —Get File Status Flags <strong>and</strong> Access Specification<br />

The cifs$fcntl service subprogram returns the following values associated with fildes<br />

(see the cifs$open service subprogram <strong>for</strong> descriptions of its symbolic names):<br />

File Attribute Value Description<br />

File status flags <strong>CIFS</strong>-OFLAG-APPEND<br />

<strong>CIFS</strong>-OFLAG-DSYNC<br />

File access<br />

specification<br />

<strong>CIFS</strong>-OFLAG-NONBLOCK<br />

<strong>CIFS</strong>-OFLAG-SYNC<br />

<strong>CIFS</strong>-OFLAG-RDONLY<br />

<strong>CIFS</strong>-OFLAG-WRONLY<br />

parm is not required <strong>for</strong> this service <strong>and</strong> is ignored.<br />

<strong>CIFS</strong>-F-SETFL —Set File Status Flags<br />

Append mode<br />

Synchronize file data on read <strong>and</strong><br />

write operations<br />

No delay<br />

Synchronize file data <strong>and</strong> access<br />

times on read <strong>and</strong> write operations<br />

Open <strong>for</strong> reading<br />

Open <strong>for</strong> writing<br />

This service requires an integer type <strong>for</strong> parm containing the new settings <strong>for</strong> the file<br />

status flags in the open file description associated with fildes. For this service, cifs$fcntl<br />

ignores other bits in parm.<br />

If the result of an AND operation between parm <strong>and</strong> a file status constant is zero,<br />

cifs$fcntl clears the corresponding file status flag in the open file description; otherwise,<br />

cifs$fcntl sets the flag. In other words, you must set the flag in parm if you want it set in<br />

the open file description; if the flag is not set in parm, it is cleared in the open file<br />

description. The following constants set the corresponding file status flag:<br />

• <strong>CIFS</strong>-OFLAG-APPEND<br />

• <strong>CIFS</strong>-OFLAG-DSYNC<br />

• <strong>CIFS</strong>-OFLAG-NONBLOCK<br />

• <strong>CIFS</strong>-OFLAG-SYNC<br />

6–32 7859 6137–009


<strong>CIFS</strong>$FCNTL<br />

If both the <strong>CIFS</strong>-OFLAG-DSYNC <strong>and</strong> <strong>CIFS</strong>-OFLAG-SYNC flags are set (see the cifs$open<br />

service subprogram), the effect is the same as if only <strong>CIFS</strong>-OFLAG-SYNC is set.<br />

Calling cifs$fcntl with <strong>CIFS</strong>-F-GETFD<br />

The following code shows how to call cifs$fcntl to get the file status flags <strong>and</strong> file mode,<br />

where fd-a is an existing file descriptor:<br />

COPY <strong>CIFS</strong>-API.<br />

COPY <strong>CIFS</strong>-OFLAG.<br />

01 return-value PIC s1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-FCNTL-CMD PIC 1(36) BINARY-1.<br />

88 <strong>CIFS</strong>-F-DUPFD VALUE 0.<br />

88 <strong>CIFS</strong>-F-GETFD VALUE 1.<br />

88 <strong>CIFS</strong>-F-GETFL VALUE 2.<br />

88 <strong>CIFS</strong>-F-GETLK VALUE 3.<br />

88 <strong>CIFS</strong>-F-SETFD VALUE 4.<br />

88 <strong>CIFS</strong>-F-SETFL VALUE 5.<br />

88 <strong>CIFS</strong>-F-SETLK VALUE 6.<br />

88 <strong>CIFS</strong>-F-SETLKW VALUE 7.<br />

...<br />

set cifs-f-getfl to true.<br />

CALL "cifs$fcntl" USING fd-a, cifs-fcntl-cmd, 0,<br />

return-value, cifs-status.<br />

Interpreting the Results of Calling cifs$fcntl with <strong>CIFS</strong>-F-GETFL<br />

To extract the file access specification <strong>and</strong> file status flags from the result of<br />

<strong>CIFS</strong>-F-GETFL, do the following:<br />

01 <strong>CIFS</strong>-OFLAG PIC 1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-OFLAG-BITS REDEFINES <strong>CIFS</strong>-OFLAG.<br />

03 FILLER PIC 1(26) BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-SYNC PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-DSYNC PIC 1 BINARY-1.<br />

03 FILLER PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-EXCL PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-TRUNC PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-CREAT PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-APPEND PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-NONBLOCK PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-WRONLY PIC 1 BINARY-1.<br />

03 <strong>CIFS</strong>-OFLAG-RDONLY PIC 1 BINARY-1.<br />

...<br />

move return-value to cifs-oflag.<br />

At this point the user can check any of the file access specifications or file status fields<br />

by looking at the desired field in the <strong>CIFS</strong>-OFLAG-BITS data item.<br />

7859 6137–009 6–33


<strong>CIFS</strong>$FCNTL<br />

To determine if the file is open <strong>for</strong> reading from the result of <strong>CIFS</strong>-F-GETFL, check the<br />

<strong>CIFS</strong>-OFLAG-RDONLY:<br />

if cifs-oflag-rdonly = 1<br />

then<br />

* Code <strong>for</strong> readable file *<br />

...<br />

To determine if the file is open <strong>for</strong> appending data from the result of <strong>CIFS</strong>-F-GETFL,<br />

check the <strong>CIFS</strong>-OFLAG-APPEND:<br />

if cifs-oflag-append = 1<br />

then<br />

* Code <strong>for</strong> appending data *<br />

...<br />

Calling cifs$fcntl with <strong>CIFS</strong>-F-SETFL<br />

The following code shows how to call cifs$fcntl to set the <strong>CIFS</strong>-OFLAG-APPEND, <strong>CIFS</strong>-<br />

OFLAG-NONBLOCK, <strong>and</strong> <strong>CIFS</strong>-OFLAG-SYNC file status flags <strong>and</strong> clear the <strong>CIFS</strong>-OFLAG-<br />

DSYNC flag, where fd-a is an existing file descriptor:<br />

COPY <strong>CIFS</strong>-API.<br />

COPY <strong>CIFS</strong>-OFLAG.<br />

01 return-value PIC s1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-FNCTL-CMD PIC 1(36) BINARY-1.<br />

88 <strong>CIFS</strong>-F-DUPFD VALUE 0.<br />

88 <strong>CIFS</strong>-F-GETFD VALUE 1.<br />

88 <strong>CIFS</strong>-F-GETFL VALUE 2.<br />

88 <strong>CIFS</strong>-F-GETLK VALUE 3.<br />

88 <strong>CIFS</strong>-F-SETFD VALUE 4.<br />

88 <strong>CIFS</strong>-F-SETFL VALUE 5.<br />

88 <strong>CIFS</strong>-F-SETLK VALUE 6.<br />

88 <strong>CIFS</strong>-F-SETLKW VALUE 7.<br />

...<br />

move 1 to <strong>CIFS</strong>-OFLAG-APPEND.<br />

move 1 to <strong>CIFS</strong>-OFLAG-NONBLOCK.<br />

move 1 to <strong>CIFS</strong>-OFLAG-SYNC.<br />

set cifs-f-setfl to true.<br />

CALL "cifs$fcntl" USING fd-a, cifs-fcntl-cmd, cifs-oflag,<br />

return-value, cifs-status.<br />

6–34 7859 6137–009


Record Locking Services<br />

<strong>CIFS</strong>$FCNTL<br />

The symbolic names in this subsection are the values <strong>for</strong> cifs-fcntl-cmd that allow<br />

cifs$fcntl to retrieve (<strong>CIFS</strong>-F-GETLK) or set (<strong>CIFS</strong>-F-SETLK <strong>and</strong> <strong>CIFS</strong>-F-SETLKW) advisory<br />

record locks on any file or directory. They require parm to point to a flock data item<br />

(<strong>CIFS</strong>-FLOCK-STRUCT).<br />

<strong>CIFS</strong>-F-GETLK—Get Record-Locking In<strong>for</strong>mation<br />

The cifs$fcntl service subprogram searches <strong>for</strong> a lock owned by another process that<br />

conflicts with the lock description (shared or exclusive) in the flock data item indicated by<br />

parm. That is, the type <strong>and</strong> location of an existing lock would prevent the requested lock<br />

from being created. The behavior of cifs$fcntl depends on whether a conflicting lock<br />

exists, as follows:<br />

• A conflicting lock exists; cifs$fcntl does the following:<br />

− Overwrites the flock data item with the in<strong>for</strong>mation retrieved about the<br />

conflicting lock<br />

− Sets l-start to the first byte of the conflicting lock, relative to the beginning of the<br />

file<br />

− Sets l-whence to <strong>CIFS</strong>-SEEK-SET-WHENCE<br />

• No conflicting lock exists; cifs$fcntl does the following:<br />

− Sets l-type to <strong>CIFS</strong>-F-UNLCK<br />

− Leaves the rest of the flock data item unchanged<br />

If parm points to a data item whose l-type field is <strong>CIFS</strong>-F-UNLCK, it is not possible <strong>for</strong> a<br />

lock conflict to arise. There<strong>for</strong>e, cifs$fcntl behaves the same as the second case.<br />

Conclusions About Using <strong>CIFS</strong>-F-GETLK<br />

You can draw the following conclusions about using <strong>CIFS</strong>-F-GETLK:<br />

• If you request an exclusive or shared lock <strong>and</strong> cifs$fcntl returns a data item whose<br />

l-type field is <strong>CIFS</strong>-F-UNLCK, then no conflicting lock existed at the time of the call.<br />

However, this does not guarantee that no conflicting lock exists if you try to set the<br />

same lock using <strong>CIFS</strong>-F-SETLK, because another process can establish a conflicting<br />

lock in the interim.<br />

• An appropriate use <strong>for</strong> <strong>CIFS</strong>-F-GETLK is to determine more in<strong>for</strong>mation about a lock<br />

that conflicts with your request to set a lock with <strong>CIFS</strong>-F-SETLK. In particular, the<br />

process ID of the owner of the conflicting lock might be useful, depending on the<br />

application.<br />

• If your request has lock type <strong>CIFS</strong>-F-UNLCK, using <strong>CIFS</strong>-F-GETLK is meaningless.<br />

7859 6137–009 6–35


<strong>CIFS</strong>$FCNTL<br />

<strong>CIFS</strong>-F-SETLK—Set Record-Locking In<strong>for</strong>mation<br />

The cifs$fcntl service subprogram sets or clears a lock on a file segment according to the<br />

description in the flock data item indicated by parm, as shown in the following table (the<br />

symbolic names are defined in <strong>CIFS</strong>-FCNTL COPY PROC):<br />

If l-type is ... Then cifs$fcntl uses l-whence, l-start, <strong>and</strong> l-len to ...<br />

<strong>CIFS</strong>-F-RDLCK Establish a shared lock.<br />

<strong>CIFS</strong>-F-WRLCK Establish an exclusive lock.<br />

<strong>CIFS</strong>-F-UNLCK Remove any locks in the indicated range.<br />

If cifs$fcntl cannot set the requested lock because of conflicts with existing locks, it fails.<br />

<strong>CIFS</strong>-F-SETLKW—Set Record-Locking In<strong>for</strong>mation; Wait If Blocked<br />

This service is the same as <strong>CIFS</strong>-F-SETLK, except that the process waits until the<br />

request can be satisfied or is interrupted. If the process is interrupted while waiting <strong>for</strong> a<br />

region to be unlocked, cifs$fcntl fails <strong>and</strong> the lock is not created.<br />

6–36 7859 6137–009


Calling cifs$fcntl with <strong>CIFS</strong>-F-SETLK<br />

<strong>CIFS</strong>$FCNTL<br />

The following code shows how to call cifs$fcntl to set an exclusive lock at the current<br />

read/write position in the file, where fd-a is an existing file descriptor:<br />

01 <strong>CIFS</strong>-FLOCK-STRUCT.<br />

03 L-TYPE PIC S1(18) BINARY-1.<br />

88 <strong>CIFS</strong>-F-RDLCK VALUE 1.<br />

88 <strong>CIFS</strong>-F-UNLCK VALUE 2.<br />

88 <strong>CIFS</strong>-F-WRLCK VALUE 3.<br />

03 L-WHENCE PIC S1(18) BINARY-1.<br />

88 <strong>CIFS</strong>-SEEK-SET-WHENCE VALUE 0.<br />

88 <strong>CIFS</strong>-SEEK-CUR-WHENCE VALUE 1.<br />

88 <strong>CIFS</strong>-SEEK-END-WHENCE VALUE 2.<br />

03 L-START PIC S1(36) BINARY-1.<br />

03 L-LEN PIC S1(36) BINARY-1.<br />

03 L-PID PIC S1(36) BINARY-1.<br />

*<br />

01 <strong>CIFS</strong>-FCNTL-CMD PIC 1(36) BINARY-1.<br />

88 <strong>CIFS</strong>-F-DUPFD VALUE 0.<br />

88 <strong>CIFS</strong>-F-GETFD VALUE 1.<br />

88 <strong>CIFS</strong>-F-GETFL VALUE 2.<br />

88 <strong>CIFS</strong>-F-GETLK VALUE 3.<br />

88 <strong>CIFS</strong>-F-SETFD VALUE 4.<br />

88 <strong>CIFS</strong>-F-SETFL VALUE 5.<br />

88 <strong>CIFS</strong>-F-SETLK VALUE 6.<br />

88 <strong>CIFS</strong>-F-SETLKW VALUE 7.<br />

...<br />

move 12 to 1-len.<br />

move 0 to 1-start.<br />

set cifs-f-wrlck to true.<br />

set cifs-seek-cur-whence to true.<br />

set cifs-f-setlk to true.<br />

call "cifs$fcntl" using fd-a, cifs-fcntl-cmd, cifs-flock-struct,<br />

return-value, cifs-status.<br />

Modifying Existing Locks<br />

If the calling process already has locks covering part of the segment indicated by the lock<br />

description, cifs$fcntl modifies these locks as necessary. For example, if the process<br />

owns an exclusive lock on the first 10 bytes of the file <strong>and</strong> requests a shared lock on<br />

byte 5 (l-start = 5), it then owns 3 distinct locks, as follows:<br />

• An exclusive lock on bytes 0 through 4<br />

• A shared lock on byte 5<br />

• An exclusive lock on bytes 6 through 9<br />

7859 6137–009 6–37


<strong>CIFS</strong>$FCNTL<br />

Clearing Existing Locks<br />

You can clear all 3 locks in the previous example by unlocking the first 10 bytes of the<br />

file, as follows:<br />

COPY <strong>CIFS</strong>-API.<br />

COPY <strong>CIFS</strong>-OFLAG.<br />

01 return-value PIC S1(36) BINARY-1.<br />

01 <strong>CIFS</strong>-FLOCK-STRUCT.<br />

03 L-TYPE PIC S1(18) BINARY-1.<br />

88 <strong>CIFS</strong>-F-RDLCK VALUE 1.<br />

88 <strong>CIFS</strong>-F-UNLCK VALUE 2.<br />

88 <strong>CIFS</strong>-F-WRLCK VALUE 3.<br />

03 L-WHENCE PIC S1(18) BINARY-1.<br />

88 <strong>CIFS</strong>-SEEK-SET-WHENCE VALUE 0.<br />

88 <strong>CIFS</strong>-SEEK-CUR-WHENCE VALUE 1.<br />

88 <strong>CIFS</strong>-SEEK-END-WHENCE VALUE 2.<br />

03 L-START PIC S1(36) BINARY-1.<br />

03 L-LEN PIC S1(36) BINARY-1.<br />

03 L-PID PIC S1(36) BINARY-1.<br />

*<br />

01 <strong>CIFS</strong>-FCNTL-CMD PIC 1(36) BINARY-1.<br />

88 <strong>CIFS</strong>-F-DUPFD VALUE 0.<br />

88 <strong>CIFS</strong>-F-GETFD VALUE 1.<br />

88 <strong>CIFS</strong>-F-GETFL VALUE 2.<br />

88 <strong>CIFS</strong>-F-GETLK VALUE 3.<br />

88 <strong>CIFS</strong>-F-SETFD VALUE 4.<br />

88 <strong>CIFS</strong>-F-SETFL VALUE 5.<br />

88 <strong>CIFS</strong>-F-SETLK VALUE 6.<br />

88 <strong>CIFS</strong>-F-SETLKW VALUE 7.<br />

...<br />

move 10 to 1-len.<br />

move 0 to 1-start.<br />

set cifs-f-unlck to true.<br />

set cifs-seek-set-whence to true.<br />

set cifs-f-setlk to true.<br />

call "cifs$fcntl" using fd-a, cifs-fcntl-cmd, cifs-flock-struct,<br />

return-value, cifs-status.<br />

6–38 7859 6137–009


<strong>CIFS</strong>$FDATASYNC<br />

Application<br />

<strong>CIFS</strong>$FDATASYNC<br />

Use the cifs$fdatasync service subprogram to write to the device all data currently in a<br />

portion of the buffer cache <strong>for</strong> a file, thus protecting the data against loss due to a<br />

system outage. With cifs$fdatasync, an application can synchronize all file updates at<br />

one time, instead of on every read or write operation. However, cifs$fdatasync does not<br />

synchronize file access times.<br />

For a similar service subprogram that does synchronize file access times, see the<br />

cifs$fsync service subprogram. For alternate methods of synchronizing disk data, see the<br />

discussions of the <strong>CIFS</strong>-OFLAG-SYNC <strong>and</strong> <strong>CIFS</strong>-OFLAG-DSYNC flags under the<br />

cifs$open <strong>and</strong> cifs$fcntl service subprograms.<br />

Synopsis<br />

CALL "cifs$fdatasync" USING fildes, cifs-status<br />

Description<br />

The cifs$fdatasync service subprogram writes from the buffer cache to the device all<br />

data belonging to the specified file, where fildes specifies a regular file open <strong>for</strong> writing.<br />

The data written is that portion of the buffer cache associated with the file referenced by<br />

fildes.<br />

fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains a file descriptor.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fdatasync service subprogram completes successfully, it returns 0 in the<br />

cifs-status parameter. Otherwise, cifs$fdatasync sets cifs-status to identify the specific<br />

error that was encountered.<br />

7859 6137–009 6–39


<strong>CIFS</strong>$FDATASYNC<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fdatasync service subprogram returns<br />

a nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

<strong>CIFS</strong>-EINVAL Data synchronization is not supported <strong>for</strong> the type of<br />

file described by fildes.<br />

<strong>CIFS</strong>-EIO The file could not be fully synchronized because of an<br />

I/O error.<br />

6–40 7859 6137–009


<strong>CIFS</strong>$FDOPEN<br />

Application<br />

Use the cifs$fdopen service subprogram to create a stream <strong>and</strong> associate a file<br />

descriptor with it.<br />

Synopsis<br />

CALL "cifs$fdopen" USING fildes, type, cifs-file, cifs-status.<br />

Description<br />

<strong>CIFS</strong>$FDOPEN<br />

The cifs$fdopen service subprogram creates a stream <strong>and</strong> associates a file descriptor<br />

with the stream, where:<br />

fildes<br />

type<br />

cifs-file<br />

is the file descriptor to associate with the stream.<br />

is a character string specifying the access mode <strong>for</strong> the file. It is the same as the<br />

type-string argument <strong>for</strong> the cifs$fopen service subprogram. It must be a subset of<br />

the access mode of the initial cifs$open service subprogram.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The access mode prefixes “w” <strong>and</strong> “w+” do not cause truncation of the file. The file<br />

position indicator is set to the position indicated by the file offset associated with the file<br />

descriptor. Error <strong>and</strong> end-of-file indicators are cleared.<br />

Return Values<br />

If the cifs$fdopen service subprogram completes successfully, it does the following:<br />

• Does not change the last access time field<br />

• Returns a value to a stream in cifs-file<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$fdopen sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–41


<strong>CIFS</strong>$FDOPEN<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fdopen service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EINVAL type is not a subset of the access mode of the initial<br />

cifs$open service subprogram.<br />

6–42 7859 6137–009


<strong>CIFS</strong>$FEOF<br />

Application<br />

Use the cifs$feof service subprogram to test whether a stream is at end of file.<br />

Synopsis<br />

CALL "cifs$feof" USING cifs-file, eof-flag.<br />

Description<br />

<strong>CIFS</strong>$FEOF<br />

The cifs$feof service subprogram tests the end-of-file indicator <strong>for</strong> a stream, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

eof-flag<br />

is a 1-word (S1(36) BINARY-1) data item which is used as the end-of-file indicator.<br />

Return Values<br />

The cifs$feof service subprogram returns a nonzero value into eof-flag if the end-of-file<br />

indicator is set.<br />

7859 6137–009 6–43


<strong>CIFS</strong>$FERROR<br />

<strong>CIFS</strong>$FERROR<br />

Application<br />

Use the cifs$ferror service subprogram to test whether a read/write error occurred.<br />

Synopsis<br />

CALL "cifs$ferror" USING cifs-file, error-flag.<br />

Description<br />

The cifs$ferror service subprogram tests the read/write error indicator <strong>for</strong> a stream,<br />

where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

error-flag<br />

is a 1-word (S1(36) BINARY-1) data item which is used as the read/write error<br />

indicator.<br />

Return Values<br />

The cifs$ferror service subprogram returns a nonzero value into error-flag if the<br />

read/write error indicator is set.<br />

6–44 7859 6137–009


<strong>CIFS</strong>$FFLUSH<br />

Application<br />

<strong>CIFS</strong>$FFLUSH<br />

Use the cifs$fflush service subprogram to write all remaining data in the buffer to a file<br />

without closing the file.<br />

Synopsis<br />

CALL "cifs$fflush" USING cifs-file, cifs-status.<br />

Description<br />

The cifs$fflush service subprogram causes any unwritten data <strong>for</strong> an output stream to be<br />

written to the file, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

The cifs$fflush service subprogram returns a nonzero value in cifs-status if a write error<br />

occurs.<br />

7859 6137–009 6–45


<strong>CIFS</strong>$FGETC<br />

<strong>CIFS</strong>$FGETC<br />

Application<br />

Use the cifs$fgetc service subprogram to obtain the next character from an input<br />

stream.<br />

Synopsis<br />

CALL "cifs$fgetc" USING cifs-file, next-char, cifs-status.<br />

Description<br />

The cifs$fgetc service subprogram obtains the next character (if present) from an input<br />

stream, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

next-char<br />

is a 1-byte field that is used to hold the next character that is retrieved.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$fgetc service subprogram retrieves the next character <strong>and</strong> advances the<br />

associated file position indicator, if defined.<br />

Return Values<br />

If the cifs$fgetc service subprogram completes successfully, it returns the next<br />

character from the specified input stream into the next-char parameter <strong>and</strong> returns 0 in<br />

cifs-status. Otherwise, cifs$fgetc sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–46 7859 6137–009


<strong>CIFS</strong>$FGETP<strong>OS</strong><br />

Application<br />

<strong>CIFS</strong>$FGETP<strong>OS</strong><br />

Use the cifs$fgetpos service subprogram to obtain the current value of the file position<br />

indicator.<br />

Synopsis<br />

CALL "call$fgetpos" USING cifs-file, cifs-fpos, cifs-status.<br />

Description<br />

The cifs$fgetpos service subprogram obtains the current value of the file position<br />

indicator, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-fpos<br />

is a 2-word group item in which the value is returned. Use the COBOL COPY PROC<br />

<strong>CIFS</strong>-FP<strong>OS</strong> <strong>for</strong> the declaration of this variable. The cifs$fsetpos service subprogram<br />

can use this data item.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If it completes successfully, the cifs$fgetpos service subprogram returns 0 in cifs-status.<br />

Otherwise, cifs$fgetpos sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–47


<strong>CIFS</strong>$FGETS<br />

<strong>CIFS</strong>$FGETS<br />

Application<br />

Use the cifs$fgets service subprogram to read the next characters from an input stream<br />

into a string.<br />

Synopsis<br />

CALL "cifs$fgets" USING string, max-chars, cifs-file, cifs-status.<br />

Description<br />

The cifs$fgets service subprogram reads the next max-chars - 1 characters from an input<br />

stream into a character string, where:<br />

string<br />

is an alphanumeric data item that contains the characters read. A nul character is<br />

written immediately after the last character read into the data item.<br />

max-chars<br />

cifs-file<br />

specifies one more than the number of characters to read. That is, cifs$fgets reads<br />

at most max-chars - 1 characters.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fgets service subprogram returns successfully, the string parameter contains<br />

the characters that were read <strong>and</strong> the cifs-status parameter is set to 0. Otherwise,<br />

cifs$fgets sets cifs-status to identify the specific error that was encountered.<br />

6–48 7859 6137–009


<strong>CIFS</strong>$FILENO<br />

Application<br />

<strong>CIFS</strong>$FILENO<br />

Use the cifs$fileno service subprogram to retrieve a file descriptor <strong>for</strong> a specific data<br />

stream.<br />

Synopsis<br />

CALL "cifs$fileno" USING cifs-file, fildes, cifs-status.<br />

Description<br />

The cifs$fileno service subprogram retrieves a file descriptor, where:<br />

cifs-file<br />

fildes<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the<br />

specified file.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fileno service subprogram completes successfully, it returns a file descriptor<br />

into the fildes parameter <strong>and</strong> sets cifs-status to 0. Otherwise, cifs$fileno sets cifs-status<br />

to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fileno service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EFAULT The value specified by stream is invalid.<br />

<strong>CIFS</strong>-EINVAL The stream to which stream points is invalid.<br />

7859 6137–009 6–49


<strong>CIFS</strong>$FOPEN<br />

<strong>CIFS</strong>$FOPEN<br />

Application<br />

Use the cifs$fopen service subprogram to open a path name <strong>and</strong> associate a stream<br />

with it.<br />

Synopsis<br />

CALL "cifs$fopen" USING pathname, type-string, cifs-file, cifs-status.<br />

Description<br />

The cifs$fopen service subprogram opens a path name <strong>and</strong> associates a stream with it,<br />

where:<br />

pathname<br />

is an alphanumeric variable that contains the name of the file to be opened.<br />

type-string<br />

is an alphanumeric data item that contains any of the sequences in the following<br />

table. Additional characters, separated from the given sequences by a comma, may<br />

follow these, but cifs$fopen ignores them. The sequences may be in upper or lower<br />

case, although upper case might not be portable to other plat<strong>for</strong>ms.<br />

Sequence Description<br />

r Open existing text file <strong>for</strong> reading.<br />

w Create file <strong>for</strong> writing or truncate to 0 length.<br />

a Append; open file or create <strong>for</strong> writing at end of file.<br />

rb Open existing binary file <strong>for</strong> reading.<br />

wb Create binary file <strong>for</strong> writing or truncate to 0 length.<br />

ab Append; open binary file or create <strong>for</strong> writing at end of file.<br />

r+ Open existing file <strong>for</strong> update (reading <strong>and</strong> writing).<br />

w+ Create file <strong>for</strong> update or truncate to 0 length.<br />

a+ Append; open file or create <strong>for</strong> update, writing at end of file.<br />

r+b or rb+ Open existing binary file <strong>for</strong> update (reading <strong>and</strong> writing).<br />

w+b or wb+ Create binary file <strong>for</strong> update or truncate to 0 length.<br />

a+b or ab+ Append; open binary file or create <strong>for</strong> update, writing at end of<br />

file.<br />

Note: The letter b in the type sequence is effective only when a file is created. In all<br />

other cases, the file retains its existing type (SDF or binary), <strong>and</strong> b, if present, is ignored.<br />

6–50 7859 6137–009


cifs-file<br />

<strong>CIFS</strong>$FOPEN<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Appending Data to a File<br />

Opening a file with append mode (a, ab, a+, or a+b) <strong>for</strong>ces all subsequent writes to the<br />

file to the current end of file, regardless of previous calls to the cifs$fseek service<br />

subprogram.<br />

Updating a File<br />

When you open a file <strong>for</strong> update, you can per<strong>for</strong>m both input <strong>and</strong> output operations on<br />

the associated stream. However, an output operation cannot be directly followed by an<br />

input operation without an intervening call to cifs$fseek, cifs$rewind, or cifs$fflush.<br />

Similarly, an input operation cannot be directly followed by an output operation without<br />

an intervening call to cifs$fseek or cifs$rewind, unless the input operation encounters<br />

the end of the file.<br />

Default Permissions When Creating a File<br />

If the cifs$fopen service subprogram creates a file, it assigns read <strong>and</strong> write permissions<br />

to the owner, group, <strong>and</strong> other permission classes by default. The following file mode<br />

specification <strong>for</strong> the cifs$open service subprogram is equivalent:<br />

compute cifs-mode-irwxu = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxg = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxo = cifs-mode-iread + cifs-mode-iwrite.<br />

Return Values<br />

If it completes successfully, the cifs$fopen service subprogram returns an opaque data<br />

item that describes an open instance of the file into cifs-file <strong>and</strong> it also returns 0 in<br />

cifs-status. Otherwise, cifs$fopen sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–51


<strong>CIFS</strong>$FPRINTF<br />

<strong>CIFS</strong>$FPRINTF<br />

Application<br />

Use the cifs$fprintf service subprogram to write <strong>for</strong>matted output.<br />

Synopsis<br />

CALL "cifs$fprintf" USING chars-out, cifs-file, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$fprintf service subprogram writes <strong>for</strong>matted output, where:<br />

chars-out<br />

cifs-file<br />

<strong>for</strong>mat<br />

item<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of bytes written<br />

out.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item into which the value of the open instance of the file is stored.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of this variable. A<br />

<strong>for</strong>matted output string can have a maximum of 32,767 characters.<br />

is an alphanumeric data item that controls the output by specifying how subsequent<br />

arguments are converted be<strong>for</strong>e being output. See the subsection “Format Strings”<br />

<strong>for</strong> additional in<strong>for</strong>mation.<br />

is an alphanumeric data item that contains the data to be printed.<br />

Format Strings<br />

A <strong>for</strong>mat string contains two types of objects:<br />

• Plain characters<br />

Plain characters are copied unchanged to the output stream.<br />

• Conversion specifications<br />

Each conversion specification results in fetching 0 or more subsequent arguments.<br />

If the <strong>for</strong>mat is exhausted while arguments remain, the excess arguments are evaluated<br />

but otherwise ignored. The cifs$fprintf service subprogram returns when it encounters<br />

the end of the <strong>for</strong>mat string.<br />

6–52 7859 6137–009


Conversion Specifications<br />

<strong>CIFS</strong>$FPRINTF<br />

Each conversion specification is introduced by the percent (%) character. After the %<br />

character, the following characters appear in sequence:<br />

1. An optional field, integer$, where integer is a decimal integer value specifying the<br />

next argument to be converted <strong>for</strong> output.<br />

2. Zero or more flags that modify the meaning of the conversion specification.<br />

3. An optional decimal integer, other than 0, specifying a minimum field width. If the<br />

converted value has fewer characters than the field width, it is padded with spaces<br />

on the left of the field width (or on the right if the left adjustment flag is specified).<br />

Note: If the first character after the percent (%) sign is 0, then it is a flag character,<br />

not a field width.<br />

4. An optional precision, in the <strong>for</strong>m of a period (.) followed by an optional decimal<br />

integer. If the integer is omitted, it is treated as 0. The padding specified by the<br />

precision overrides the padding specified by the field width. The precision specifies<br />

the following number:<br />

a. For d, i, o, u, x, <strong>and</strong> X conversions, the minimum number of digits to appear<br />

b. For e, E, <strong>and</strong> f conversions, the number of digits to appear after the decimal<br />

point<br />

c. For g <strong>and</strong> G conversions, the maximum number of significant digits<br />

d. For s conversions, the maximum number of characters to be printed from a<br />

string<br />

5. An optional h, l, L, or ll (lowercase double L) <strong>for</strong>mat character, which must appear as<br />

follows:<br />

a. h<br />

b. l<br />

c. L<br />

This letter specifies that a following d, i, o, u, x, or X conversion specifier applies<br />

to a half-word BINARY argument (PIC 9(5) BINARY). It means the argument has<br />

been promoted according to the integral promotions <strong>and</strong> its value moves to a<br />

half-word BINARY field be<strong>for</strong>e printing.<br />

This letter specifies that a following d, i, o, u, x, or X conversion specifier applies<br />

to a full-word BINARY argument (PIC 9(10) BINARY). This letter specifies that a<br />

following n conversion specifier applies to a full-word BINARY argument (PIC<br />

9(10) BINARY.<br />

This letter specifies that a following e, E, f, g, or G conversion specifier applies to<br />

a COMP-2 argument.<br />

If h, l, or L appears with any other conversion specifier, it is ignored.<br />

7859 6137–009 6–53


<strong>CIFS</strong>$FPRINTF<br />

d. ll<br />

These letters (lowercase double L) specify that a following d, I, o, x, or X<br />

conversion specifier applies to a 2-word PIC S1(72) BINARY-1 argument.<br />

6. A character that specifies the type of conversion to be applied.<br />

A field width or precision, or both, can be indicated by an asterisk (*) instead of a digit<br />

string. In this case, a PIC 9(10) BINARY argument supplies the field width or precision.<br />

The arguments specifying field width or precision must appear be<strong>for</strong>e the argument (if<br />

any) to be converted. A negative field width argument is read as a - flag followed by a<br />

positive field width. A negative precision argument is the same as if it were omitted.<br />

Precision <strong>and</strong> width can also be indicated by an asterisk ( * ) followed by a decimal<br />

integer <strong>and</strong> the $ character, where the decimal integer specifies the position in the<br />

argument list of the integer argument containing the field width or precision.<br />

The following table lists the flag characters <strong>and</strong> their meanings.<br />

Flag<br />

Character Description<br />

- The result of the conversion is left justified within the field.<br />

+ The result of a signed conversion always begins with a plus or minus sign.<br />

Space If the first character of a signed conversion is not a sign, a space is placed<br />

be<strong>for</strong>e the result. If the space <strong>and</strong> + flags both appear, the space flag is<br />

ignored.<br />

# The result is converted to an alternate <strong>for</strong>m. For c, d, i, s, <strong>and</strong> u<br />

conversions, the flag has no effect.<br />

For o conversion, it increases the precision to <strong>for</strong>ce the first digit of the<br />

result to be 0.<br />

For x <strong>and</strong> X conversions, a nonzero result has 0x or 0X placed be<strong>for</strong>e it. For<br />

e, E, f, g, <strong>and</strong> G conversions, the result always contains a decimal point,<br />

even if no digits follow the decimal point (normally, a decimal point appears<br />

in the result of these conversions only if a digit follows it). For g <strong>and</strong> G<br />

conversions, trailing 0s are not removed from the result, as they normally<br />

are.<br />

0 For numeric conversions (d, i, o, u, x, X, e, E, f, g, G), the field width is<br />

padded with leading zeros following any indication of sign or base; the field<br />

is not padded with spaces.<br />

If the 0 <strong>and</strong> - flags both appear, the 0 flag is ignored. For d, i, o, u, x, <strong>and</strong> X<br />

conversions, the 0 flag is ignored if a precision is specified. For other<br />

conversions, the behavior is undefined if a precision is specified.<br />

Note: If the first character after the percent (%) sign is 0, then this<br />

character is a zero flag, not a field width.<br />

6–54 7859 6137–009


The following table lists the conversion specifiers <strong>and</strong> their meanings.<br />

Specifier Description<br />

<strong>CIFS</strong>$FPRINTF<br />

c The least significant byte of the 9(10) BINARY argument is converted to a<br />

character <strong>and</strong> printed.<br />

d, i, o, u, x,<br />

X<br />

The 9(10) BINARY argument is converted to signed decimal (d or i),<br />

unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal notation<br />

(x or X). The letters abcdef are used <strong>for</strong> x conversion <strong>and</strong> the letters<br />

ABCDEF <strong>for</strong> X conversion. The precision specifies the minimum number<br />

of digits to appear. If the value being converted can be represented in<br />

fewer digits, it is exp<strong>and</strong>ed with leading 0s. The default precision is 1. The<br />

result of converting a 0 value with a precision of 0 is no characters.<br />

e, E The COMP-2 argument is converted in the style [-]d.ddde+dd, where one<br />

digit occurs be<strong>for</strong>e the decimal point <strong>and</strong> the number of digits after the<br />

decimal point is equal to the precision.<br />

When the precision is missing, 6 digits are produced. If the precision is 0,<br />

no decimal point appears. The value is rounded to the appropriate number<br />

of digits.<br />

The E <strong>for</strong>mat code produces a number with E instead of e introducing the<br />

exponent. The exponent always contains at least 2 digits. However, if the<br />

magnitude to print is greater than or equal to 1E+100, additional exponent<br />

digits are printed as necessary.<br />

f The COMP-2 argument is converted to decimal notation in the style<br />

[-]ddd.ddd, where the number of digits after the decimal point is equal to<br />

the precision specification.<br />

If the precision is missing, it is taken as 6; if the precision is explicitly 0, no<br />

decimal point appears. If a decimal point appears, at least one digit<br />

appears be<strong>for</strong>e it. The value is rounded to the appropriate number of<br />

digits.<br />

g, G For the g <strong>for</strong>mat code, the COMP-2 argument is printed in style f or e. For<br />

a G <strong>for</strong>mat code, it is printed in style E. In each style, the precision<br />

specifies the number of significant digits.<br />

The style used depends on the value converted. Style e is used only if the<br />

exponent resulting from the conversion is less than -4 or greater than the<br />

precision. Trailing zeros are removed from the result. A decimal point<br />

appears only if it is followed by a digit.<br />

n The argument is taken to be a 9(10) BINARY integer into which is written<br />

the number of characters written to the output stream so far by this call to<br />

cifs$fprintf. No argument is converted.<br />

p The argument is taken to be a PIC S1(72) BINARY-1 data item. The value<br />

is printed as 24 octal digits.<br />

7859 6137–009 6–55


<strong>CIFS</strong>$FPRINTF<br />

Specifier Description<br />

s The argument is taken to be an alphanumeric character string. Characters<br />

from the string are written up to but not including the terminating NUL, or<br />

until the number of characters indicated by the precision is written. If the<br />

precision is missing, it is taken to be arbitrarily large so that all characters<br />

be<strong>for</strong>e the first NUL are printed.<br />

The maximum number of characters that can be printed <strong>for</strong> one %s<br />

conversion is 6999.<br />

% The character % is printed. No argument is converted.<br />

Considerations <strong>for</strong> Conversion Specifications<br />

If the conversion specifier is not one of the characters in the above table, the character is<br />

printed <strong>and</strong> no argument is converted.<br />

If any argument is or points to an aggregate (except <strong>for</strong> an array of characters using %s<br />

conversion or any %p conversion), the behavior is undefined.<br />

A nonexistent or small field width does not cause truncation of a field. If the conversion<br />

result is wider than the field width, the field is exp<strong>and</strong>ed to contain the conversion result.<br />

Return Values<br />

If it completes successfully, the cifs$fprintf service subprogram returns the number of<br />

characters transmitted into the chars-out argument. Otherwise, cifs$fprintf returns a<br />

negative value in the argument.<br />

Examples<br />

Print a date <strong>and</strong> time in the <strong>for</strong>m “Tuesday, July 3, 10:02,” where weekday <strong>and</strong> month<br />

are strings:<br />

CALL "cifs$frpintf" USING bytes-written, cifs-stdout-file,<br />

"%s, %s %d, %.2d:%.2d/n",<br />

weekday, month, day, hour, min.<br />

Print pi to five decimal places:<br />

01 r1 comp-2.<br />

...<br />

COMPUTE r1 = 4 * function atan(1.0).<br />

CALL "cifs$fprintf" USING bytes-written, cifs-stdout-file,<br />

"pi = %.5f/n", r1.<br />

6–56 7859 6137–009


<strong>CIFS</strong>$FPUTC<br />

Application<br />

Use the cifs$fputc service subprogram to write a character to an output stream.<br />

Synopsis<br />

CALL "cifs$fputc" USING char, cifs-file, cifs-status.<br />

Description<br />

<strong>CIFS</strong>$FPUTC<br />

The cifs$fputc service subprogram writes a character to an output stream, where:<br />

char<br />

cifs-file<br />

is an alphanumeric data item that specifies the character to write.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$fputc service subprogram writes the character at the position indicated by the<br />

associated file position indicator (if defined), advancing the indicator appropriately. If the<br />

file position indicator is not defined, the character is appended to the output stream.<br />

Return Values<br />

If the cifs$fputc service subprogram returns successfully, the character specified in char<br />

is written to the output stream <strong>and</strong> the cifs-status parameter is set to 0. Otherwise,<br />

cifs$fputc sets cifs-status to identify the specific error that was encountered.<br />

7859 6137–009 6–57


<strong>CIFS</strong>$FPUTS<br />

<strong>CIFS</strong>$FPUTS<br />

Application<br />

Use the cifs$fputs service subprogram to write a string to an output stream.<br />

Synopsis<br />

CALL "cifs$fputs" USING string, cifs-file, chars-out, cifs-status.<br />

Description<br />

The cifs$fputs service subprogram writes a string to an output stream, where:<br />

string<br />

cifs-file<br />

is an alphanumeric data item that contains the characters to be written to the output<br />

stream.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

chars-out<br />

is a 1-word (S1(36) BINARY-1) data item that contains the number of characters<br />

written to the output stream<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fputs service subprogram returns successfully, the number of bytes written is<br />

returned in chars-out <strong>and</strong> the cifs-status parameter is set to 0. Otherwise, cifs$fputs sets<br />

cifs-status to identify the specific error that was encountered.<br />

6–58 7859 6137–009


<strong>CIFS</strong>$FREAD<br />

Application<br />

<strong>CIFS</strong>$FREAD<br />

Use the cifs$fread service subprogram to read elements from an input stream into an<br />

array.<br />

Synopsis<br />

CALL "cifs$fread" USING buffer, elt-size, elt-count, cifs-file,<br />

elts-read, cifs-status.<br />

Description<br />

The cifs$fread service subprogram reads elements from an input stream into an array,<br />

where:<br />

buffer<br />

elt-size<br />

is an alphanumeric character string.<br />

specifies the size of an element in the array.<br />

elt-count<br />

cifs-file<br />

specifies the number of elements to attempt to read.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

elts-read<br />

specifies the number of elements read.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$fread service subprogram advances the file position indicator (if defined) by the<br />

number of bytes successfully read. If an error occurs, the resulting value of the file<br />

position indicator is indeterminate. If a partial element is read, its value is indeterminate.<br />

Use either the cifs$ferror or cifs$feof service subprogram to distinguish between a read<br />

error <strong>and</strong> end of file.<br />

7859 6137–009 6–59


<strong>CIFS</strong>$FREAD<br />

Return Values<br />

If it completes successfully, the cifs$fread service subprogram returns the number of<br />

elements read into elts-read; this number can be less than elt-count if a read error or end<br />

of file occurs. If either elt-size or elt-count is 0, cifs$fread returns 0 <strong>and</strong> both the contents<br />

of the array <strong>and</strong> the state of the input stream remain unchanged. If an error occurs,<br />

cifs-status is set to identify the specific error that was encountered.<br />

6–60 7859 6137–009


<strong>CIFS</strong>$FREOPEN<br />

Application<br />

<strong>CIFS</strong>$FREOPEN<br />

Use the cifs$freopen service subprogram to open a path name <strong>and</strong> associate a stream<br />

with it. This service subprogram first attempts to close a file associated with the stream.<br />

The primary use of cifs$freopen is to change the file associated with a st<strong>and</strong>ard text<br />

stream (st<strong>and</strong>ard error, st<strong>and</strong>ard input, or st<strong>and</strong>ard output) since those identifiers are not<br />

values that can be updated by the cifs$fopen service subprogram.<br />

Synopsis<br />

CALL "cifs$freopen" USING path, type-string, cifs-file, cifs-status.<br />

Description<br />

The cifs$freopen service subprogram opens a path <strong>and</strong> associates a stream with it,<br />

where:<br />

path<br />

is an alphanumeric variable that contains the name of the file to be opened.<br />

type-string<br />

cifs-file<br />

is an alphanumeric data item that contains one of the sequences in the table in<br />

cifs$fopen. Additional characters can follow these sequences, but cifs$freopen<br />

ignores them.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$freopen service subprogram first attempts to close any file associated with the<br />

specified stream, ignoring any failure to close the file successfully.<br />

Default Permissions When Creating a File<br />

If the cifs$freopen service subprogram creates a file, it assigns read <strong>and</strong> write<br />

permissions to the owner, group, <strong>and</strong> other permission classes by default.<br />

7859 6137–009 6–61


<strong>CIFS</strong>$FREOPEN<br />

The following file mode specification <strong>for</strong> the cifs$open service subprogram is equivalent:<br />

compute cifs-mode-irwxu = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxg = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxo = cifs-mode-iread + cifs-mode-iwrite.<br />

Return Values<br />

If it completes successfully, the cifs$freopen service subprogram returns the value of<br />

stream in the cifs-file parameter <strong>and</strong> place a 0 in cifs-status. Otherwise, cifs$freopen<br />

sets cifs-status to identify the specific error that was encountered.<br />

6–62 7859 6137–009


<strong>CIFS</strong>$FSCANF<br />

Application<br />

Use the cifs$fscanf service subprogram to read <strong>for</strong>matted input.<br />

Synopsis<br />

CALL "cifs$fscanf" USING items-scanned, cifs-file, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$fscanf service subprogram reads <strong>for</strong>matted input, where:<br />

items-scanned<br />

cifs-file<br />

<strong>for</strong>mat<br />

item<br />

<strong>CIFS</strong>$FSCANF<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of assigned input<br />

items.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item into which the value of the open instance of the file is<br />

stored. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of this variable.<br />

A <strong>for</strong>matted output string can have a maximum of 32,767 characters.<br />

controls the input by specifying how input text is converted <strong>for</strong> assignment.<br />

Subsequent arguments are objects that receive the converted input. If there are<br />

insufficient arguments <strong>for</strong> the <strong>for</strong>mat, a signal is generated. If the program recovers<br />

from the signal, it treats it as if an asterisk flag were specified. If the <strong>for</strong>mat is<br />

exhausted while arguments remain, cifs$fscanf evaluates the excess arguments but<br />

otherwise ignores them.<br />

is an alphanumeric data item that contains the data to be scanned.<br />

Format Strings<br />

The <strong>for</strong>mat argument can contain the following code:<br />

• Any number of spaces, horizontal tabs, or newline (line feed) characters that cause<br />

input to be read up to the next nonwhite-space character<br />

• An ordinary character (not %) that must match the next character of the input stream<br />

• Conversion specifications, consisting of the following sequence:<br />

− The character % or the character sequence % digit $ decimal-integer<br />

− An optional assignment-suppressing character *<br />

− An optional decimal integer that specifies the maximum field width<br />

7859 6137–009 6–63


<strong>CIFS</strong>$FSCANF<br />

− An optional h, l, L, or ll (lowercase double L) indicating the size of the receiving<br />

object<br />

See “Conversion Specifications” below.<br />

Conversion Specifications<br />

A conversion specification directs the conversion of the next input field. Except <strong>for</strong> the<br />

conversion specifiers c <strong>and</strong> [, an input field is defined as a sequence of nonspace<br />

characters. It starts at the first character in the input that is not a white-space character<br />

(ASCII characters 9 – 13 <strong>and</strong> a space) <strong>and</strong> extends to the first conflicting character or<br />

until the field width, if specified, is exhausted.<br />

When the <strong>for</strong>m % decimal-integer $ is used, the decimal integer indicates to which<br />

argument in the argument list to assign the results of the conversion. If decimal-integer<br />

is n, the conversion results are assigned to the nth argument.<br />

The service subprogram places the result in the object pointed to by the subsequent<br />

argument, unless assignment suppression was indicated by an asterisk ( * ). The<br />

conversion specifier indicates the interpretation of the input field. The corresponding<br />

argument must be an appropriate type.<br />

The following table lists the valid cifs$fscanf conversion specifiers.<br />

Specifier Description<br />

c A character is expected. The subsequent argument must be an<br />

alphanumeric data item. The normal skip over white-space characters is<br />

suppressed in this case. To read the next nonspace character, use %1s.<br />

If a field width is given, the corresponding argument must refer to an<br />

alphanumeric item. The indicated number of characters is read.<br />

d A decimal integer is expected. The subsequent argument must be a<br />

full-word BINARY data item.<br />

e, E, f, g, G A floating-point number is expected. The corresponding argument must<br />

be a floating point value.<br />

i An integer is expected. The corresponding argument must be a full-word<br />

BINARY data item.<br />

n No input is consumed. The subsequent argument must be a full-word<br />

BINARY data item into which is written the number of characters read<br />

from the input stream so far by this call to cifs$fscanf. This is not<br />

counted as a match input item.<br />

o An octal integer is expected. The subsequent argument must be an<br />

integer.<br />

s A character string is expected. The subsequent argument must be an<br />

alphanumeric data item that is large enough to accept the string <strong>and</strong> a<br />

terminating NUL, which is added automatically. A space, a horizontal tab,<br />

or a newline (line feed) character terminates the input field but is not part<br />

of the field.<br />

u An unsigned decimal integer is expected.<br />

6–64 7859 6137–009


Specifier Description<br />

The subsequent argument must be a full-word BINARY data item.<br />

<strong>CIFS</strong>$FSCANF<br />

x, X A hexadecimal integer is expected. The subsequent argument must be<br />

an integer.<br />

[ A string that is not to be delimited by spaces is expected. The normal<br />

skip over white-space characters is suppressed in this case. The<br />

subsequent argument must be an alphanumeric data item just as <strong>for</strong> %s.<br />

The left bracket is followed by a set of characters followed by a right<br />

bracket. The characters between the brackets define the set that<br />

determines the input field string.<br />

If the first character after the left bracket is not a circumflex (^), the input<br />

field consists entirely of characters in the defining set. The first input<br />

character not in the defining set signals the end of the input field.<br />

If the first character after the left bracket is a circumflex (^), the input<br />

field consists entirely of characters not in the defining set. The first input<br />

character in the defining set signals the end of the input field.<br />

If the first character is a right bracket (possibly following a circumflex), it<br />

is assumed to be part of the set. A second right bracket is necessary to<br />

delimit the set. This means the set of characters cannot be empty.<br />

A NUL character is appended to the input.<br />

% A single % is expected in the input at this point. No assignment occurs.<br />

Considerations <strong>for</strong> Conversion Specifications<br />

Only the characters in the table above can be used as conversion specifiers. If you use<br />

any other character as a conversion specifier, the service subprogram does not recognize<br />

it. Scanning terminates <strong>and</strong> the service subprogram returns the number of input items<br />

successfully read.<br />

The conversion specifiers d, i, o, u, <strong>and</strong> x can be preceded by h to indicate a PIC 9(5)<br />

BINARY, or by ll (lowercase double L) to indicate a PIC S1(72) BINARY-1 data item.<br />

Similarly, the conversion specifiers e <strong>and</strong> f can be preceded by l to indicate that the<br />

subsequent argument is a COMP-2 data item rather than a COMP-1 data item, or by L to<br />

indicate a COMP-2 data item.<br />

If cifs$fscanf encounters the end of the file during a conversion, the conversion<br />

terminates. If conversion terminates on a conflicting input character, the offending<br />

character is left unread in the input stream. Trailing white-space characters (including a<br />

newline character) are unread unless matched in the control string. The compiler cannot<br />

directly determine the success of literal matches <strong>and</strong> suppressed assignments other<br />

than through the %n conversion.<br />

If a <strong>for</strong>mat does not have a corresponding argument, the <strong>for</strong>mat is treated as if an<br />

asterisk (*) flag were specified.<br />

7859 6137–009 6–65


<strong>CIFS</strong>$FSCANF<br />

Return Values<br />

If it completes successfully, the cifs$fscanf service subprogram returns the number of<br />

assigned input items (which can be fewer than provided <strong>for</strong>, or even 0, in the event of an<br />

early conflict between an input character <strong>and</strong> the <strong>for</strong>mat) into the items-scanned<br />

argument, or EOF if end of file is encountered be<strong>for</strong>e the first conflict or conversion.<br />

Otherwise, cifs$fscanf returns when it encounters the end of the <strong>for</strong>mat string.<br />

6–66 7859 6137–009


<strong>CIFS</strong>$FSEEK<br />

Application<br />

<strong>CIFS</strong>$FSEEK<br />

Use the cifs$fseek service subprogram to set the file position indicator <strong>for</strong> a stream.<br />

Synopsis<br />

CALL "cifs$fseek" USING cifs-file, offset, whence, cifs-status.<br />

Description<br />

The cifs$fseek service subprogram sets the file position indicator <strong>for</strong> a stream, where:<br />

cifs-file<br />

offset<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

is a 1-word ( 1(36) BINARY-1 ) data item specifying the number of characters to<br />

move the indicator from the starting position.<br />

whence<br />

is a 1-word ( 1(36) BINARY-1 ) data item that specifies the starting position in the file,<br />

which can be one of the following values:<br />

0 The beginning of the file<br />

1 The current position<br />

2 The end of the file<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$fseek service subprogram clears the end-of-file indicator <strong>and</strong> undoes any<br />

effects of cifs$ungetc. After a call to cifs$fseek <strong>for</strong> an update file, the next operation can<br />

be either input or output.<br />

Return Values<br />

If the cifs$fseek service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$fseek sets cifs-status to identify the specific error that was encountered.<br />

7859 6137–009 6–67


<strong>CIFS</strong>$FSETP<strong>OS</strong><br />

<strong>CIFS</strong>$FSETP<strong>OS</strong><br />

Application<br />

Use the cifs$fsetpos service subprogram to set the file position indicator <strong>for</strong> a stream.<br />

Synopsis<br />

CALL "cifs$fsetpos" USING cifs-file, cifs-fpos, cifs-status.<br />

Description<br />

The cifs$fsetpos service subprogram sets the file position indicator <strong>for</strong> a stream, where:<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-fpos<br />

is a 2-word group item containing the new value <strong>for</strong> the file position indicator. Use<br />

the COBOL COPY PROC <strong>CIFS</strong>-FP<strong>OS</strong> <strong>for</strong> the declaration of this variable. This<br />

structure must be obtained by a call to the cifs$fgetpos service subprogram.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If it completes successfully, the cifs$fsetpos service subprogram returns 0 in cifs-status.<br />

Otherwise, cifs$fsetpos sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–68 7859 6137–009


<strong>CIFS</strong>$FSTAT<br />

Application<br />

<strong>CIFS</strong>$FSTAT<br />

Use the cifs$fstat service subprogram to retrieve in<strong>for</strong>mation about an open file. In<br />

particular, you can get in<strong>for</strong>mation about the file mode, security attributes, file size, <strong>and</strong><br />

access times.<br />

The cifs$fstat service subprogram uses a file descriptor to identify the file or directory.<br />

See the cifs$stat service subprogram <strong>for</strong> a similar service subprogram that uses a path<br />

name.<br />

Synopsis<br />

CALL "cifs$fstat" USING fildes, cifs-stat, cifs-status.<br />

Description<br />

The cifs$fstat service subprogram returns in<strong>for</strong>mation about an open file in a group item,<br />

where:<br />

fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be used.<br />

cifs-stat<br />

is a group item in which cifs$fstat returns the file in<strong>for</strong>mation. Use the COBOL<br />

COPY PROC <strong>CIFS</strong>-STAT <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

7859 6137–009 6–69


<strong>CIFS</strong>$FSTAT<br />

The cifs-stat Data Item<br />

The cifs-stat group item identifies certain in<strong>for</strong>mation about a file or directory. The<br />

following table describes the data item, which is defined in the COBOL COPY PROC<br />

<strong>CIFS</strong>-STAT. The size of the data item cifs-stat is 44 bytes.<br />

Field Name Offset Description<br />

cifs-stat-mode 0 File mode.<br />

cifs-stat-ino 4 File serial number.<br />

cifs-stat-dev 8 Numeric identifier <strong>for</strong> the file system in which<br />

the file resides.<br />

cifs-stat-nlink 12 Number of links to the file or directory.<br />

cifs-stat-uid 16 Owner user ID of file or directory.<br />

cifs-stat-gid 20 Group-ID of file or directory.<br />

cifs-stat-size 24 Size, in bytes, <strong>for</strong> directories or regular files;<br />

bytes available to be read <strong>for</strong> pipe or FIFO<br />

files.<br />

cifs-stat-rdev 28 If the inode represents a device file, this value<br />

identifies the specific type of device that the<br />

inode controls. The values are<br />

1 = /dev/tty<br />

2 = st<strong>and</strong>ard input, output, or error device<br />

3 = /dev/null<br />

4 = /dev/r<strong>and</strong>om or /dev/ur<strong>and</strong>om<br />

cifs-stat-atime 32 Time of last access to file data.<br />

cifs-stat-mtime 36 Time of last data modification.<br />

cifs-stat-ctime 40 Time of file creation.<br />

Return Values<br />

If the cifs$fstat service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$fstat sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fstat service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor.<br />

<strong>CIFS</strong>-EFAULT The address stored in cifs-stat is invalid.<br />

6–70 7859 6137–009


<strong>CIFS</strong>$FSYNC<br />

Application<br />

<strong>CIFS</strong>$FSYNC<br />

Use the cifs$fsync service subprogram to write to the device all data currently in the<br />

buffer cache <strong>for</strong> a file, thus protecting the data against loss due to a system outage.<br />

With cifs$fsync, an application can synchronize all file updates at one time, instead of on<br />

every read or write operation. The cifs$fsync service subprogram also synchronizes file<br />

access times.<br />

For a similar service subprogram that does not synchronize file access times, see<br />

cifs$fdatasync. For alternate methods of synchronizing disk data, see the discussions of<br />

the <strong>CIFS</strong>-OFLAG-SYNC <strong>and</strong> <strong>CIFS</strong>-OFLAG-DSYNC flags under the cifs$open <strong>and</strong> cifs$fcntl<br />

service subprograms.<br />

Synopsis<br />

CALL "cifs$fsync" USING fildes, cifs-status.<br />

Description<br />

The cifs$fsync service subprogram writes from the buffer cache to the mass storage<br />

device all data belonging to the specified file, where fildes specifies a regular file open<br />

<strong>for</strong> writing.<br />

fildes<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be used.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$fsync service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$fsync sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$fsync service subprogram returns a<br />

nonzero value in the cifs-status parameter.<br />

The following COBOL level 88 condition names (defined in the COBOL COPY PROC<br />

<strong>CIFS</strong>-API) can be checked in order to determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

<strong>CIFS</strong>-EINVAL Data synchronization is not supported <strong>for</strong> the type of file described by<br />

fildes.<br />

<strong>CIFS</strong>-EIO The file could not be fully synchronized because of an I/O error.<br />

7859 6137–009 6–71


<strong>CIFS</strong>$FTELL<br />

<strong>CIFS</strong>$FTELL<br />

Application<br />

Use the cifs$ftell service subprogram to obtain the current value of the file position<br />

indicator <strong>for</strong> a stream.<br />

Synopsis<br />

CALL "cifs$ftell" USING cifs-file, offset, cifs-status.<br />

Description<br />

The cifs$ftell service subprogram obtains the current value in bytes of the file position<br />

indicator <strong>for</strong> a stream, relative to the beginning of the file, where:<br />

cifs-file<br />

offset<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the file position indicator <strong>for</strong><br />

the stream returned from cifs$ftell.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$ftell service subprogram returns successfully, the current value of the file<br />

position indicator <strong>for</strong> the stream, relative to the beginning of the file, is placed into the<br />

offset parameter <strong>and</strong> the cifs-status parameter is set to 0. Otherwise, cifs$ftell sets<br />

cifs-status to identify the specific error that was encountered.<br />

6–72 7859 6137–009


<strong>CIFS</strong>$FTRUNCATE<br />

Application<br />

<strong>CIFS</strong>$FTRUNCATE<br />

The cifs$ftruncate service subprogram sets the end-of-file position <strong>for</strong> an open file.<br />

Synopsis<br />

CALL "cifs$ftruncate" USING fildes, length, cifs-status.<br />

Description<br />

A file referenced by the descriptor fildes has its size (in bytes) set to length. If the file<br />

was previously longer than the length specified, those bytes are no longer accessible. If<br />

the file was previously shorter than the length specified, bytes between the old end of<br />

file <strong>and</strong> the specified length are read as zeroes. For cifs$ftruncate, the calling program<br />

must have the file open <strong>for</strong> writing.<br />

For files stored in SDF <strong>for</strong>mat, the length value of 34359738367 (defined as INT_MAX in<br />

the limits.h header file) has special meaning. <strong>CIFS</strong> treats this as an indication that it must<br />

recalculate the actual size of the file when next read based on the position of the EOF<br />

record, rather than pad the file with zeroes.<br />

fildes<br />

length<br />

is a 1-word (S1(36) BINARY-1) data item which contains a file descriptor of the file<br />

being used.<br />

is a 1-word (S1(36) BINARY-1) data item.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$ftruncate service subprogram completes successfully, it returns 0 in<br />

cifs-status. Otherwise, cifs$fruncate sets cifs-status to identify the specific error that<br />

was encountered.<br />

7859 6137–009 6–73


<strong>CIFS</strong>$FWRITE<br />

<strong>CIFS</strong>$FWRITE<br />

Application<br />

Use the cifs$fwrite service subprogram to write elements from a buffer to an output<br />

stream.<br />

Synopsis<br />

CALL "cifs$fwrite" USING buffer, elt-size, elt-count, cifs-file,<br />

elts-written, cifs-status.<br />

Description<br />

The cifs$fwrite service subprogram writes elements from an array to an output stream,<br />

where:<br />

buffer<br />

elt-size<br />

is an alphanumeric character string to be written to the output stream.<br />

specifies the size of an element in the array.<br />

elt-count<br />

cifs-file<br />

specifies the number of elements to attempt to write.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

elts-written<br />

specifies the number of elements written.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$fwrite service subprogram advances the file position indicator by the number of<br />

bytes successfully written. If an error occurs, the resulting value of the file position<br />

indicator is indeterminate.<br />

Return Values<br />

If it completes successfully, the cifs$fwrite service subprogram returns the number of<br />

elements written into elts-written; this number is less than elts-count only if a write error<br />

occurs. If an error occurs, cifs-status is set to identify the specific error that was<br />

encountered.<br />

6–74 7859 6137–009


<strong>CIFS</strong>$GETC<br />

Application<br />

<strong>CIFS</strong>$GETC<br />

Use the cifs$getc service subprogram to obtain the next character from an input stream.<br />

Synopsis<br />

CALL "cifs$getc" USING cifs-file, next-char, cifs-status.<br />

Description<br />

The cifs$getc service subprogram is equivalent to cifs$fgetc.<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

next-char<br />

is a 1-byte field used to hold the next character that is retrieved.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$getc service subprogram completes successfully, it returns the next character<br />

from the specified input stream <strong>and</strong> returns 0 in cifs-status. Otherwise, cifs$getc sets<br />

cifs-status to identify the specific error that was encountered.<br />

Application<br />

Use the cifs$getchar service subprogram to obtain the next character from st<strong>and</strong>ard<br />

input.<br />

Synopsis<br />

CALL "cifs$getchar" USING next-char, cifs-status.<br />

Description<br />

The cifs$getchar service subprogram is equivalent to calling cifs$getc with the cifs-file<br />

argument set to st<strong>and</strong>ard input.<br />

next-char<br />

is a 1-byte field used to hold the next character that is retrieved.<br />

7859 6137–009 6–75


<strong>CIFS</strong>$GETC<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

The cifs$getchar service subprogram returns the next character from st<strong>and</strong>ard input <strong>and</strong><br />

returns 0 in cifs-status. Otherwise, cifs$getchar sets cifs-status to identify the specific<br />

error that was encountered.<br />

6–76 7859 6137–009


<strong>CIFS</strong>$GETCWD<br />

Application<br />

<strong>CIFS</strong>$GETCWD<br />

Use the cifs$getcwd service subprogram to identify a process' current working directory.<br />

You can specify where the in<strong>for</strong>mation is returned.<br />

Synopsis<br />

CALL "cifs$getcwd" USING path-buffer, max-size, cifs-status.<br />

Description<br />

The cifs$getcwd service subprogram identifies the absolute path name of the current<br />

working directory of the calling process, where:<br />

path-buffer<br />

is an alphanumeric field into which the cifs$getcwd service subprogram returns the<br />

path name of the current working directory in the path.<br />

max-size<br />

is the size in bytes of path-buffer. This variable must be declared as 9(10) BINARY. If<br />

the path name of the working directory has more characters in it than max-size<br />

allows, an error occurs.<br />

cifs-status<br />

is a 1-word (1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$getcwd service subprogram completes successfully, it returns the absolute<br />

path name <strong>for</strong> the current working directory into the parameter path-buffer. Otherwise,<br />

cifs$getcwd sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$getcwd service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EFAULT The path-buffer is invalid.<br />

<strong>CIFS</strong>-EINVAL max-size is less than or equal to 0.<br />

<strong>CIFS</strong>-ENOMEM The path-buffer is null <strong>and</strong> no memory space is available to the<br />

process.<br />

<strong>CIFS</strong>-ERANGE max-size is greater than 0 but less than the length of the path<br />

name plus 1.<br />

7859 6137–009 6–77


<strong>CIFS</strong>$GETS<br />

<strong>CIFS</strong>$GETS<br />

Application<br />

Use the cifs$gets service subprogram to read a string of characters from st<strong>and</strong>ard input<br />

into an array.<br />

Synopsis<br />

CALL "cifs$gets" USING string, cifs-status.<br />

Description<br />

The cifs$gets service subprogram reads characters from the st<strong>and</strong>ard input stream <strong>and</strong><br />

places them into the argument string, until it encounters the end of the file or a newline<br />

(line feed) character. Cif$gets discards any newline character <strong>and</strong> writes a nul character<br />

immediately after the last character in the character string.<br />

string<br />

is an alphanumeric data item that contains the characters read from the st<strong>and</strong>ard<br />

input stream.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If cifs$gets completes successfully, the service subprogram returns the characters into<br />

the string parameter <strong>and</strong> returns 0 in cifs-status. If cifs$gets encounters end of file<br />

be<strong>for</strong>e reading any characters into the string parameter, the contents of the string<br />

parameter remain unchanged. If a read error occurs, the contents of the array are<br />

indeterminate. Otherwise, cifs$gets sets cifs-status to identify the specific error that<br />

was encountered.<br />

6–78 7859 6137–009


<strong>CIFS</strong>$ISTAT<br />

Application<br />

<strong>CIFS</strong>$ISTAT<br />

Use the cifs$istat service subprogram to retrieve <strong>CIFS</strong>-unique in<strong>for</strong>mation about a file or<br />

directory.<br />

Synopsis<br />

CALL "cifs$istat" USING cifs-stat-ino, cifs-istat, size, cifs-status.<br />

Description<br />

If cifs-stat-ino corresponds to a valid file serial number, the service subprogram places up<br />

to size bytes of the following in<strong>for</strong>mation into the cifs-istat area. The cifs-stat-ino<br />

argument is typically obtained from the <strong>CIFS</strong>-STAT-INO field of the <strong>CIFS</strong>-STAT group<br />

item (COPY PROC <strong>CIFS</strong>-STAT) returned by a cifs$stat or cifs$fstat service subprogram.<br />

cifs-stat-ino<br />

is a data item that corresponds to a valid file serial number. The COBOL COPY PROC<br />

<strong>CIFS</strong>-STAT contains the declaration of this variable.<br />

cifs-istat<br />

size<br />

is group item in which cifs$istat returns the file in<strong>for</strong>mation. Use the COBOL COPY<br />

PROC <strong>CIFS</strong>-STAT <strong>for</strong> the declaration of this variable.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the number of bytes to store<br />

into the cifs-istat buffer.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The <strong>CIFS</strong>-ISTAT buffer contains the following fields.<br />

Field Name Offset Description<br />

cifs-istat-cycle 0 <strong>OS</strong> <strong>2200</strong> absolute F-cycle of this file.<br />

cifs-istat-cycle-chain 4 Inode number of the next <strong>OS</strong> <strong>2200</strong> F-cycle<br />

of this same file name. See File Definition<br />

<strong>and</strong> File Types in Section 3 <strong>for</strong> a description<br />

of inode.<br />

cifs-istat-alt-os-dir-ino 8 Inode number of the alternate <strong>OS</strong> <strong>2200</strong><br />

directory version of this file name. See File<br />

Definition <strong>and</strong> File Types in Section 3 <strong>for</strong> a<br />

description of inode.<br />

7859 6137–009 6–79


<strong>CIFS</strong>$ISTAT<br />

Field Name Offset Description<br />

cifs-istat-os<strong>2200</strong> 12 Indicates where a directory inode appears in<br />

the /os<strong>2200</strong> hierarchy. See File Definition<br />

<strong>and</strong> File Types in Section 3 <strong>for</strong> a description<br />

of inode.<br />

Can contain the following values:<br />

0 Not in the /os<strong>2200</strong> hierarchy<br />

1 The /os<strong>2200</strong> directory<br />

2 An immediate subdirectory (qualifier) of<br />

/os<strong>2200</strong><br />

3 A program or data file in the /os<strong>2200</strong><br />

hierarchy<br />

cifs-istat-owner 16 Owner of the file. For owned files, this is the<br />

<strong>OS</strong> <strong>2200</strong> user ID. For unowned files, this is<br />

the project or account, depending on the<br />

value of the configuration variable PRIVAC.<br />

cifs-istat-directory 29 The <strong>OS</strong> <strong>2200</strong> MFD containing this file; either<br />

STD or SHARED.<br />

cifs-istat-contain 36 For regular files, the name of the underlying<br />

<strong>OS</strong> <strong>2200</strong> file container. The field contains a<br />

null string <strong>for</strong> other file types.<br />

cifs-istat-element-name 74 The element name associated with the file;<br />

null string if the file is not stored as an<br />

<strong>OS</strong> <strong>2200</strong> element.<br />

cifs-istat-element-version 87 The element version associated with the file;<br />

not used if the file is not stored as an<br />

<strong>OS</strong> <strong>2200</strong> element.<br />

cifs-istat-element-type 100 The type of the underlying element, either 1,<br />

5, 6, or 7. Not used if the file is not stored<br />

as an <strong>OS</strong> <strong>2200</strong> element.<br />

cifs-istat-element-sub-type 102 The subtype of the underlying symbolic or<br />

omnibus element; not used <strong>for</strong> other<br />

element types or if the file is not stored as<br />

an <strong>OS</strong> <strong>2200</strong> element.<br />

cifs-istat-share 104 For directories, the network share name<br />

assigned to it; a null string if the directory is<br />

not shared.<br />

cifs-istat-acr 136 The ACR name associated with a file.<br />

The size of <strong>CIFS</strong>-ISTAT is 144 bytes. The data item <strong>CIFS</strong>-ISTAT-SIZE contains this<br />

in<strong>for</strong>mation. The data is stored in the order listed; whatever does not fit in size bytes is<br />

discarded.<br />

Return Values<br />

If the cifs$istat service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$istat sets cifs-status to identify the specific error that was encountered.<br />

6–80 7859 6137–009


<strong>CIFS</strong>$LINK<br />

Application<br />

<strong>CIFS</strong>$LINK<br />

Use the cifs$link service subprogram to create new directory entries <strong>for</strong> a file, allowing<br />

you to reference one file in multiple ways. The new entries can be in the same directory<br />

or in different directories.<br />

cifs$link increases the link count of the referenced file by 1.<br />

Synopsis<br />

CALL "cifs$link" USING path1, path2, cifs-status.<br />

Description<br />

The cifs$link service subprogram creates a new directory entry (link), provided the<br />

process has the necessary permissions (see “Permissions Required” in this subsection),<br />

where:<br />

path1<br />

path2<br />

is an alphanumeric variable that contains the name of an existing regular or FIFO file.<br />

is an alphanumeric variable that contains the path name <strong>for</strong> the new link <strong>for</strong> the file<br />

named by path1. The directory in which the new link is created must be in the same<br />

file system as path1.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Diagrams<br />

The cifs$link service subprogram causes both directory entries to refer to the same<br />

physical file. In the following diagrams, both link_1 <strong>and</strong> link_2 refer to the same file,<br />

whether they are in the same directory or not.<br />

7859 6137–009 6–81


<strong>CIFS</strong>$LINK<br />

Permissions Required<br />

The calling process must have all the following permissions to create the link:<br />

• Search permission <strong>for</strong> all the path1 component directories<br />

• Search permission <strong>for</strong> all the path2 component directories<br />

• Write permission to the parent directory of the new file<br />

Return Values<br />

If the cifs$link service subprogram completes successfully, it does the following:<br />

• Updates the last accessed time field of the path1 file<br />

• Updates the last modified time field of the path2 directory<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$link sets cifs-status to identify the specific error that was encountered.<br />

6–82 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$LINK<br />

If any of the following conditions occurs, the cifs$link service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a<br />

component of either path name.<br />

• The calling process is denied write permission to the<br />

path2 directory.<br />

<strong>CIFS</strong>-EEXIST The link named by path2 already exists.<br />

<strong>CIFS</strong>-EFAULT The value specified by path1 or path2 is invalid.<br />

<strong>CIFS</strong>-EIO An I/O error occurred.<br />

<strong>CIFS</strong>-EMLINK The number of links to the file named by path1 exceeds the<br />

maximum.<br />

<strong>CIFS</strong>-ENOENT Any of the following errors occurred:<br />

• A directory in either path name does not exist.<br />

• The file in path1 does not exist.<br />

• Either path1 or path2 contains an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC The path2 directory to contain the link has too many entries.<br />

<strong>CIFS</strong>-ENOTDIR A component of either path name prefix is not a directory.<br />

<strong>CIFS</strong>-EPERM The file named by path1 is a directory or a character file.<br />

7859 6137–009 6–83


<strong>CIFS</strong>$LSEEK<br />

<strong>CIFS</strong>$LSEEK<br />

Application<br />

Use the cifs$lseek service subprogram to set the read/write offset <strong>for</strong> an open file at a<br />

specific position in the file. You can also set the read/write offset beyond the end of<br />

existing data in the file without increasing the file size; however, a write operation at that<br />

location increases the file size.<br />

Definition<br />

The read/write offset is the file address at which the next cifs$read or cifs$write<br />

operation starts.<br />

Synopsis<br />

CALL "cifs$lseek" USING fildes, offset, whence, new-offset, cifs-status.<br />

Description<br />

The cifs$lseek service subprogram sets the read/write offset <strong>for</strong> an open file description,<br />

where:<br />

fildes<br />

offset<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be used.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that specifies the new location of the<br />

read/write offset from the beginning, current position, or end of a file, as shown in<br />

the table <strong>and</strong> diagram below.<br />

whence<br />

is a 1-word ( 1(36) BINARY-1 ) data item that specifies whether the read/write offset<br />

is calculated from the beginning, current position, or end of a file. See the following<br />

table <strong>and</strong> diagram <strong>for</strong> the valid values <strong>for</strong> whence <strong>and</strong> their relationships to offset.<br />

Value of<br />

whence<br />

How the Read/Write Offset Is<br />

Calculated<br />

1 Current offset value plus offset bytes<br />

2 Size of the file plus offset bytes<br />

0 offset bytes from the beginning of the<br />

file<br />

6–84 7859 6137–009


new-offset<br />

<strong>CIFS</strong>$LSEEK<br />

is a 1-word ( 1(36) BINARY-1 ) data item that specifies the new read/write offset<br />

from the beginning of the file.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Illustration<br />

Given a value <strong>for</strong> offset, the value of whence determines whether the read/write offset<br />

occurs at the beginning, current position, or end of a file. The following diagram shows<br />

the possible new positions of the read/write offset:<br />

Reading Unwritten Areas<br />

If a file contains unwritten gaps, reading these areas returns bytes with the value 0.<br />

However, files created outside of <strong>CIFS</strong> can contain unwritten data that is not detectable;<br />

reading these areas returns bytes with indeterminate values.<br />

Service Subprogram Behavior <strong>for</strong> Different File Types<br />

All calls to cifs$lseek fail <strong>for</strong> the following file types:<br />

• Pipes<br />

• FIFO files<br />

For some types of files, a read/write offset is not meaningful; <strong>for</strong> these files, the<br />

read/write offset returned by cifs$lseek is undefined.<br />

Portability Issue<br />

In other implementations, the returned argument new-offset can be unsigned. To test<br />

<strong>for</strong> an error in a portable way, compare the returned argument new-offset with -1.<br />

7859 6137–009 6–85


<strong>CIFS</strong>$LSEEK<br />

Return Values<br />

If the cifs$lseek service subprogram completes successfully, it returns the new<br />

read/write offset location in bytes from the beginning of the file in the new-offset<br />

argument. Otherwise, cifs$lseek sets cifs-status to identify the specific error that was<br />

encountered <strong>and</strong> returns a value of –1 in the new-offset argument.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$lseek service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor.<br />

<strong>CIFS</strong>-EINVAL One of the following errors occurred:<br />

• whence is invalid.<br />

• The resulting read/write offset would be<br />

invalid (that is, negative).<br />

<strong>CIFS</strong>-ESPIPE fildes is associated with a pipe or FIFO file.<br />

6–86 7859 6137–009


<strong>CIFS</strong>$MASK<br />

Application<br />

<strong>CIFS</strong>$MASK<br />

Use the cifs$mask service subprogram to determine whether a given string matches a<br />

wild card pattern.<br />

Note: There is no P<strong>OS</strong>IX equivalent to cifs$mask.<br />

Synopsis<br />

CALL "cifs$mask" USING name, mask, result.<br />

Description<br />

name<br />

mask<br />

result<br />

is an alphanumeric variable that contains the name to check.<br />

is an alphanumeric variable that contains the mask characters.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the result of the operation.<br />

The cifs$mask service subprogram checks the name parameter <strong>for</strong> con<strong>for</strong>mance with<br />

the mask parameter. The mask parameter may contain the wild card characters asterisk<br />

(*) <strong>and</strong> question mark (?).<br />

A question mark matches a single occurrence of any character; an asterisk matches zero<br />

or more occurrences of any character. Other characters in mask must be a<br />

case-insensitive match to ones in the corresponding positions of name, in order <strong>for</strong> the<br />

service subprogram to return a nonzero result. For example, the name “abcdef”<br />

con<strong>for</strong>ms to “abc*” <strong>and</strong> “aBc???”, but not to “abc?” Wild card characters may be mixed<br />

in any order <strong>and</strong> with any other characters.<br />

Return Values<br />

The cifs$mask service subprogram returns nonzero in the result argument if name<br />

con<strong>for</strong>ms to mask, 0 if it does not.<br />

7859 6137–009 6–87


<strong>CIFS</strong>$MKDIR<br />

<strong>CIFS</strong>$MKDIR<br />

Application<br />

Use the cifs$mkdir service subprogram to create a new directory, setting its file<br />

permissions <strong>and</strong> security attributes. The directory is empty except <strong>for</strong> its dot <strong>and</strong> dot-dot<br />

entries. Once the directory is created, you can make directory entries.<br />

Synopsis<br />

CALL "cifs$mkdir" USING path, cifs-mode, cifs-status.<br />

Description<br />

The cifs$mkdir service subprogram creates a directory containing only the dot <strong>and</strong> dotdot<br />

entries, where:<br />

path<br />

is an alphanumeric data item that contains the name of the new directory.<br />

cifs-mode<br />

is a 1-word (1(36) BINARY-1) data item that contains the file permission settings <strong>for</strong><br />

the new file, which are first modified by the file mode creation mask of the calling<br />

process. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this<br />

variable. In addition to the permission bits, you can specify the creation of a Large<br />

Element Program File (LEPF); see <strong>CIFS</strong>$CHMOD <strong>for</strong> the LEPF <strong>and</strong> NPF mode<br />

settings.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

File Mode Attributes<br />

The cifs$mkdir service subprogram also sets the following attributes in the file mode <strong>for</strong><br />

the directory:<br />

• The user ID of the new directory to the effective user ID of the calling process<br />

• The group-ID of the new directory, to the effective group-ID of the process<br />

Return Values<br />

If the cifs$mkdir service subprogram completes successfully, it does the following:<br />

• Sets the file permissions, user ID, <strong>and</strong> group-ID <strong>for</strong> the new directory, as discussed<br />

in the preceding paragraphs<br />

• Sets the last accessed, last modified <strong>and</strong> last file status change fields of the new<br />

directory<br />

• Updates the last accessed <strong>and</strong> last modified fields of the parent directory<br />

6–88 7859 6137–009


• Returns 0 in the cifs-status parameter<br />

Otherwise, cifs$mkdir sets cifs-status to identify the specific error that was<br />

encountered.<br />

Error Codes<br />

<strong>CIFS</strong>$MKDIR<br />

If any of the following conditions occurs, the cifs$mkdir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES The calling process is denied one of the following:<br />

• Search permission to a directory in the path name<br />

• Write permission on the parent directory of the new directory<br />

<strong>CIFS</strong>-EEXIST A directory with the same path name already exists.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-EINVAL cifs-mode has undefined bits set.<br />

<strong>CIFS</strong>-EMLINK The link count of the parent directory exceeds the C st<strong>and</strong>ard<br />

value INT_MAX.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC Either of the following errors occurred:<br />

• The parent directory has too many entries.<br />

• The file system does not have enough space to hold the new<br />

directory.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name prefix is not a directory.<br />

7859 6137–009 6–89


<strong>CIFS</strong>$MKFIFO<br />

<strong>CIFS</strong>$MKFIFO<br />

Application<br />

Use the cifs$mkfifo service subprogram to create a new first-in-first-out (FIFO) file,<br />

setting its file permissions <strong>and</strong> security attributes. The new FIFO file is empty.<br />

Synopsis<br />

CALL "cifs$mkfifo" USING path, cifs-mode, cifs-status.<br />

Description<br />

The cifs$mkfifo service subprogram creates a FIFO file, where:<br />

path<br />

is an alphanumeric data item that contains the name of the new FIFO file.<br />

cifs-mode<br />

is a 1-word (1(36) BINARY-1) data item that contains the file permission settings <strong>for</strong><br />

the new FIFO file, which are first modified by the file mode creation mask of the<br />

calling process. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this<br />

variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

File Mode Attributes<br />

The cifs$mkfifo service subprogram also sets the following attributes in the file mode:<br />

• The user ID of the new FIFO file to the effective user ID of the calling process<br />

• The group-ID of the new FIFO file to the effective group-ID of the process<br />

Return Values<br />

If the cifs$mkfifo service subprogram completes successfully, it does the following:<br />

• Sets the file permissions, user ID, <strong>and</strong> group ID <strong>for</strong> the new FIFO file, as discussed<br />

in the preceding paragraphs<br />

• Sets the last accessed, last modified <strong>and</strong> last file status change fields of the new<br />

FIFO file<br />

• Updates the last accessed <strong>and</strong> last modified fields of the parent directory<br />

• Returns 0 in the cifs-status parameter<br />

Otherwise, cifs$mkfifo sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–90 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$MKFIFO<br />

If any of the following conditions occurs, the cifs$mkfifo service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned.<br />

<strong>CIFS</strong>-EACCES The calling process is denied one of the<br />

following:<br />

• Search permission to a component of the<br />

path name<br />

• Write permission to the parent directory of<br />

the new file<br />

<strong>CIFS</strong>-EEXIST A file with the same path name already exists.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-EINVAL cifs-mode has bits set that are either<br />

undefined or not file permission bits.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• A directory in the path name does not<br />

exist.<br />

• path points to an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC Either of the following errors occurred:<br />

• The parent directory has too many entries.<br />

• The file system does not have enough<br />

resources <strong>for</strong> file allocation.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path prefix is not a<br />

directory.<br />

<strong>CIFS</strong>-EROFS The parent directory exists on a read-only file<br />

system.<br />

7859 6137–009 6–91


<strong>CIFS</strong>$OPEN<br />

<strong>CIFS</strong>$OPEN<br />

Application<br />

Use the cifs$open service subprogram to open a file, specifying how you can access the<br />

file <strong>and</strong> setting special attributes. Opening a file does the following:<br />

• Creates an open file description <strong>and</strong> corresponding file descriptor <strong>for</strong> this unique<br />

instance of the open file.<br />

Note: The new open file description is not shared by any other process on the<br />

system; the file descriptor identifies this open file description only.<br />

• Can create the file, if it does not already exist. In this case, you must also specify the<br />

file permissions <strong>for</strong> the file mode. See also the cifs$creat service subprogram.<br />

Synopsis<br />

CALL "cifs$open" USING path, cifs-oflag, cifs-mode, new-fd, cifs-status.<br />

Description<br />

The cifs$open service subprogram opens a file, where:<br />

path<br />

is an alphanumeric variable that contains the name of the file to be opened.<br />

cifs-oflag<br />

sets the access specification <strong>and</strong> file status flags in the open file description. See<br />

"The oflag Argument" in a following subsection <strong>for</strong> the valid values <strong>for</strong> cifs-oflag. Use<br />

the COBOL COPY PROC <strong>CIFS</strong>-OFLAG <strong>for</strong> the declaration of this variable.<br />

cifs-mode<br />

new-fd<br />

is a 1-word (1(36) BINARY-1) data item that sets the file permissions when a new file<br />

is created (see the file status flag <strong>CIFS</strong>-OFLAG-CREAT). See “The mode Argument”<br />

in a following subsection <strong>for</strong> the valid values <strong>for</strong> cifs-mode. Use the COBOL COPY<br />

PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this variable.<br />

is a 1-word (S1(36) BINARY-1) data item into which the file description of the newly<br />

created file is placed.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

6–92 7859 6137–009


Results of Opening a File<br />

The cifs$open service subprogram does the following:<br />

1. Sets the initial read/write offset to the start of the file<br />

2. Selects the numerically lowest available file descriptor <strong>for</strong> the process<br />

<strong>CIFS</strong>$OPEN<br />

3. Returns the file descriptor so that other I/O service subprograms can access the file<br />

Example<br />

The following code statement opens a file that does not currently exist:<br />

move 0 to cifs-oflag.<br />

move 1 to cifs-oflag-creat.<br />

move 1 to cifs-oflag-wronly.<br />

move 1 to cifs-oflag-rdonly.<br />

move 0 to cifs-mode.<br />

compute cifs-mode-irwxu = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxg = cifs-mode-iread + cifs-mode-iwrite.<br />

CALL "cifs$open" USING "/books/novels/f_inventory", cifs-oflag,<br />

cifs-mode, fd-inventory, cifs-status.<br />

The statement does the following tasks:<br />

• Creates the file f-inventory in the directory /books/novels<br />

• Opens the file <strong>for</strong> reading <strong>and</strong> writing<br />

• Assigns read <strong>and</strong> write permission <strong>for</strong> the owner <strong>and</strong> group classes<br />

• Captures the file descriptor returned by cifs$open in fd-inventory<br />

Files Affected by cifs$open<br />

A process must open a file be<strong>for</strong>e reading from or writing to it. The cifs$open service<br />

subprogram opens the following types of files:<br />

• Regular files<br />

• FIFO files<br />

• Directories (<strong>for</strong> reading only)<br />

Note: The cifs$open service subprogram can also create a regular file if it does not<br />

exist. The other types of files must exist be<strong>for</strong>e cifs$open can access them.<br />

Return Values<br />

If the cifs$open service subprogram completes successfully, it does the following:<br />

• Updates the following time in<strong>for</strong>mation fields if <strong>CIFS</strong>-OFLAG-CREAT is set <strong>and</strong> the<br />

file does not exist:<br />

− The last accessed, last modified, <strong>and</strong> last file status change fields <strong>for</strong> the file<br />

− The last accessed <strong>and</strong> last modified fields <strong>for</strong> the parent directory<br />

7859 6137–009 6–93


<strong>CIFS</strong>$OPEN<br />

• Updates the last accessed <strong>and</strong> last modified time in<strong>for</strong>mation fields <strong>for</strong> the file if<br />

<strong>CIFS</strong>-OFLAG-TRUNC is set <strong>for</strong> an existing file<br />

• Returns the file descriptor in new-fd<br />

Otherwise, cifs$open sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$open service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned.<br />

<strong>CIFS</strong>-EACCES Any of the following access errors occurred:<br />

• The calling process is denied search permission on one or<br />

more directories in path.<br />

• The file exists <strong>and</strong> the permissions specified by cifs-oflag<br />

are denied.<br />

• The file does not exist <strong>and</strong> write permission is denied <strong>for</strong><br />

the parent directory of the file to be created.<br />

• <strong>CIFS</strong>-OFLAG-TRUNC is specified <strong>and</strong> write permission is<br />

denied.<br />

<strong>CIFS</strong>-EAGAIN A resource is temporarily unavailable. Either the calling<br />

process attempted to open a file that was rolled out with<br />

O_NONBLOCK set, or the wait time specified by the<br />

<strong>CIFS</strong>$WAITROLBAK environment variable expired. This is a<br />

temporary condition <strong>and</strong> a subsequent call might complete<br />

normally.<br />

<strong>CIFS</strong>-EBUSY A resource is temporarily unavailable. Either the calling<br />

process attempted to open a file that was exclusively<br />

assigned with O_NONBLOCK set, or the wait time specified<br />

by the <strong>CIFS</strong>$WAITXUSE environment variable expired. This is<br />

a temporary condition <strong>and</strong> a subsequent call might complete<br />

normally.<br />

<strong>CIFS</strong>-EEXIST <strong>CIFS</strong>-OFLAG-CREAT <strong>and</strong> <strong>CIFS</strong>-OFLAG-EXCL are set <strong>and</strong> the file<br />

exists.<br />

<strong>CIFS</strong>-EFAULT The name specified by path is invalid.<br />

<strong>CIFS</strong>-EINTR The cifs$open operation was interrupted by a signal.<br />

<strong>CIFS</strong>-EINVAL Any of the following errors occurred:<br />

• <strong>CIFS</strong>-OFLAG-CREAT is specified <strong>and</strong> cifs-mode is missing.<br />

• A cifs$open service subprogram call with read-only<br />

access <strong>and</strong> <strong>CIFS</strong>-OFLAG-TRUNC specified is not valid. The<br />

two options are incompatible.<br />

• cifs-oflag has neither the <strong>CIFS</strong>-OFLAG-RDONLY or the<br />

<strong>CIFS</strong>-OFLAG-WRONLY flags set. One of these flags must<br />

be set.<br />

• A cifs$open service subprogram call with more than one<br />

of <strong>CIFS</strong>-MODE-1100SDF <strong>and</strong> <strong>CIFS</strong>-MODE-1100BIN<br />

specified is not valid.<br />

6–94 7859 6137–009


<strong>CIFS</strong>$OPEN<br />

A file cannot have more than one of these attributes.<br />

• A cifs$open service subprogram call <strong>for</strong> a FIFO file with<br />

read/write access is not valid.<br />

• Either cifs-oflag or cifs-mode has undefined bits set.<br />

<strong>CIFS</strong>-EIO An input/output error occurred.<br />

<strong>CIFS</strong>-EISDIR The file is a directory <strong>and</strong> cifs-oflag specifies write access.<br />

<strong>CIFS</strong>-EMFILE The calling process is attempting to open a file <strong>and</strong> the limit<br />

on the maximum number of open file descriptors <strong>for</strong> a<br />

process would be exceeded.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• <strong>CIFS</strong>-OFLAG-CREAT is not set <strong>and</strong> the file does not exist.<br />

• <strong>CIFS</strong>-OFLAG-CREAT is set <strong>and</strong> either<br />

− A directory in the path name does not exist.<br />

− path contains an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC The directory or file system that is to contain the new file is<br />

out of available space.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name prefix is not a directory.<br />

<strong>CIFS</strong>-ENXIO <strong>CIFS</strong>-OFLAG-NONBLOCK <strong>and</strong> <strong>CIFS</strong>-OFLAG-WRONLY are set<br />

<strong>for</strong> a FIFO file <strong>and</strong> no process has the file open <strong>for</strong> reading.<br />

The cifs-oflag Argument<br />

The cifs-oflag argument contains the following values:<br />

• An access specification value<br />

• Any combination of values <strong>for</strong> file status flags<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-OFLAG <strong>for</strong> the declaration/definition of the cifs-oflag<br />

fields.<br />

7859 6137–009 6–95


<strong>CIFS</strong>$OPEN<br />

Access Specification Values<br />

The following symbolic constants are valid access specifications.<br />

<strong>CIFS</strong>-OFLAG-RDONLY Open the file <strong>for</strong> reading only.<br />

<strong>CIFS</strong>-OFLAG-WRONLY Open the file <strong>for</strong> writing only.<br />

File Status Flag Values<br />

The following symbolic constants are valid file status flags.<br />

<strong>CIFS</strong>-OFLAG-APPEND The read/write offset is set to the end of the file be<strong>for</strong>e<br />

each write operation.<br />

<strong>CIFS</strong>-OFLAG-CREAT The cifs$open service subprogram<br />

• Creates a regular file with path as its path name<br />

• Sets ownership of the regular file, as follows:<br />

− Sets the user ID of the file to the effective<br />

user ID of the process<br />

− Sets the group ID of the file to the effective<br />

group ID of the process<br />

When <strong>CIFS</strong>-OFLAG-CREAT is set, cifs$open requires a<br />

third argument, cifs-mode. The file permission attributes<br />

are set to the value in cifs-mode minus the attributes set<br />

in the process' file mode creation mask (see the<br />

cifs$umask service subprogram). The cifs-mode<br />

argument does not affect whether the file is opened <strong>for</strong><br />

read or write access or both.<br />

<strong>CIFS</strong>-OFLAG-DSYNC The cifs$open service subprogram opens the file <strong>for</strong><br />

synchronized read <strong>and</strong> write operations. The kernel<br />

implements a buffering system <strong>for</strong> the file data in volatile<br />

storage. I/O buffering increases the speed at which data<br />

can be accessed <strong>and</strong> changed, but it also increases the<br />

risk of lost data due to a system failure. When file I/O<br />

operations are not synchronized, it is possible <strong>for</strong> file data<br />

to reside in volatile storage <strong>for</strong> some period of time<br />

without being written to a disk device.<br />

Setting the <strong>CIFS</strong>-OFLAG-DSYNC flag<br />

• Causes any data written through the file descriptor to<br />

also be written to the disk device be<strong>for</strong>e the<br />

cifs$write service subprogram returns<br />

• Ensures that any data read from a file descriptor is<br />

written to the disk device be<strong>for</strong>e the cifs$read service<br />

subprogram returns that data<br />

<strong>CIFS</strong>-OFLAG-EXCL Use <strong>CIFS</strong>-OFLAG-EXCL with <strong>CIFS</strong>-OFLAG-CREAT to<br />

ensure that the file does not already exist, as follows.<br />

6–96 7859 6137–009


If <strong>CIFS</strong>-OFLAG-EXCL is ... And <strong>CIFS</strong>-OFLAG-CREAT is<br />

...<br />

Then ...<br />

<strong>CIFS</strong>$OPEN<br />

Set Set cifs$open fails if the file<br />

exists.<br />

Set Not set cifs$open ignores <strong>CIFS</strong>-<br />

OFLAG-EXCL.<br />

Not set Set cifs$open opens the file if<br />

it already exists;<br />

otherwise, cifs$open<br />

creates the file.<br />

Not set Not set cifs$open opens the file if<br />

it already exists;<br />

otherwise, cifs$open fails.<br />

<strong>CIFS</strong>-OFLAG-NONBLOCK This value determines whether cifs$open waits <strong>for</strong><br />

certain file availability or fails, as follows.<br />

If <strong>CIFS</strong>-OFLAG-<br />

NONBLOCK is ...<br />

And the file type<br />

is ... Then...<br />

Set Regular cifs$open fails if the<br />

<strong>OS</strong> <strong>2200</strong> file container is<br />

rolled out or otherwise<br />

temporarily unavailable.<br />

Set FIFO For read-only access,<br />

cifs$open returns<br />

without a delay.<br />

For write-only access,<br />

cifs$open fails if no<br />

process has the file open<br />

<strong>for</strong> reading.<br />

7859 6137–009 6–97


<strong>CIFS</strong>$OPEN<br />

If <strong>CIFS</strong>-OFLAG-<br />

NONBLOCK is ...<br />

And the file type<br />

is ... Then...<br />

Not set Regular The process waits if the<br />

<strong>OS</strong> <strong>2200</strong> file container is<br />

rolled out or exclusively<br />

assigned. The maximum<br />

wait time can be<br />

specified by the<br />

<strong>CIFS</strong>$WAITROLBAK <strong>and</strong><br />

<strong>CIFS</strong>$WAITXUSE<br />

environment variables.<br />

Not set FIFO For read-only access,<br />

cifs$open waits until a<br />

process opens the file<br />

<strong>for</strong> writing.<br />

For write-only access,<br />

cifs$open waits until a<br />

process opens the file<br />

<strong>for</strong> reading.<br />

<strong>CIFS</strong>-OFLAG-NONBLOCK This has no effect when opening any other type of<br />

file.<br />

<strong>CIFS</strong>-OFLAG-SYNC This value has the same effect as <strong>CIFS</strong>-OFLAG-<br />

DSYNC, with the addition of ensuring that file access<br />

times are updated on the disk device be<strong>for</strong>e returning<br />

from cifs$read or cifs$write requests on the file<br />

descriptor. Setting both <strong>CIFS</strong>-OFLAG-SYNC <strong>and</strong><br />

<strong>CIFS</strong>-OFLAG-DSYNC has the same effect as setting<br />

only <strong>CIFS</strong>-OFLAG-SYNC.<br />

<strong>CIFS</strong>-OFLAG-TRUNC This value truncates the file length to zero, leaving<br />

the file mode <strong>and</strong> file owner unchanged. This affects<br />

only a regular file opened with write-only or<br />

read/write access. A call to cifs$open with read-only<br />

access <strong>and</strong> <strong>CIFS</strong>-OFLAG-TRUNC set returns an error.<br />

The cifs-mode Argument<br />

The cifs-mode (use COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> this declaration) argument<br />

contains the following attributes <strong>for</strong> a newly created file (see Section 3 <strong>for</strong> a discussion<br />

of the attributes in the file mode):<br />

• File permission attributes<br />

The file permission attributes can be set into three different permission classes<br />

− Owner (<strong>CIFS</strong>-MODE-IRWXU)<br />

− Group (<strong>CIFS</strong>-MODE-IRWXG)<br />

− Other (<strong>CIFS</strong>-MODE-IRWXO)<br />

6–98 7859 6137–009


<strong>CIFS</strong>$OPEN<br />

These permission classes can be set using the permission attribute variables<br />

<strong>CIFS</strong>-MODE-IREAD, <strong>CIFS</strong>-MODE-IWRITE <strong>and</strong> <strong>CIFS</strong>-MODE-IEXEC. For example to<br />

set read <strong>and</strong> write permission to the owner class, use the following comm<strong>and</strong>:<br />

COMPUTE <strong>CIFS</strong>-MODE-IRWXU = <strong>CIFS</strong>-MODE-IREAD + <strong>CIFS</strong>-MODE-IWRITE.<br />

To set read permission to the group class, use the following comm<strong>and</strong>:<br />

COMPUTE <strong>CIFS</strong>-MODE-IRWXG = <strong>CIFS</strong>-MODE-IREAD.<br />

• File <strong>for</strong>mat attributes<br />

− Binary <strong>for</strong>mat: <strong>CIFS</strong>-MODE-1100BIN<br />

− System data <strong>for</strong>mat (SDF): <strong>CIFS</strong>-MODE-1100SDF<br />

7859 6137–009 6–99


<strong>CIFS</strong>$OPENDIR<br />

<strong>CIFS</strong>$OPENDIR<br />

Application<br />

Use the cifs$opendir service subprogram to open a directory stream, making it<br />

accessible to the calling process at the first directory entry. You must first open a<br />

directory stream be<strong>for</strong>e doing anything with it.<br />

See cifs$closedir <strong>for</strong> closing an open directory, cifs$readdir <strong>for</strong> reading the next directory<br />

entry, <strong>and</strong> cifs$rewinddir <strong>for</strong> repositioning the stream at its beginning.<br />

Synopsis<br />

CALL "cifs$opendir" USING dirname, cifs-dir, cifs-status.<br />

Description<br />

The cifs$opendir service subprogram opens a directory stream <strong>and</strong> positions the stream<br />

to the first directory entry, where dirname identifies the directory to open.<br />

dirname<br />

cifs-dir<br />

is a nul-terminated character string that contains the directory name to open.<br />

is a 2-word (S1(72) BINARY-1) data item into which the directory stream is returned.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-DIR <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$opendir service subprogram completes successfully, it returns an identifier <strong>for</strong><br />

the directory stream into the cifs-dir argument. Otherwise, cifs$opendir sets cifs-status<br />

to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$opendir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES One of the following errors occurred:<br />

• Search permission is denied <strong>for</strong> a component of the path name<br />

prefix of dirname.<br />

• Read permission is denied <strong>for</strong> the directory itself.<br />

6–100 7859 6137–009


<strong>CIFS</strong>-EFAULT dirname is not a valid name.<br />

<strong>CIFS</strong>-EIO An I/O error occurred on a directory in the path name.<br />

<strong>CIFS</strong>$OPENDIR<br />

<strong>CIFS</strong>-EMFILE The calling process would exceed the maximum number of file<br />

descriptors allowed.<br />

<strong>CIFS</strong>-ENOENT One of the following errors occurred:<br />

• The directory does not exist.<br />

• dirname is an empty string.<br />

<strong>CIFS</strong>-ENOMEM Memory could not be allocated <strong>for</strong> the cifs-dir object.<br />

<strong>CIFS</strong>-ENOTDIR A component of dirname is not a directory.<br />

7859 6137–009 6–101


<strong>CIFS</strong>$PACK<br />

<strong>CIFS</strong>$PACK<br />

Application<br />

Use the <strong>CIFS</strong>$PACK service subprogram to pack the underlying <strong>OS</strong> <strong>2200</strong> program files<br />

of <strong>CIFS</strong> directories.<br />

Synopsis<br />

CALL "<strong>CIFS</strong>$PACK" USING path, cifs-status.<br />

Description<br />

The <strong>CIFS</strong>$PACK service subprogram packs the underlying <strong>OS</strong> <strong>2200</strong> program file of a<br />

<strong>CIFS</strong> file or directory. This recovers unused table of contents (TOC) space <strong>and</strong> file text<br />

space resulting from the program file having deleted elements. The action is directly<br />

analogous to a FURPUR @PACK. Any existing relocatable <strong>and</strong> PROC entry point tables<br />

will be preserved.<br />

Notes:<br />

• The pack operation requires <strong>CIFS</strong> to have exclusive use (@ASG, AX) of a file while it<br />

is being packed. The program file must not be assigned to any run or name section,<br />

including the run doing the <strong>CIFS</strong>$PACK service subprogram call. (An EBUSY status is<br />

returned.)<br />

• Unlike the -pr option of the <strong>CIFS</strong>UT touch comm<strong>and</strong>, the <strong>CIFS</strong>$PACK routine does<br />

not have recursive capabilities. Only one program file can be packed <strong>for</strong> each call.<br />

The <strong>CIFS</strong> pack is a safe pack; if the system goes down or an X-keyin to the run is<br />

done during the pack, the contents of the program file are retained, except in<br />

extremely rare circumstances.<br />

path<br />

is a nul terminated ASCII character string <strong>for</strong> a <strong>CIFS</strong> file or directory whose<br />

underlying program file you wish to pack.<br />

cifs-status<br />

is a 1-word (1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

<strong>CIFS</strong>$PACK returns a zero value into the cifs-status parameter if any of the following<br />

conditions are true:<br />

• If it can pack the underlying program file.<br />

• If the file is already packed.<br />

• If it is not able to pack productively.<br />

• If there is no underlying program file.<br />

If there is an error, then cifs-status is set to an appropriate value. A text version of the<br />

status can be displayed by calling the <strong>CIFS</strong>$PERROR service subprogram, passing the<br />

status to it.<br />

6–102 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$PACK<br />

The following are the possible cifs-status values on an error return. These values are<br />

given in the <strong>CIFS</strong>-API COBOL PROC in element SYS$LIB$*<strong>CIFS</strong>$LIB.<strong>CIFS</strong>-DEF:<br />

<strong>CIFS</strong>-EACCES Access to a file or directory is denied.<br />

<strong>CIFS</strong>-EFAULT The path pointer caused a fault in <strong>CIFS</strong>, an<br />

IGDM.<br />

<strong>CIFS</strong>-ENAMETOOLONG The path name length is too long.<br />

<strong>CIFS</strong>-ENOENT The named file or directory does not exist or<br />

<strong>CIFS</strong> could not assign the program file.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path prefix is not a<br />

directory.<br />

<strong>CIFS</strong>-EPERM Access to a file or directory is denied.<br />

<strong>CIFS</strong>-EBUSY The program file is rolled-out or assigned to<br />

someone else <strong>CIFS</strong> requires exclusive access<br />

to the file.<br />

<strong>CIFS</strong>-ENONMEM Buffer space is unavailable.<br />

<strong>CIFS</strong>-EIO An IO error occurred on the backing program<br />

file.<br />

<strong>CIFS</strong>-E1100CORRUPT A basic error in the program file, such as text<br />

<strong>for</strong> elements being out of order.<br />

<strong>CIFS</strong>-E1100INTERNAL An internal error has occurred in <strong>CIFS</strong>.<br />

7859 6137–009 6–103


<strong>CIFS</strong>$PERROR<br />

<strong>CIFS</strong>$PERROR<br />

Application<br />

Use the cifs$perror service subprogram to print a message corresponding to an error<br />

that occurred.<br />

Synopsis<br />

CALL "cifs$perror" USING cifs-status [, msg-str].<br />

Description<br />

The cifs$perror service subprogram associates the error number in cifs-status with an<br />

error message <strong>and</strong> writes a line to the st<strong>and</strong>ard error file, where a line is the message<br />

followed by a newline (line feed) character.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

msg-str<br />

is a character string that can be used to add user in<strong>for</strong>mation to the error message.<br />

The argument msg-str is a character string specified to precede the message. If<br />

msg-str is present, cifs$perror writes the following sequence be<strong>for</strong>e writing the<br />

message:<br />

The string contained in msg-str<br />

A colon <strong>and</strong> a space<br />

The contents of the error message strings are the same as those returned by a call<br />

to cifs$strerror with the argument errnum set to the value in cifs-status.<br />

Return Values<br />

The cifs$perror service subprogram returns no value.<br />

6–104 7859 6137–009


<strong>CIFS</strong>$PIPE<br />

Application<br />

<strong>CIFS</strong>$PIPE<br />

Use the cifs$pipe service subprogram to create a pipe to transmit data between<br />

processes. Pipes are temporary entities that help processes communicate with each<br />

other. Pipes have a “read end” <strong>and</strong> a “write end,” which are located by file descriptors<br />

returned by cifs$pipe. When you use a pipe, one process writes data to it <strong>and</strong> another<br />

process reads the data on a first-in-first-out (FIFO) basis; or one process can pipe data to<br />

itself.<br />

The cifs$pipe service subprogram also initializes the <strong>CIFS</strong>-OFLAG-NONBLOCK flags as<br />

clear; (see the cifs$open service subprogram) <strong>for</strong> both file descriptors. You can set these<br />

flags with the cifs$fcntl service subprogram (see the cifs$fcntl service subprogram). See<br />

“Redirecting St<strong>and</strong>ard Files to Pipes” <strong>for</strong> in<strong>for</strong>mation on using pipes.<br />

Synopsis<br />

CALL "cifs$pipe" USING fd-pair, cifs-status.<br />

Description<br />

The cifs$pipe service subprogram creates a pipe <strong>and</strong> returns its file descriptors in the fdpair<br />

group item where:<br />

fd-pair<br />

is a 2-group data item defined as follows:<br />

01 fd-pair<br />

02 fildes0 pic S1(36) BINARY-1.<br />

02 fildes1 pic S1(36) BINARY-1.<br />

where<br />

fildes0 is the file descriptor <strong>for</strong> the read end of the pipe.<br />

fildes1 is the file descriptor <strong>for</strong> the write end of the pipe.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

7859 6137–009 6–105


<strong>CIFS</strong>$PIPE<br />

Return Values<br />

If the cifs$pipe service subprogram completes successfully, it does the following:<br />

• Initializes the last accessed time, created time, <strong>and</strong> last modified time fields of the<br />

pipe<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$pipe sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$pipe service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EMFILE The calling process would exceed the maximum number of<br />

file descriptors allowed.<br />

Redirecting St<strong>and</strong>ard Files to Pipes<br />

Using St<strong>and</strong>ard Files<br />

To agree on the file descriptors <strong>for</strong> a pipe, programs follow the convention of using the C<br />

st<strong>and</strong>ard files to correspond to the pipe's file descriptors, as follows:<br />

C St<strong>and</strong>ard File<br />

COBOL Program<br />

Name<br />

St<strong>and</strong>ard input file (stdin) <strong>CIFS</strong>-STDIN-FD 0<br />

St<strong>and</strong>ard output file<br />

(stdout)<br />

<strong>CIFS</strong>-STDOUT-FD 1<br />

St<strong>and</strong>ard error file (stderr) <strong>CIFS</strong>-STDERR-FD 2<br />

Redirecting St<strong>and</strong>ard Files<br />

File<br />

Descriptor<br />

In your program, you can redirect the st<strong>and</strong>ard files to one end of a pipe. For example, to<br />

redirect <strong>CIFS</strong>-STDOUT-FD to the write end of a pipe, do the following procedure:<br />

1. Close <strong>CIFS</strong>-STDOUT-FD, making its file descriptor available <strong>for</strong> reuse.<br />

2. Duplicate the write end of the pipe. The kernel always chooses the lowest available<br />

number <strong>for</strong> a new file descriptor, which is the one previously assigned to<br />

<strong>CIFS</strong>-STDOUT-FD.<br />

3. Close the original write end of the pipe, leaving <strong>CIFS</strong>-STDOUT-FD as the write end.<br />

6–106 7859 6137–009


<strong>CIFS</strong>$PRINTF<br />

Application<br />

<strong>CIFS</strong>$PRINTF<br />

Use the cifs$printf service subprogram to write <strong>for</strong>matted output to the st<strong>and</strong>ard output.<br />

Synopsis<br />

CALL "cifs$printf" USING chars-out, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$printf service subprogram is equivalent to calling cifs$fprintf using <strong>CIFS</strong>-<br />

STDOUT-FILE as the file, as follows:<br />

call "cifs$fprintf" using chars-out, cifs-stdout-file, <strong>for</strong>mat, ... .<br />

chars-out<br />

<strong>for</strong>mat<br />

item<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of bytes written<br />

out.<br />

is an alphanumeric data item that controls the output by specifying how subsequent<br />

arguments are converted be<strong>for</strong>e being output. See cifs$fprintf <strong>for</strong> a description of<br />

the <strong>for</strong>mat argument.<br />

is an alphanumeric data item that contains the data to be printed.<br />

Return Values<br />

If it completes successfully, the cifs$printf service subprogram returns the number of<br />

characters transmitted in the chars-out parameter. Otherwise, cifs$printf returns a<br />

negative value in the chars-out parameter.<br />

7859 6137–009 6–107


<strong>CIFS</strong>$PUTC<br />

<strong>CIFS</strong>$PUTC<br />

Application<br />

Use the cifs$putc service subprogram to write characters to an output stream.<br />

Synopsis<br />

CALL "cifs$putc" USING char, cifs-file, cifs-status.<br />

Description<br />

The cifs$putc service subprogram is equivalent to cifs$fputc.<br />

char<br />

cifs-file<br />

is a 1-byte field used to hold the character to be placed into the output stream.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$putc service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$putc sets cifs-status to identify the specific error that was encountered.<br />

6–108 7859 6137–009


<strong>CIFS</strong>$PUTCHAR<br />

Application<br />

<strong>CIFS</strong>$PUTCHAR<br />

Use the cifs$putchar service subprogram to write a character to st<strong>and</strong>ard output.<br />

Synopsis<br />

CALL "cifs$putchar" USING char, cifs-status.<br />

Description<br />

The cifs$putchar service subprogram is equivalent to calling cifs$putc with the second<br />

argument (cifs-file) set to st<strong>and</strong>ard output.<br />

char<br />

is a 1-byte field used to hold the character to be placed into the st<strong>and</strong>ard output<br />

stream.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$putchar service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$putchar sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–109


<strong>CIFS</strong>$PUTS<br />

<strong>CIFS</strong>$PUTS<br />

Application<br />

Use the cifs$puts service subprogram to write a string of characters to st<strong>and</strong>ard output.<br />

Synopsis<br />

CALL "cifs$puts" USING string, cifs-status.<br />

Description<br />

The cifs$puts service subprogram writes the string contained in the string argument to<br />

the st<strong>and</strong>ard output stream, appending a newline (line feed) character to the output. The<br />

nul character terminating the string is not written.<br />

string<br />

is an alphanumeric data item that contains the characters to be placed into the<br />

st<strong>and</strong>ard output stream.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$puts service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$puts sets cifs-status to identify the specific error that was encountered.<br />

6–110 7859 6137–009


<strong>CIFS</strong>$READ<br />

Application<br />

<strong>CIFS</strong>$READ<br />

Use the cifs$read service subprogram to read data from a file at the current read/write<br />

position. Use the cifs$lseek service subprogram to reposition the read/write offset, if<br />

necessary. See the following subsections <strong>for</strong> more in<strong>for</strong>mation: “Determining the<br />

Number of Bytes Read,” “Starting Position <strong>for</strong> Different File Types,” <strong>and</strong> “Reading<br />

Different File Types.”<br />

Synopsis<br />

CALL "cifs$read" USING fildes, buf, bytes-to-read, bytes-read, cifs-status.<br />

Description<br />

The cif$read service subprogram reads data from a file into a buffer, where:<br />

fildes<br />

buf<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be read.<br />

is an alphanumeric data item that receives the data as it is read.<br />

bytes-to-read<br />

is a 1-word ( 1(36) BINARY-1 ) data item that is the number of bytes to be read,<br />

which is limited by the size of a data bank.<br />

bytes-read<br />

is a 1-word ( 1(36) BINARY-1 ) data item that is set to the actual number of bytes<br />

read.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$read service subprogram completes successfully, it does the following:<br />

• Updates the last accessed time field of the file (see the cifs$fstat <strong>and</strong> cifs$stat<br />

service subprograms), if it reads any bytes<br />

• Increments the read/write offset by the number of bytes actually read<br />

7859 6137–009 6–111


<strong>CIFS</strong>$READ<br />

• Returns the number of bytes actually read <strong>and</strong> placed into the buffer into the bytesread<br />

parameter<br />

• Return 0 in cifs-status<br />

Otherwise, cifs$read sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$read service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EAGAIN The file descriptor's <strong>CIFS</strong>-OFLAG-NONBLOCK flag is set <strong>and</strong> no data is<br />

available.<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor open <strong>for</strong> reading.<br />

<strong>CIFS</strong>-EFAULT One of the following errors occurred:<br />

• buf is invalid, <strong>and</strong> bytes-to-read is greater than 0.<br />

• buf is valid, but (buf + (bytes-to-read - 1)) points to an invalid<br />

address.<br />

<strong>CIFS</strong>-EIO An I/O error occurred during processing of the request.<br />

Determining the Number of Bytes Read<br />

The cifs$read service subprogram returns the number of bytes actually read <strong>and</strong> stored<br />

in the buffer (bytes-read), which is never greater than bytes-to-read. The following<br />

paragraphs relate this return value to the input value of bytes-to-read.<br />

bytes-read = bytes-to-read<br />

The cifs$read service subprogram read <strong>and</strong> stored the exact number of bytes requested.<br />

bytes-read < bytes-to-read<br />

The value returned is less than bytes-to-read if one of the following statements is true:<br />

• Fewer than bytes-to-read bytes remain between the read/write offset <strong>and</strong> the end of<br />

the file.<br />

• The file is a pipe or FIFO that has fewer than bytes-to-read bytes immediately<br />

available <strong>for</strong> reading.<br />

bytes-read = 0<br />

The value returned is 0 if one of the following statements is true:<br />

• The value of bytes-to-read is 0; the service subprogram has no other effects.<br />

• The value of bytes-to-read is not 0, but the read/write offset is at the end of file<br />

(EOF).<br />

6–112 7859 6137–009


Starting Position <strong>for</strong> Different File Types<br />

<strong>CIFS</strong>$READ<br />

The file type determines which byte in the file is the first to be read, as shown in the<br />

following paragraphs.<br />

Regular Files<br />

The cifs$read service subprogram starts at the position given by the read/write offset<br />

associated with the open file description corresponding to fildes. Be<strong>for</strong>e returning,<br />

cifs$read increases the read/write offset by the number of bytes read.<br />

Pipes <strong>and</strong> FIFO Files<br />

The cifs$read service subprogram starts at the current position associated with the file<br />

corresponding to fildes. The value of the read/write offset has no meaning <strong>for</strong> these file<br />

types.<br />

If the starting position is at or beyond the current end of file (EOF), the service<br />

subprogram returns 0 <strong>and</strong> stores nothing into the buffer. Subsequent read operations<br />

attempt to read from the device again, unless EOF is a hard EOF mark on st<strong>and</strong>ard input.<br />

In this case, all subsequent read operations return 0 <strong>and</strong> store no data into the buffer.<br />

Reading Different File Types<br />

The file type determines the behavior of the cifs$read service subprogram, as shown in<br />

the following paragraphs.<br />

Empty Pipe or FIFO File<br />

The cifs$read service subprogram per<strong>for</strong>ms as follows:<br />

• If no process has the pipe or FIFO file open <strong>for</strong> writing, cifs$read returns 0 to<br />

indicate the end of the file.<br />

• If some process has the pipe or FIFO file open <strong>for</strong> writing <strong>and</strong> the<br />

<strong>CIFS</strong>-OFLAG-NONBLOCK flag <strong>for</strong> the open file description corresponding to fildes is<br />

set (see the cifs$open <strong>and</strong> cifs$fcntl service subprograms), cifs$read returns <strong>and</strong><br />

sets cifs-status to the value of <strong>CIFS</strong>-EAGAIN.<br />

• If some process has the pipe or FIFO file open <strong>for</strong> writing <strong>and</strong> the<br />

<strong>CIFS</strong>-OFLAG-NONBLOCK flag is clear, cifs$read waits until some data is written or<br />

the pipe or FIFO file is closed by all processes that have the pipe or FIFO file open<br />

<strong>for</strong> writing.<br />

<strong>CIFS</strong>-MODE-1100BIN File Created Outside of <strong>CIFS</strong><br />

These files can contain areas of unwritten data that are indistinguishable from valid data.<br />

Reading these areas results in bytes with indeterminate values. A process must never<br />

assume these areas are zero-filled.<br />

7859 6137–009 6–113


<strong>CIFS</strong>$READ<br />

<strong>CIFS</strong>-MODE-1100SDF File<br />

The cifs$read service subprogram per<strong>for</strong>ms as follows:<br />

• Translates Fieldata images to ASCII<br />

• Removes all SDF attributes from the text returned, so the process cannot use this<br />

attribute to read SDF line numbers<br />

6–114 7859 6137–009


<strong>CIFS</strong>$READDIR<br />

Application<br />

<strong>CIFS</strong>$READDIR<br />

Use the cifs$readdir service subprogram to read the current entry in a directory stream<br />

(that is, the entry at the current position); cifs$readdir then positions the directory stream<br />

at the next entry. Be<strong>for</strong>e reading a directory stream, you must open it.<br />

You can distinguish the end of the directory from error cases; see “Finding the End of<br />

the Directory” in this subsection.<br />

See cifs$opendir <strong>for</strong> opening a directory stream, cifs$closedir <strong>for</strong> closing an open<br />

directory, <strong>and</strong> cifs$rewinddir <strong>for</strong> repositioning a directory stream at its beginning.<br />

Synopsis<br />

CALL "cifs$readdir" USING cifs-dir, entry-ino, entry-name, max-len,<br />

true-len, cifs-status.<br />

Description<br />

The cifs$readdir service subprogram reads the next entry in a directory stream, where<br />

cifs-dir is a directory stream from which to read the directory entry. The directory stream<br />

must have been opened previously by cifs$opendir.<br />

cifs-dir<br />

is a 2-word (S1(72) BINARY-1) data item which contains the directory stream from<br />

which to read. Use the COBOL COPY PROC <strong>CIFS</strong>-DIR <strong>for</strong> the declaration of this<br />

variable.<br />

entry-ino<br />

is a 1-word ( S1(36) BINARY-1 ) data item that corresponds to a valid file serial<br />

number.<br />

entry-name<br />

max-len<br />

is an alphanumeric data item into which the directory name is placed.<br />

is 1-word ( 1(36) BINARY-1 ) data item that contains the maximum length of the<br />

entry name.<br />

true-len<br />

is 1-word ( 1(36) BINARY-1 ) data item that contains the actual length of the entry<br />

name.<br />

7859 6137–009 6–115


<strong>CIFS</strong>$READDIR<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Calling cifs$readdir Repeatedly<br />

If a process opens a directory <strong>and</strong> then repeatedly calls cifs$readdir on the directory<br />

stream, cifs$readdir returns one entry <strong>for</strong> each file continuously in the directory from the<br />

time of the cifs$opendir call. This includes one entry <strong>for</strong> the dot file (entry-name is “ . “)<br />

<strong>and</strong> one entry <strong>for</strong> the dot-dot file (entry-name is “ .. “).<br />

Every time cifs$readdir reads the same directory stream; it overwrites the previous<br />

directory entry returned.<br />

Multiple Directory Streams<br />

Per<strong>for</strong>ming cifs$readdir on one directory stream never interferes with entries in other<br />

directory streams.<br />

Finding the End of the Directory<br />

Use the following procedure to distinguish the end of the directory from error cases:<br />

1. Set cifs-status to 0.<br />

2. Call cifs$readdir.<br />

3. Check the value of cifs-status if cifs$readdir returns a true-len less than or equal to 0.<br />

• If cifs-status equals 0, cifs$readdir reached the end of the directory.<br />

• If cifs-status does not equal 0, cifs$readdir returned an error.<br />

Return Values<br />

If the cifs$readdir service subprogram completes successfully, it does the following:<br />

• Updates the last accessed time field of the directory each time the directory is<br />

actually read. The service subprogram can store several entries <strong>for</strong> one call in the<br />

buffer <strong>and</strong> not do actual read operations <strong>for</strong> other calls. The update to last accessed<br />

time field is not written to nonvolatile storage until the directory stream is closed by<br />

one of the following events:<br />

− A call to cifs$closedir<br />

− Process termination<br />

• Returns one of the following:<br />

− The name of a directory entry<br />

− A true-len less than or equal to 0, if no more entries exist. In this case,<br />

cifs$readdir does not change the value of cifs-status.<br />

Otherwise, cifs$readdir sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–116 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$READDIR<br />

If any of the following conditions occurs, the cifs$readdir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF cifs-dir does not contain a valid directory stream.<br />

<strong>CIFS</strong>-EFAULT cifs-dir is not valid.<br />

7859 6137–009 6–117


<strong>CIFS</strong>$REMOVE<br />

<strong>CIFS</strong>$REMOVE<br />

Application<br />

Use the cifs$remove service subprogram to remove any type of named file, including an<br />

empty directory.<br />

Synopsis<br />

CALL "cifs$remove" USING path, cifs-status.<br />

Description<br />

The cifs$remove service subprogram causes a file or directory to be removed, where<br />

path contains the name of the file or directory. If the file is open, any subsequent input or<br />

output operations to the file do not fail. Subsequent attempts to open the file fail unless<br />

the file is re-created.<br />

path<br />

is a nul-terminated character string that contains the path name of the file or<br />

directory to remove.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$remove service subprogram completes successfully, it returns a value of 0 in<br />

the cifs-status parameter. Otherwise, cifs$remove sets cifs-status to identify the specific<br />

error that was encountered.<br />

6–118 7859 6137–009


<strong>CIFS</strong>$RENAME<br />

Application<br />

<strong>CIFS</strong>$RENAME<br />

Use the cifs$rename service subprogram to change the path name of an existing file.<br />

The new entry can be in the same directory or in different directories. If it is in the same<br />

directory, the file name must be unique.<br />

If the new path name also resolves to an existing file, the link to that file is removed<br />

be<strong>for</strong>e the name is reused; this possibly removes the unlinked file from the file system<br />

(see “General Rules <strong>for</strong> Renaming Files” in this subsection).<br />

See the cifs$link service subprogram <strong>for</strong> creating new directory entries <strong>for</strong> a file <strong>and</strong> the<br />

cifs$unlink service subprogram <strong>for</strong> removing file links.<br />

Synopsis<br />

CALL "cifs$rename" USING old-path, new-path, cifs-status.<br />

Description<br />

The cifs$rename service subprogram changes the path name of an existing file, where:<br />

old-path<br />

is an alphanumeric variable that contains the name of the file to rename.<br />

new-path<br />

is an alphanumeric variable that contains the new path name to attach to the file.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Neither old-path nor new-path can refer to a character file.<br />

Example 1<br />

The following example illustrates a simple rename operation within a directory:<br />

7859 6137–009 6–119


<strong>CIFS</strong>$RENAME<br />

Example 2<br />

The following diagram illustrates a simple rename operation between two directories:<br />

Example 3<br />

The following diagram illustrates a complex rename operation, where the new path<br />

name resolves to an existing file. The existing link to /dir_2/file_2 is removed first; then<br />

the rename operation is similar to example 2, with a different file name.<br />

6–120 7859 6137–009


General Rules <strong>for</strong> Renaming Files<br />

The following general rules apply to renaming files:<br />

• If the old <strong>and</strong> new path names resolve to the same file, cifs$rename returns<br />

successfully without making any changes.<br />

<strong>CIFS</strong>$RENAME<br />

• If the old <strong>and</strong> new path names do not resolve to the same file, the following rules<br />

apply:<br />

− The process must have write-access permission to the directory containing the<br />

link to the old file.<br />

− The process must have write-access permission to the directory that contains<br />

the new link.<br />

• If the new path name resolves to an existing file, the file is unlinked from the last<br />

directory in the new path name be<strong>for</strong>e its name is reused <strong>for</strong> old-path. If no other<br />

links to the file exist, the file is removed from the file hierarchy as soon as all<br />

references to it are closed (see the cifs$close service subprogram). The dot <strong>and</strong><br />

dot-dot entries cannot be manipulated by the cifs$rename <strong>and</strong> cifs$rmdir service<br />

subprograms. These entries are automatically deleted from a directory when its last<br />

link is removed.<br />

Special Rules <strong>for</strong> Renaming a Directory<br />

The following special rules apply to renaming a directory:<br />

• The process must have write-access permission to the old directory.<br />

• If the new path name exists in the file system, it must resolve to a directory.<br />

• If the new path name resolves to an existing directory, the process must have writeaccess<br />

permission to it <strong>and</strong> it must be empty.<br />

• The old path name must not resolve to a directory contained in the new path name.<br />

Special Rules <strong>for</strong> Renaming a Nondirectory File<br />

The new path name must not resolve to an existing directory.<br />

Return Values<br />

If the cifs$rename service subprogram completes successfully, it does the following:<br />

• Updates the last accessed time <strong>and</strong> last modified fields of the parent directory of<br />

each file<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$rename sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–121


<strong>CIFS</strong>$RENAME<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$rename service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a<br />

component of either path name.<br />

• The calling process is denied write permission to directories<br />

containing either old-path or new-path.<br />

• The calling process is denied write permission to directories<br />

to which either old -path or new-path point.<br />

<strong>CIFS</strong>-EEXIST The link named by new-path is a directory with entries other than<br />

dot <strong>and</strong> dot-dot; that is, it is not an empty directory.<br />

<strong>CIFS</strong>-EFAULT The value specified by old-path or new-path is invalid.<br />

<strong>CIFS</strong>-EINVAL One of the following errors occurred:<br />

• The directory path name in new-path contains the directory<br />

name in old-path.<br />

• The last component of either old-path or new-path is either<br />

dot or dot-dot.<br />

<strong>CIFS</strong>-EISDIR The path name in new-path resolves to a directory, <strong>and</strong> the path<br />

name in old-path resolves to a file that is not a directory.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The link named by old-path does not exist.<br />

• Either old-path or new-path points to an empty string.<br />

<strong>CIFS</strong>-EN<strong>OS</strong>PC The parent directory of new-path has too many entries.<br />

<strong>CIFS</strong>-ENOTDIR Either of the following errors occurred:<br />

• A component of either path name prefix is not a directory.<br />

• old-path names a directory, <strong>and</strong> new-path names a file that is<br />

not a directory.<br />

6–122 7859 6137–009


<strong>CIFS</strong>$REWIND<br />

Application<br />

<strong>CIFS</strong>$REWIND<br />

Use the cifs$rewind service subprogram to set the file position indicator to the beginning<br />

of a stream.<br />

Synopsis<br />

CALL "cifs$rewind" cifs-file, cifs-status.<br />

Description<br />

The cifs$rewind service subprogram is equivalent to the following call to cifs$fseek:<br />

call "cifs$fseek" using cifs-file, 0, 0, cifs-status.<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$rewind service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$rewind sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–123


<strong>CIFS</strong>$REWINDDIR<br />

<strong>CIFS</strong>$REWINDDIR<br />

Application<br />

Use the cifs$rewinddir service subprogram to reposition a directory stream at its<br />

beginning. The cifs$rewinddir service subprogram updates the directory stream to<br />

reflect the current state of the directory, making visible any directory entries added since<br />

the directory stream was opened.<br />

You can distinguish a successful call to cifs$rewinddir from error cases; see “Detecting<br />

Error Cases” in this subsection.<br />

See cifs$opendir <strong>for</strong> opening a directory, cifs$closedir <strong>for</strong> closing an open directory, <strong>and</strong><br />

cifs$readdir <strong>for</strong> reading the next directory entry.<br />

Synopsis<br />

CALL "cifs$rewinddir" USING cifs-dir, cifs-status.<br />

Description<br />

The cifs$rewinddir service subprogram resets the position of the directory stream to its<br />

beginning, where cifs-dir is the directory stream to rewind. The directory stream must<br />

have been opened previously by cifs$opendir.<br />

cifs-dir<br />

is a 2-word (S1(72) BINARY-1) data item into which the directory stream is returned.<br />

Use the COBOL COPY PROC <strong>CIFS</strong>-DIR <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Detecting Error Cases<br />

Use the following procedure to detect error cases:<br />

1. Set cifs-status to 0.<br />

2. Call cifs$rewinddir.<br />

3. Check the value of cifs-status.<br />

• If cifs-status equals 0, cifs$rewinddir did not detect an error.<br />

• If cifs-status does not equal 0, cifs$rewinddir detected an error.<br />

Return Values<br />

The cifs$rewinddir service subprogram returns no value.<br />

6–124 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$REWINDDIR<br />

If any of the following conditions occurs, the cifs$rewinddir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EBADF cifs-dir does not contain a valid directory object representing<br />

an open directory stream.<br />

<strong>CIFS</strong>-EFAULT cifs-dir is not a valid value.<br />

7859 6137–009 6–125


<strong>CIFS</strong>$RMDIR<br />

<strong>CIFS</strong>$RMDIR<br />

Application<br />

Use the cifs$rmdir service subprogram to remove an empty directory from the file<br />

system.<br />

Synopsis<br />

CALL "cifs$rmdir" USING path, cifs-status.<br />

Description<br />

The cifs$rmdir service subprogram removes an empty directory <strong>and</strong> its dot <strong>and</strong> dot-dot<br />

entries, where path contains the value of the directory to remove. The directory cannot<br />

be the system root directory.<br />

If any process has the directory open or has an open directory stream (see the<br />

cifs$opendir service subprogram) when cifs$rmdir removes the last link, the directory<br />

contents remain accessible until all references are closed.<br />

path<br />

is a nul-terminated character string that contains the path name of the directory to be<br />

removed.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$rmdir service subprogram completes successfully, it does the following:<br />

• Updates the last accessed <strong>and</strong> last modified fields of the parent directory<br />

• Returns 0 in the cifs-status field<br />

Otherwise, cifs$rmdir sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$rmdir service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a<br />

component of the path name.<br />

• The calling process is denied write permission to the parent<br />

directory of the directory to be removed.<br />

6–126 7859 6137–009


<strong>CIFS</strong>-EEXIST path names a directory that is not empty.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>$RMDIR<br />

<strong>CIFS</strong>-EINVAL The calling process is requesting that the dot or dot-dot entry in a<br />

directory be removed.<br />

<strong>CIFS</strong>-EIO An I/O error prevented the completion of the service subprogram.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The directory does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name is not a directory.<br />

7859 6137–009 6–127


<strong>CIFS</strong>$SCANF<br />

<strong>CIFS</strong>$SCANF<br />

Application<br />

Use the cifs$scanf service subprogram to read <strong>for</strong>matted input from the st<strong>and</strong>ard input.<br />

Synopsis<br />

CALL "cifs$scanf" USING items-scanned, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$scanf service subprogram is equivalent to calling cifs$fscanf using <strong>CIFS</strong>-STDIN-<br />

FILE as the file, as follows:<br />

call "cifs$fscanf" using items-scanned, cifs-stdin-file, <strong>for</strong>mat, ... .<br />

items-scanned<br />

<strong>for</strong>mat<br />

item<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of assigned input<br />

items.<br />

See cifs$fscanf <strong>for</strong> a description of the <strong>for</strong>mat argument.<br />

is an alphanumeric data item that contains the data to be scanned.<br />

Return Values<br />

If it completes successfully, the cifs$scanf service subprogram returns either of the<br />

following:<br />

• The number of assigned input items, which can be 0 in the event of an early conflict<br />

between an input character <strong>and</strong> the <strong>for</strong>mat<br />

• EOF, if it encounters end of file be<strong>for</strong>e the first conflict or conversion<br />

Otherwise, cifs$scanf returns when it encounters the end of the <strong>for</strong>mat string.<br />

6–128 7859 6137–009


<strong>CIFS</strong>$SHARE<br />

Application<br />

<strong>CIFS</strong>$SHARE<br />

Use the cifs$share service subprogram to specify the network-visible name <strong>for</strong> the given<br />

directory. The share name cannot be more than 31 characters long.<br />

Notes:<br />

• There is no P<strong>OS</strong>IX equivalent to cifs$share.<br />

• Many network clients cannot access share names with more than 12 characters.<br />

Synopsis<br />

CALL "cifs$share" USING path, sharename, cifs-status.<br />

Description<br />

The path parameter must specify a directory to which the caller has full access. The<br />

sharename parameter must be a string of 31 or fewer characters from the printable<br />

ASCII set, not including the slash (/), back slash (\), question mark (?), asterisk (*), or<br />

comma (,) characters. If the sharename is an empty string, the call removes network<br />

visibility <strong>for</strong> the directory. If the sharename string contains invalid characters, the<br />

network visibility <strong>for</strong> the directory is unchanged. Otherwise, the sharename becomes the<br />

network name <strong>for</strong> the directory, replacing any existing name.<br />

path<br />

is a nul-terminated character string that contains the path name of the file.<br />

sharename<br />

is a nul-terminated character string that contains the share name to be established<br />

<strong>for</strong> the file.<br />

cifs-status<br />

is a 1-word (1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$share service subprogram completes successfully, it returns a value of 0 in<br />

the cifs-status parameter. Otherwise, cifs$share sets cifs-status to identify the specific<br />

error that was encountered.<br />

7859 6137–009 6–129


<strong>CIFS</strong>$SPRINTF<br />

<strong>CIFS</strong>$SPRINTF<br />

Application<br />

Use the cifs$sprintf service subprogram to write <strong>for</strong>matted output to a character array.<br />

Synopsis<br />

CALL "cifs$sprintf" USING chars-out, dest-string, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$sprintf service subprogram is equivalent to cifs$fprintf, except that the<br />

argument dest-string specifies an alphanumeric data item to which the generated output<br />

is written (rather than to a stream). A nul character is appended after the characters are<br />

written, but the nul character is not counted as part of the returned sum.<br />

chars-out<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of bytes written<br />

out.<br />

dest-string<br />

<strong>for</strong>mat<br />

item<br />

is an alphanumeric data item to which the output is written.<br />

is an alphanumeric data item that controls the output by specifying how subsequent<br />

arguments are converted be<strong>for</strong>e they are output. See the cifs$fprintf <strong>for</strong> further<br />

details about this parameter.<br />

is an alphanumeric data item that contains the data to be printed.<br />

Return Values<br />

The cifs$sprintf service subprogram returns the number of characters written to the<br />

destination string, not counting the terminating nul character.<br />

6–130 7859 6137–009


<strong>CIFS</strong>$SSCANF<br />

Application<br />

Use the cifs$sscanf service subprogram to read <strong>for</strong>matted input from a string.<br />

Synopsis<br />

<strong>CIFS</strong>$SSCANF<br />

CALL "cifs$sscanf" USING items-scanned, scan-string, <strong>for</strong>mat, [item...].<br />

Description<br />

The cifs$sscanf service subprogram is equivalent to cifs$fscanf, except that the<br />

argument scan-string specifies a string from which the input is read (rather than from a<br />

stream). Reaching the end of the string is equivalent to encountering end of file <strong>for</strong> the<br />

cifs$fscanf service subprogram.<br />

items-scanned<br />

is a 1-word ( S1(36) BINARY-1 ) data item that contains the number of assigned input<br />

items.<br />

scan-string<br />

<strong>for</strong>mat<br />

item<br />

is an alphanumeric data item from which the input is read.<br />

controls the input by specifying how input text is converted <strong>for</strong> assignment.<br />

Subsequent arguments are objects that receive the converted input. If there are<br />

insufficient arguments <strong>for</strong> the <strong>for</strong>mat, a signal is generated. If the program recovers<br />

from the signal, it treats it as if an asterisk flag were specified. If the <strong>for</strong>mat is<br />

exhausted while arguments remain, cifs$fscanf evaluates the excess arguments but<br />

otherwise ignores them.<br />

is an alphanumeric data item that contains the data to be scanned.<br />

Return Values<br />

If it completes successfully, the cifs$sscanf service subprogram returns the number of<br />

assigned input items (which can be 0 in the event of an early conflict between an input<br />

character <strong>and</strong> the <strong>for</strong>mat) into the items-scanned argument. Otherwise, cifs$sscanf<br />

returns when it encounters the end of the <strong>for</strong>mat string.<br />

7859 6137–009 6–131


<strong>CIFS</strong>$STAT<br />

<strong>CIFS</strong>$STAT<br />

Application<br />

Use the cifs$stat service subprogram to retrieve in<strong>for</strong>mation about a named file. In<br />

particular, you can get in<strong>for</strong>mation about the file mode, security attributes, file size, <strong>and</strong><br />

access times.<br />

The cifs$stat service subprogram uses a path name to identify the file. See the cifs$fstat<br />

service subprogram <strong>for</strong> a similar service subprogram that uses a file descriptor.<br />

Synopsis<br />

CALL "cifs$stat" USING path, cifs-stat, cifs-status.<br />

Description<br />

The cifs$stat service subprogram returns in<strong>for</strong>mation about a file into the cifs-stat<br />

structure, where:<br />

path<br />

cifs-stat<br />

is a nul-terminated character string that contains the path name of the file.<br />

is a group item in which cifs$fstat returns the file in<strong>for</strong>mation. Use the COBOL<br />

COPY PROC <strong>CIFS</strong>-STAT <strong>for</strong> the declaration of this variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The calling process does not need read, write, or execute permission <strong>for</strong> the file; but it<br />

must have search permission <strong>for</strong> all directories in the path name leading to the file.<br />

Refer to the cifs$fstat service subprogram <strong>for</strong> a table that describes the cifs-stat<br />

structure.<br />

Return Values<br />

If the cifs$stat service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$stat sets cifs-status to identify the specific error that was encountered.<br />

6–132 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$STAT<br />

If any of the following conditions occurs, the cifs$stat service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EACCES The calling process is denied search permission to a directory in<br />

the path name.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The file or directory does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name prefix is not a directory.<br />

7859 6137–009 6–133


<strong>CIFS</strong>$STDERR<br />

<strong>CIFS</strong>$STDERR<br />

Application<br />

Use the cifs$stderr service subprogram to set the opaque data item that describes an<br />

open instance of the st<strong>and</strong>ard error file.<br />

Synopsis<br />

CALL "cifs$stderr" USING cifs-file.<br />

Description<br />

The cifs$stderr service subprogram sets the argument cifs-file to an open instance of the<br />

st<strong>and</strong>ard error file.<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

Return Values<br />

The value of the parameter cifs-file is set to a value that describes an open instance of a<br />

file.<br />

6–134 7859 6137–009


<strong>CIFS</strong>$STDIN<br />

Application<br />

<strong>CIFS</strong>$STDIN<br />

Use the cifs$stdin service subprogram to set the opaque data item that describes an<br />

open instance of the st<strong>and</strong>ard input file.<br />

Synopsis<br />

CALL "cifs$stdin" USING cifs-file.<br />

Description<br />

The cifs$stdin service subprogram sets the argument cifs-file to an open instance of the<br />

st<strong>and</strong>ard input file.<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

The value of the parameter cifs-file is set to a value that describes an open instance of a<br />

file.<br />

7859 6137–009 6–135


<strong>CIFS</strong>$STDOUT<br />

<strong>CIFS</strong>$STDOUT<br />

Application<br />

Use the cifs$stdout service subprogram to set the opaque data item that describes an<br />

open instance of the st<strong>and</strong>ard output file.<br />

Synopsis<br />

CALL "cifs$stdout" USING cifs-file.<br />

Description<br />

The cifs$stdout service subprogram sets the argument cifs-file to an open instance of<br />

the st<strong>and</strong>ard output file.<br />

cifs-file<br />

is an opaque data item that describes an open instance of a file. It is a 2-word<br />

(S1(72) BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

The value of the parameter cifs-file is set to a value that describes an open instance of a<br />

file.<br />

6–136 7859 6137–009


<strong>CIFS</strong>$STRERROR<br />

Application<br />

<strong>CIFS</strong>$STRERROR<br />

Use the cifs$strerror service subprogram to retrieve the error message associated with a<br />

particular error number.<br />

Synopsis<br />

CALL "cifs$strerror" USING errnum, message-string [insert-string...].<br />

Description<br />

The cifs$strerror service subprogram retrieves the ELMS text <strong>for</strong> the specified error<br />

number, errnum, using first the <strong>CIFS</strong> component, <strong>and</strong> then the URTS component if the<br />

message does not exist within <strong>CIFS</strong>. The optional parameters (insert-string) are character<br />

strings that are used as inserts in the error message text.<br />

errnum<br />

is a 1-word ( 9(10) BINARY ) data item that contains the error number of the<br />

message to be retrieved.<br />

message-string<br />

is an alphanumeric character data item into which the retrieved error message can<br />

be returned.<br />

insert-string<br />

is an alphanumeric character data item that contains text to be used as an insert in<br />

the error message.<br />

Return Values<br />

The cifs$strerror service subprogram returns a retrieved message text with any inserts<br />

applied to the message-string parameter. This area is modifiable by the caller <strong>and</strong> is<br />

overwritten on subsequent calls to cifs$strerror.<br />

7859 6137–009 6–137


<strong>CIFS</strong>$TMPFILE<br />

<strong>CIFS</strong>$TMPFILE<br />

Application<br />

Use the cifs$tmpfile service subprogram to create a temporary file <strong>for</strong> use while a<br />

program executes.<br />

Synopsis<br />

CALL "cifs$tmpfile" USING cifs-file, cifs-status.<br />

Description<br />

The cifs$tmpfile service subprogram creates a temporary file, where cifs-file is an<br />

opaque data item that describes an open instance of a file. The file is opened <strong>for</strong> update<br />

<strong>and</strong> automatically removed at program termination.<br />

cifs-file<br />

is a 2-word (S1(72) BINARY-1) data item into which the value of the open instance of<br />

the file is stored. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of this<br />

variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Default Permissions When Creating a File<br />

If the cifs$tmpfile service subprogram creates a file, it assigns read <strong>and</strong> write<br />

permissions to the owner, group, <strong>and</strong> other permission classes by default.<br />

Return Values<br />

The cifs$tmpfile service subprogram returns a value to the stream of the file that it<br />

created in the cifs-file parameter <strong>and</strong> returns a 0 value in the cifs-status parameter. If the<br />

file cannot be created, cifs$tmpfile sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–138 7859 6137–009


<strong>CIFS</strong>$TMPNAM<br />

Application<br />

<strong>CIFS</strong>$TMPNAM<br />

Use the cifs$tmpnam service subprogram to generate a string to use as a file name that<br />

is different from any existing file name.<br />

Synopsis<br />

CALL "cifs$tmpnam" USING name-string, cifs-status.<br />

Description<br />

The cifs$tmpnam service subprogram generates a string that is not the same as the<br />

name of an existing file.<br />

name-string<br />

is an alphanumeric data item that contains the file name returned by the service<br />

subprogram<br />

cifs-status<br />

is a 1-word (1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The cifs$tmpnam service subprogram generates a different string each time it is called.<br />

Note: Files created using strings generated by the cifs$tmpnam service subprogram<br />

are temporary only in the sense that their names must not conflict with those generated<br />

by conventional naming rules <strong>for</strong> the implementation. You must still use the cifs$remove<br />

service subprogram to remove such files when their use is ended <strong>and</strong> be<strong>for</strong>e program<br />

termination.<br />

Return Values<br />

If the cifs$tmpnam service subprogram completes successfully, it returns 0 in cifs-status<br />

<strong>and</strong> the file name is returned in name-string. Otherwise, cifs$tmpnam sets cifs-status to<br />

identify the specific error that was encountered.<br />

7859 6137–009 6–139


<strong>CIFS</strong>$TRUNCATE<br />

<strong>CIFS</strong>$TRUNCATE<br />

Application<br />

Use the cifs$truncate service subprogram to set the end-of-file position <strong>for</strong> an existing<br />

regular file.<br />

Synopsis<br />

CALL "cifs$truncate" USING path, length, cifs-status.<br />

Description<br />

A regular file whose name is given by path has its size (in bytes) set to length. If the file<br />

was previously longer than the length specified, those bytes are no longer accessible. If<br />

the file was previously shorter than the length specified, bytes between the old end of<br />

file <strong>and</strong> the specified length are read as zeroes. For cifs$truncate, the caller must have<br />

write access to the file.<br />

For files stored in SDF <strong>for</strong>mat, the length value of 34359738367 (defined as INT_MAX in<br />

the limits.h header file) has special meaning. <strong>CIFS</strong> treats this as an indication that it must<br />

recalculate the actual size of the file when it is next read based on the position of the<br />

EOF record, rather than pad the file with zeroes.<br />

path<br />

length<br />

is a nul-terminated character string that contains the path name of the file.<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the length to set the file to.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$truncate service subprogram completes successfully, it returns 0 in<br />

cifs-status. Otherwise, cifs$truncate sets cifs-status to identify the specific error that<br />

was encountered.<br />

6–140 7859 6137–009


<strong>CIFS</strong>$UMASK<br />

Application<br />

<strong>CIFS</strong>$UMASK<br />

Use the cifs$umask service subprogram to create the file mode creation mask <strong>for</strong> the<br />

calling process <strong>and</strong> save its previous version.<br />

Synopsis<br />

CALL "cifs$umask" USING new-cifs-mode, old-cifs-mode, cifs-status.<br />

Description<br />

The cifs$umask service subprogram sets the file mode creation mask, where<br />

new-cifs-mode contains the value <strong>for</strong> the mask.<br />

The file mode creation mask is a process attribute that limits the permissions the<br />

process can attach to a file. The mask is a set of attributes corresponding to read, write,<br />

<strong>and</strong> search/execute permissions <strong>for</strong> each of the owner, group, <strong>and</strong> other permission<br />

classes. If an attribute is set in the mask, that permission is denied when files are<br />

created. For example, to prohibit anyone in the group <strong>and</strong> other permission classes from<br />

writing to a file, set the corresponding attributes in the file mode creation mask be<strong>for</strong>e<br />

creating the file.<br />

new-cifs-mode<br />

is a 1-word (1(36) BINARY-1) data item that contains the new settings <strong>for</strong> the file<br />

permissions. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this<br />

variable.<br />

old-cifs-mode<br />

is a 1-word (1(36) BINARY-1) data item that contains the new settings <strong>for</strong> the file<br />

permissions. Use the COBOL COPY PROC <strong>CIFS</strong>-MODE <strong>for</strong> the declaration of this<br />

variable.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Service subprograms that create files request file permissions through a mode argument<br />

in the call statement. However, they first apply the file mode creation mask to turn off<br />

corresponding permissions that are set in the mode argument. For example, if the<br />

attributes <strong>for</strong> group <strong>and</strong> other write permissions are set in the file mode creation mask,<br />

those permissions are not set <strong>for</strong> files created subsequently.<br />

7859 6137–009 6–141


<strong>CIFS</strong>$UMASK<br />

Setting the File Mode Creation Mask<br />

You can set the file mode creation mask using any of the symbolic constants <strong>for</strong> the<br />

individual or group permission settings, as follows:<br />

compute cifs-mode-irwxg = cifs-mode-iread + cifs-mode-iwrite.<br />

compute cifs-mode-irwxo = cifs-mode-iread + cifs-mode-iwrite.<br />

call "cifs$umask" using cifs-mode, old-cifs-mode, cifs-status.<br />

The previous code sets the file mode creation mask to contain both of the following:<br />

• Write access by the group class<br />

• Any access by the other class<br />

The mask, then, prohibits those permissions <strong>for</strong> service subprograms that apply the<br />

mask to the new-cifs-mode argument.<br />

Return Values<br />

The cifs$umask service subprogram returns the previous value of the file mode creation<br />

mask. If the cifs$uname service subprogram completes successfully, it returns 0 in<br />

cifs-status. Otherwise, cifs$umask sets cifs-status to identify the specific error that was<br />

encountered.<br />

6–142 7859 6137–009


<strong>CIFS</strong>$UNAME<br />

Application<br />

<strong>CIFS</strong>$UNAME<br />

Use the cifs$uname service subprogram to retrieve version in<strong>for</strong>mation about the <strong>CIFS</strong><br />

subsystem.<br />

Note: There is no P<strong>OS</strong>IX equivalent to cifs$uname.<br />

Synopsis<br />

CALL "cifs$uname" USING cifs-ss-bdi, cifs-ss-name, cifs-status.<br />

Description<br />

The cifs$uname service subprogram returns version in<strong>for</strong>mation about the <strong>CIFS</strong><br />

subsystem. The cifs-ss-bdi parameter receives the bank descriptor index (BDI) of the<br />

subsystem gate bank, in symbolic <strong>for</strong>m. The data item cifs-ss-bdi must be able to hold 8<br />

characters. The cifs-ss-name parameter is filled with the subsystem name, the date <strong>and</strong><br />

time of the subsystem construction, <strong>and</strong> the build number. The cifs-ss-name data item<br />

must be at least 48 characters long.<br />

cifs-ss-bdi<br />

is an alphanumeric data item that contains Bank Descriptor Index (BDI) of the<br />

subsystem gate bank.<br />

cifs-ss-name<br />

is an alphanumeric data item that contains the subsystem name, the date <strong>and</strong> time<br />

of the subsystem construction, <strong>and</strong> the build number.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Return Values<br />

If the cifs$uname service subprogram completes successfully, it returns 0 in cifs-status.<br />

Otherwise, cifs$uname sets cifs-status to identify the specific error that was<br />

encountered.<br />

7859 6137–009 6–143


<strong>CIFS</strong>$UNGETC<br />

<strong>CIFS</strong>$UNGETC<br />

Application<br />

Use the cifs$ungetc service subprogram to return a character to the input stream,<br />

causing the next read operation to read that character.<br />

Synopsis<br />

CALL "cifs$ungetc" USING prev-char, cifs-file, rtn-char, cifs-status.<br />

Description<br />

The cifs$ungetc service subprogram pushes a character back onto the input stream,<br />

where:<br />

prev-char<br />

cifs-file<br />

is an alphanumeric data item that specifies the character to be returned.<br />

is an opaque data item that describes an open instance of a file. It is a 2-word (S1(72)<br />

BINARY-1) data item. Use the COBOL COPY PROC <strong>CIFS</strong>-FILE <strong>for</strong> the declaration of<br />

this variable.<br />

rtn-char<br />

is an alphanumeric data item that contains the character to be returned.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The character is returned by the next read on that stream, provided no intervening call to<br />

cifs$fseek erases all memory of pushed-back characters.<br />

Notes:<br />

• cifs$ungetc at end of file is legal; it causes cifs$feof to return false until the character<br />

is reread.<br />

• cifs$ungetc does not change the value of the file.<br />

• cifs$ungetc is not allowed <strong>for</strong> output operations.<br />

Return Values<br />

If it completes successfully, the cifs$ungetc service subprogram returns the character<br />

pushed back to the input stream (rtn-char) <strong>and</strong> places a 0 in cifs-status. Otherwise,<br />

cifs$ungetc sets cifs-status to identify the specific error that was encountered.<br />

6–144 7859 6137–009


<strong>CIFS</strong>$UNLINK<br />

Application<br />

<strong>CIFS</strong>$UNLINK<br />

Use the cifs$unlink service subprogram to remove a link from a named, nondirectory file,<br />

which decreases the file's link count by 1. If the link count becomes 0, cifs$unlink<br />

deletes the file from the file system.<br />

See the cifs$rename service subprogram <strong>for</strong> changing the name of a file <strong>and</strong> the<br />

cifs$link service subprogram <strong>for</strong> creating new directory entries <strong>for</strong> a file.<br />

Synopsis<br />

CALL "cifs$unlink" USING path, cifs-status.<br />

Description<br />

The cifs$unlink service subprogram removes a link from a file, where path contains the<br />

file link to be removed. Path cannot contain a directory; use cifs$rmdir to remove a<br />

directory.<br />

path<br />

is a nul-terminated character string that contains the path name of the file.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

If a process has the file open when it is being removed, that process can continue to<br />

access the file through the open file descriptor.<br />

Return Values<br />

If the cifs$unlink service subprogram completes successfully, it does the following:<br />

• Updates the cifs-stat-atime <strong>and</strong> cifs-stat-mtime fields of the parent directory<br />

• Updates the cifs-stat-atime field of the file, if the file's link count is not 0<br />

• Returns 0 in the cifs-status parameter.<br />

Otherwise, cifs$unlink sets cifs-status to identify the specific error that was<br />

encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$unlink service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

7859 6137–009 6–145


<strong>CIFS</strong>$UNLINK<br />

<strong>CIFS</strong>-EACCES Any of the following errors occurred:<br />

• The calling process is denied search permission to a component<br />

of the path name.<br />

• The calling process is denied write permission to the directory<br />

containing the link to be removed.<br />

<strong>CIFS</strong>-EFAULT The value specified by path is invalid.<br />

<strong>CIFS</strong>-ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path contains an empty string.<br />

<strong>CIFS</strong>-ENOTDIR A component of the path name prefix is not a directory.<br />

6–146 7859 6137–009


<strong>CIFS</strong>$UTIME<br />

Application<br />

<strong>CIFS</strong>$UTIME<br />

Use the cifs$utime service subprogram to change the access time <strong>and</strong> modification time<br />

of a file, using an arbitrary time setting. You can retrieve these values into a <strong>CIFS</strong>-STAT<br />

data item using the cifs$stat service subprogram.<br />

These times are also changed by service subprograms that per<strong>for</strong>m input <strong>and</strong> output<br />

operations on the file; check the paragraphs under “Return Values” <strong>for</strong> each service<br />

subprogram to see which time fields the service subprogram updates, if any.<br />

Privilege Requirement<br />

For a process to change the access time <strong>and</strong> modification time of a file, one of the<br />

following must be true:<br />

• The process is privileged.<br />

• The effective user ID of the process is equal to the owning user ID of the file.<br />

Synopsis<br />

CALL "cifs$utime" USING path, timbuf, cifs-status.<br />

Description<br />

The cifs$utime service subprogram sets the access time <strong>and</strong> modification time of a file<br />

to the values in the timbuf parameter, where:<br />

path<br />

timbuf<br />

is a nul-terminated character string that contains the path name of the file.<br />

is a COBOL group item that controls how cifs$utime sets the access time <strong>and</strong><br />

modification time. It must be defined as follows:<br />

01 timbuf.<br />

02 actime pic 1(36) binary-1.<br />

02 modtime pic 1(36) binary-1.<br />

cifs$utime sets the access time <strong>and</strong> modification time of the file to the values in<br />

timbuf if the calling process is allowed to change the times (see “Privilege<br />

Requirement” in this subsection). Whether the process has write permission to the<br />

file is immaterial.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

7859 6137–009 6–147


<strong>CIFS</strong>$UTIME<br />

The timbuf Data Item<br />

The following table describes the timbuf data item:<br />

Member<br />

Name Description **<br />

actime This value is put into the last accessed field of the file.<br />

modtime This value is put into the last modified field of the file.<br />

** Time values are measured in seconds from 00:00:00 January 1, 1970, local time.<br />

Setting Values in the timbuf Data Item<br />

The following program fragment sets the values in the timbuf data item to May 18, 2004<br />

6:35:15. It then uses these values to update the last accessed <strong>and</strong> last modified fields<br />

<strong>for</strong> the file /my_dir/my_file.<br />

01 argument-1.<br />

03 arg1 PIC X(15).<br />

03 filler PIC X value nul.<br />

01 r1 pic 9(10) binary.<br />

01 r2 pic 9(10) binary.<br />

01 r3 pic 9(10) binary.<br />

01 timbuf.<br />

02 actime pic 1(36) binary-1.<br />

02 modtime pic 1(36) binary-1.<br />

...<br />

compute r1 = function integer-of-date(19700101).<br />

compute r2 = function interger-of-date(20040518).<br />

*<br />

* Calculate the number of seconds from 01/01/1970 to 05/18/2004<br />

*<br />

compute r3 = (r2 - r1) * 24 * 60 * 60.<br />

*<br />

* Add the number of seconds from midnight 05/18/2004 to 06:35:15 to<br />

* total<br />

*<br />

compute r3 = r3 + (6 * 60 * 60) + (35 * 60) + 15.<br />

move r3 to actime modtime.<br />

move '/my_dir/my_file' to arg1.<br />

call "<strong>CIFS</strong>$UTIME" using arg1, timbuf, cifs-status.<br />

if cifs-status NOT = 0<br />

call "<strong>CIFS</strong>$PERROR" using cifs-status.<br />

Return Values<br />

If the cifs$utime service subprogram completes successfully, it returns a value of 0 in<br />

the cifs-status parameter. Otherwise, cifs$utime sets cifs-status to identify the specific<br />

error that was encountered.<br />

6–148 7859 6137–009


Error Codes<br />

<strong>CIFS</strong>$UTIME<br />

If any of the following conditions occurs, the cifs$utime service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

EACCES Either of the following errors occurred:<br />

• The calling process is denied search permission on a directory in<br />

the path name.<br />

• timbuf is null, <strong>and</strong> all of the following are true:<br />

− The effective user ID of the calling process does not match<br />

the user ID of the owner of the file.<br />

− The calling process is denied write permission <strong>for</strong> the file.<br />

− The process is not privileged.<br />

EFAULT The value specified by path is invalid.<br />

ENOENT Either of the following errors occurred:<br />

• The file does not exist.<br />

• path points to an empty string.<br />

ENOTDIR A component of the path name prefix is not a directory.<br />

EPERM All of the following are true:<br />

• timbuf is not null.<br />

• The effective user ID of the calling process does not match the<br />

file's owner.<br />

• The process is not privileged.<br />

7859 6137–009 6–149


<strong>CIFS</strong>$WRITE<br />

<strong>CIFS</strong>$WRITE<br />

Application<br />

Use the cifs$write service subprogram to write data to a file at the current read/write<br />

position. Use the cifs$lseek service subprogram to reposition the read/write offset. See<br />

the following subsections <strong>for</strong> more in<strong>for</strong>mation: “Determining the Number of Bytes<br />

Written,”“Starting Position <strong>for</strong> Different File Types,” “Writing to Different File Types,”<br />

<strong>and</strong> “Translating Special Characters.”<br />

Synopsis<br />

CALL "cifs$write" USING fildes, buffer, bytes-to-write,<br />

bytes-written, cifs-status.<br />

Description<br />

The cifs$write service subprogram writes data from a buffer to an open file, where:<br />

fildes<br />

buffer<br />

is a 1-word (S1(36) BINARY-1) data item which contains the file description of the file<br />

to be read.<br />

is an alphanumeric data item holding the data to write.<br />

bytes-to-write<br />

is a 1-word (S1(36) BINARY-1) data item that is the number of bytes to write, which<br />

is limited by the size of a data bank.<br />

bytes-written<br />

is a 1-word (1(36) BINARY-1) data item that is set to the actual number of bytes<br />

written.<br />

cifs-status<br />

is a 1-word (1(36) BINARY-1) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

Attempting to Write Beyond the Limits<br />

The cifs$write service subprogram fails if the file position exceeds the maximum size of<br />

the file.<br />

6–150 7859 6137–009


Return Values<br />

<strong>CIFS</strong>$WRITE<br />

If the cifs$write service subprogram completes successfully, it does the following:<br />

• Updates the last accessed time <strong>and</strong> last modified time fields (see the cifs$fstat <strong>and</strong><br />

cifs$stat service subprograms) of the file, if the service subprogram wrote any bytes<br />

• Returns the number of bytes actually written to the file<br />

• Returns 0 in cifs-status<br />

Otherwise, cifs$write sets cifs-status to identify the specific error that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$write service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-EAGAIN The <strong>CIFS</strong>-OFLAG-NONBLOCK flag is set, the calling process is<br />

writing to a pipe or FIFO file, <strong>and</strong> one of the following conditions<br />

occurred:<br />

• The pipe or FIFO file is full.<br />

• The pipe or FIFO file does not have bytes-to-write space<br />

available.<br />

<strong>CIFS</strong>-EBADF fildes is not a valid file descriptor open <strong>for</strong> writing.<br />

<strong>CIFS</strong>-EFAULT One of the following errors occurred:<br />

• buffer points to an invalid address, <strong>and</strong> bytes-to-write is<br />

greater than 0.<br />

• buffer is valid, but (buffer + (bytes-to-write - 1)) points to an<br />

invalid address.<br />

<strong>CIFS</strong>-EFBIG The calling process is attempting to write at a starting position<br />

beyond the highest position allowed <strong>for</strong> the file.<br />

<strong>CIFS</strong>-EIO A disk error occurred.<br />

<strong>CIFS</strong>-EPIPE One of the following errors occurred:<br />

• An attempt is made to write to a pipe or FIFO file that is not<br />

open <strong>for</strong> reading by any process.<br />

• While waiting <strong>for</strong> room in a pipe, all file descriptors open <strong>for</strong><br />

reading the pipe are closed.<br />

7859 6137–009 6–151


<strong>CIFS</strong>$WRITE<br />

Determining the Number of Bytes Written<br />

The cifs$write service subprogram returns the number of bytes actually written<br />

(bytes-written) from the buffer to the file, which is never greater than bytes-to-write. The<br />

following paragraphs relate this return value to the input value of bytes-to-write.<br />

bytes-written = bytes-to-write > 0<br />

The cifs$write service subprogram wrote <strong>and</strong> stored the exact number of bytes<br />

requested.<br />

bytes-written < bytes-to-write<br />

The value returned is less than bytes-to-write if one of the following statements is true:<br />

• Fewer than bytes-to-write bytes can be written without exceeding the maximum<br />

size of the file.<br />

• The file is a pipe or FIFO that has fewer than bytes-to-write bytes immediately<br />

available <strong>for</strong> writing.<br />

bytes-written = 0<br />

The value returned is 0 if the value of bytes-to-write is 0.<br />

Starting Position <strong>for</strong> Different File Types<br />

The file type determines the first byte in the file to be written, as shown in the following<br />

paragraphs.<br />

Regular Files<br />

The service subprogram starts at the current position of the read/write offset associated<br />

with the open file description corresponding to fildes. Be<strong>for</strong>e returning, cifs$write<br />

increases the read/write offset by the number of bytes written to the file.<br />

If the <strong>CIFS</strong>-OFLAG-APPEND flag associated with the open file description corresponding<br />

to fildes is set, the read/write offset is set to the end of the file immediately be<strong>for</strong>e each<br />

write operation.<br />

Writing data to locations beyond the end of the file causes the file to exp<strong>and</strong><br />

automatically.<br />

Pipes <strong>and</strong> FIFO Files<br />

The service subprogram starts at the current position associated with the file<br />

corresponding to fildes.<br />

6–152 7859 6137–009


Writing to Different File Types<br />

<strong>CIFS</strong>$WRITE<br />

The file type determines the behavior of the cifs$write service subprogram, as shown in<br />

the following paragraphs.<br />

Regular Files<br />

Data accumulates in buffers, which are written to nonvolatile storage when all processes<br />

have closed the file (see the cifs$close service subprogram).<br />

Pipes <strong>and</strong> FIFO Files<br />

Pipes <strong>and</strong> FIFO files have a storage capacity of 7,168 bytes to store data until it is read.<br />

No data is written to nonvolatile storage.<br />

If the pipe or FIFO file is full, a process must wait <strong>for</strong> data to be read from it be<strong>for</strong>e<br />

writing data to it. The <strong>CIFS</strong>-OFLAG-NONBLOCK flag associated with the open file<br />

description corresponding to fildes (see the cifs$open <strong>and</strong> cifs$fcntl service<br />

subprograms) determines the behavior of cifs$write <strong>for</strong> pipes <strong>and</strong> FIFO files, as follows:<br />

<strong>CIFS</strong>-OFLAG-<br />

NONBLOCK<br />

Set cifs$write does one of<br />

the following:<br />

Value of bytes-to-write<br />

≤ 7,168* > 7,168**<br />

• Successfully<br />

writes all the data<br />

• Returns an error<br />

condition if there<br />

is not room <strong>for</strong> all<br />

the data<br />

Clear cifs$write waits <strong>for</strong><br />

room in the file <strong>for</strong> all<br />

the data<br />

cifs$write does one of the<br />

following:<br />

• Writes as much data as<br />

immediately possible <strong>and</strong><br />

returns the number of<br />

bytes written. (If the pipe<br />

or FIFO file is empty,<br />

cifs$write transfers 7,168<br />

bytes.)<br />

• Returns an error condition<br />

if the pipe or FIFO file is<br />

full.<br />

cifs$write transfers data to the<br />

pipe, not returning until one of<br />

the following occurs:<br />

• The bytes-to-write bytes<br />

are written.<br />

• If the pipe is empty,<br />

cifs$write transfers at<br />

least 7,168 bytes be<strong>for</strong>e<br />

returning.<br />

* If a process writes 7,168 bytes or less to a pipe, the data in the pipe is guaranteed to be<br />

contiguous.<br />

** If a process writes more than 7,168 bytes to a pipe, the data can alternate with data from<br />

other processes writing to the pipe.<br />

7859 6137–009 6–153


<strong>CIFS</strong>$WRITE<br />

The call returns an error condition if one of the following occurs:<br />

• No process has the pipe open <strong>for</strong> reading.<br />

• While cifs$write is waiting <strong>for</strong> data to be read from a pipe, all file descriptors open<br />

<strong>for</strong> reading the pipe are closed.<br />

Translating Special Characters<br />

The newline (line feed) characters have special meaning <strong>for</strong> a write operation when fildes<br />

refers to <strong>CIFS</strong>-STDOUT-FD, <strong>CIFS</strong>-STDERR-FD, or an SDF file. The newline character<br />

causes cifs$write to write the characters preceding the newline since the end of the last<br />

line as either of the following:<br />

• One line to <strong>CIFS</strong>-STDOUT-FD or <strong>CIFS</strong>-STDERR-FD<br />

• One image to the SDF file<br />

6–154 7859 6137–009


<strong>CIFS</strong>$XLATE<br />

Application<br />

<strong>CIFS</strong>$XLATE<br />

Use the cifs$xlate service subprogram to set or retrieve the translation attributes <strong>for</strong> a<br />

directory.<br />

Note: There is no P<strong>OS</strong>IX equivalent to cifs$xlate.<br />

Synopsis<br />

CALL "cifs$xlate" USING path, cifs-xlate, ccs-in, ccs-out, cifs-status.<br />

Description<br />

path<br />

is a nul-terminated character string that contains the path name of the file.<br />

cifs-xlate<br />

ccs-in<br />

is a 1-word (1(72) BINARY-1) data item which contains the translate in<strong>for</strong>mation. Use<br />

the COBOL COPY PROC <strong>CIFS</strong>-XLATE <strong>for</strong> the declaration of this variable.<br />

ccs-out<br />

is an alphanumeric data item that contains a CCS name.<br />

is an alphanumeric data item that contains a CCS name.<br />

cifs-status<br />

is a 1-word ( 1(36) BINARY-1 ) data item that contains the error in<strong>for</strong>mation returned<br />

by the service subprogram. Use the COBOL COPY PROC <strong>CIFS</strong>-API <strong>for</strong> the<br />

declaration of this variable.<br />

The path parameter specifies the directory <strong>for</strong> which translation in<strong>for</strong>mation is set or<br />

retrieved. The cifs-xlate data item must be set by one of the following comm<strong>and</strong>s:<br />

set cifs-xlate-get to true.<br />

set cifs-xlate-set-in to true.<br />

set cifs-xlate-set-out to true.<br />

set cifs-xlate-set-both to true.<br />

For cifs-xlate-get set to true, ccs-in <strong>and</strong> ccs-out specify where to return the coded<br />

character set (CCS) names <strong>for</strong> the directory; the resulting values are empty strings if<br />

translation is not enabled <strong>for</strong> the specified directory.<br />

For cifs-xlate-set-in or cifs-xlate-set-both set to true, ccs-in is the CCS name used to<br />

establish the translation mode <strong>for</strong> files written into the directory; an empty string turns<br />

off translation.<br />

7859 6137–009 6–155


<strong>CIFS</strong>$XLATE<br />

For cifs-xlate-set-out set to true, ccs-out is the CCS name used to establish the<br />

translation mode <strong>for</strong> files read from the directory; an empty string turns off translation.<br />

See the <strong>CIFS</strong>UT xlate comm<strong>and</strong> <strong>for</strong> a list of valid CCS names.<br />

Return Values<br />

If the cifs$xlate service subprogram completes successfully, it returns a value of 0 in the<br />

cifs-status parameter. Otherwise, cifs$xlate sets cifs-status to identify the specific error<br />

that was encountered.<br />

Error Codes<br />

If any of the following conditions occurs, the cifs$xlate service subprogram returns a<br />

nonzero value in the cifs-status parameter. The following COBOL level 88 condition<br />

names (defined in the COBOL COPY PROC <strong>CIFS</strong>-API) can be checked in order to<br />

determine the error that was returned:<br />

<strong>CIFS</strong>-ECCSNAME One or both of the requested CCS names are not known to<br />

<strong>CIFS</strong>.<br />

<strong>CIFS</strong>-ENOTDIR The requested path is not a directory.<br />

6–156 7859 6137–009


Example Program<br />

Example Program<br />

The following example program can be used to list the contents of a file/directory that<br />

resides on the <strong>2200</strong>, or it can be used to copy a file/directory from one location to<br />

another. If uses many of the service programs that were discussed earlier in this section.<br />

First, compile the program. Be sure to per<strong>for</strong>m the following comm<strong>and</strong> prior to the<br />

compilation:<br />

@use cob$pf.,sys$lib$*cifs$lib.<br />

IDENTIFICATION DIVISION.<br />

PROGRAM-ID.<br />

<strong>CIFS</strong>-TEST.<br />

ENVIRONMENT DIVISION.<br />

CONFIGURATION SECTION.<br />

SOURCE-COMPUTER. UNISYS-<strong>2200</strong>.<br />

OBJECT-COMPUTER. UNISYS-<strong>2200</strong>.<br />

*<br />

* Control characters commonly used in C strings.<br />

*<br />

SPECIAL-NAMES.<br />

SYMBOLIC nul, lf IS 1, 11.<br />

DATA DIVISION.<br />

WORKING-STORAGE SECTION.<br />

*<br />

* General <strong>CIFS</strong> definitions.<br />

*<br />

COPY <strong>CIFS</strong>-API.<br />

*<br />

* Definitions <strong>for</strong> OFLAG bits used on open() calls.<br />

*<br />

COPY <strong>CIFS</strong>-OFLAG.<br />

*<br />

* Definitions <strong>for</strong> MODE bits used when creating files.<br />

*<br />

COPY <strong>CIFS</strong>-MODE.<br />

*<br />

* Space <strong>for</strong> a pointer to the st<strong>and</strong>ard output <strong>and</strong> st<strong>and</strong>ard error<br />

* stream control structures.<br />

*<br />

COPY <strong>CIFS</strong>-FILE REPLACING <strong>CIFS</strong>-FILE BY <strong>CIFS</strong>-STDERR-FILE.<br />

COPY <strong>CIFS</strong>-FILE REPLACING <strong>CIFS</strong>-FILE BY <strong>CIFS</strong>-STDOUT-FILE.<br />

*<br />

* Comm<strong>and</strong> parsing control string, result fields, <strong>and</strong> error messages.<br />

*<br />

01 COMMAND-FORMAT.<br />

03 FILLER PIC X(8) VALUE " %n%3s%n".<br />

03 FILLER PIC X(7) VALUE " %4095s".<br />

03 FILLER PIC X(7) VALUE " %4095s".<br />

03 FILLER PIC X(4) VALUE " %1s".<br />

03 FILLER PIC X VALUE nul.<br />

7859 6137–009 6–157


Example Program<br />

77 FIELD-COUNT PIC S1(36) BINARY-1.<br />

01 COMMAND-LINE.<br />

03 COMMAND-BYTE PIC X OCCURS 4.<br />

77 COMMAND-START PIC S1(36) BINARY-1.<br />

77 COMMAND-STOP PIC S1(36) BINARY-1.<br />

77 COMMAND-BYTES PIC S1(36) BINARY-1.<br />

77 ARGUMENT-1 PIC X(4096).<br />

77 ARGUMENT-2 PIC X(4096).<br />

77 ARGUMENT-3 PIC X.<br />

01 COMMAND-ERROR-MESSAGE.<br />

03 FILLER PIC X(27)<br />

VALUE "*Error reading comm<strong>and</strong> line".<br />

03 FILLER PIC X VALUE nul.<br />

01 SYNTAX-ERROR-FORMAT.<br />

03 FILLER PIC X(24)<br />

VALUE "Unrecognized input: ".<br />

03 FILLER PIC X VALUE lf.<br />

03 FILLER PIC X VALUE nul.<br />

*<br />

* Error <strong>and</strong> in<strong>for</strong>mational messages <strong>for</strong> file access.<br />

*<br />

01 OPEN-ERROR-FORMAT.<br />

03 FILLER PIC X(21)<br />

VALUE "*Error opening : ".<br />

03 FILLER PIC X VALUE nul.<br />

01 READ-ERROR-MESSAGE.<br />

03 FILLER PIC X(25)<br />

VALUE "*Error reading input file".<br />

03 FILLER PIC X VALUE nul.<br />

01 WRITE-ERROR-MESSAGE.<br />

03 FILLER PIC X(26)<br />

VALUE "*Error writing output file".<br />

03 FILLER PIC X VALUE nul.<br />

01 CL<strong>OS</strong>E-ERROR-MESSAGE.<br />

03 FILLER PIC X(26)<br />

VALUE "*Error closing output file".<br />

03 FILLER PIC X VALUE nul.<br />

01 COPY-FORMAT.<br />

03 FILLER PIC X(15)<br />

VALUE "%d bytes copied".<br />

03 FILLER PIC X VALUE lf.<br />

03 FILLER PIC X VALUE nul.<br />

*<br />

* Data fields used in reading <strong>and</strong> writing files.<br />

*<br />

77 READ-FD PIC S1(36) BINARY-1.<br />

77 WRITE-FD PIC S1(36) BINARY-1.<br />

COPY <strong>CIFS</strong>-DIR.<br />

77 BYTES-READ PIC S1(36) BINARY-1.<br />

77 BYTES-WRITTEN PIC S1(36) BINARY-1.<br />

77 BYTES-TOTAL PIC S1(36) BINARY-1.<br />

01 DATA-BUFFER.<br />

6–158 7859 6137–009


03 DATA-BYTE PIC X OCCURS 131072.<br />

*<br />

* Error <strong>and</strong> in<strong>for</strong>mational messages <strong>for</strong> listing directory entries.<br />

*<br />

01 GETCWD-ERROR-MESSAGE.<br />

03 FILLER PIC X(35)<br />

VALUE "*Error retrieving current directory".<br />

03 FILLER PIC X VALUE nul.<br />

01 CHDIR-ERROR-FORMAT.<br />

03 FILLER PIC X(25)<br />

VALUE "*Error changing to : ".<br />

03 FILLER PIC X VALUE nul.<br />

01 DIRECTORY-ERROR-MESSAGE.<br />

03 FILLER PIC X(24)<br />

VALUE "*Error reading directory".<br />

01 STAT-ERROR-FORMAT.<br />

03 FILLER PIC X(26)<br />

VALUE "*Error on stat() of : ".<br />

03 FILLER PIC X VALUE nul.<br />

01 STAT-ENTRY-FORMAT.<br />

03 FILLER PIC X(6) VALUE " %-18s".<br />

03 FILLER PIC X(6) VALUE " %012o".<br />

03 FILLER PIC X(4) VALUE " %8i".<br />

03 FILLER PIC X(4) VALUE " %5i".<br />

03 FILLER PIC X(5) VALUE " %11i".<br />

03 FILLER PIC X VALUE lf.<br />

03 FILLER PIC X VALUE nul.<br />

01 ISTAT-ERROR-FORMAT.<br />

03 FILLER PIC X(35)<br />

VALUE "*Error on istat() of , ino %d: ".<br />

03 FILLER PIC X VALUE nul.<br />

01 ISTAT-FILE-FORMAT.<br />

03 FILLER PIC X(11) VALUE " %s#%s(%d)".<br />

03 FILLER PIC X VALUE nul.<br />

01 ISTAT-TYPE-FORMAT.<br />

03 FILLER PIC X(10) VALUE " (%hd.%hd)".<br />

03 FILLER PIC X VALUE nul.<br />

01 ISTAT-OWNER-FORMAT.<br />

03 FILLER PIC X(7) VALUE " %s/%s".<br />

03 FILLER PIC X VALUE lf.<br />

03 FILLER PIC X VALUE nul.<br />

*<br />

* Data fields used in listing directories.<br />

*<br />

01 DOT-NAME.<br />

03 FILLER PIC X VALUE ".".<br />

03 FILLER PIC X VALUE nul.<br />

77 INODE-NUMBER PIC S1(36) BINARY-1.<br />

01 ENTRY-NAME.<br />

03 ENTRY-BYTE PIC X OCCURS 4096.<br />

COPY <strong>CIFS</strong>-STAT.<br />

*<br />

Example Program<br />

7859 6137–009 6–159


Example Program<br />

*<br />

*<br />

PROCEDURE DIVISION.<br />

COMMAND-LOOP SECTION.<br />

GET-COMMAND.<br />

*<br />

* Retrieve the FILE struct pointers <strong>for</strong> use on normal <strong>and</strong><br />

* error messages.<br />

*<br />

CALL "<strong>CIFS</strong>$STDOUT" USING <strong>CIFS</strong>-STDOUT-FILE.<br />

CALL "<strong>CIFS</strong>$STDERR" USING <strong>CIFS</strong>-STDERR-FILE.<br />

*<br />

* Main loop to read, parse, <strong>and</strong> dispatch comm<strong>and</strong>s.<br />

*<br />

PERFORM TEST AFTER UNTIL COMMAND-BYTES = 0<br />

*<br />

* Read a comm<strong>and</strong> line from st<strong>and</strong>ard input.<br />

*<br />

CALL "<strong>CIFS</strong>$READ" USING <strong>CIFS</strong>-STDIN-FD,<br />

DATA-BUFFER,<br />

131071,<br />

COMMAND-BYTES,<br />

<strong>CIFS</strong>-STATUS<br />

IF BYTES-READ < 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS,<br />

COMMAND-ERROR-MESSAGE<br />

STOP RUN<br />

END-IF<br />

*<br />

* Insure the image is nul terminated <strong>for</strong> sscanf().<br />

*<br />

IF COMMAND-BYTES > 0 AND DATA-BYTE(COMMAND-BYTES) = lf<br />

MOVE nul to DATA-BYTE(COMMAND-BYTES)<br />

ELSE<br />

MOVE nul TO DATA-BYTE(COMMAND-BYTES + 1)<br />

END-IF<br />

*<br />

* Clear comm<strong>and</strong> field be<strong>for</strong>e parsing into it.<br />

*<br />

MOVE SPACES TO COMMAND-LINE<br />

CALL "<strong>CIFS</strong>$SSCANF" USING FIELD-COUNT,<br />

DATA-BUFFER,<br />

COMMAND-FORMAT,<br />

COMMAND-START,<br />

COMMAND-LINE,<br />

COMMAND-STOP,<br />

ARGUMENT-1,<br />

ARGUMENT-2,<br />

ARGUMENT-3<br />

*<br />

* If anything was input, replace the terminating nul with a space to<br />

* allow COBOL comparisons to work, then branch to the proper h<strong>and</strong>ler.<br />

6–160 7859 6137–009


Example Program<br />

*<br />

IF FIELD-COUNT > 0<br />

SUBTRACT COMMAND-START FROM COMMAND-STOP GIVING<br />

COMMAND-BYTES<br />

MOVE SPACE TO COMMAND-BYTE(COMMAND-BYTES + 1)<br />

EVALUATE COMMAND-LINE ALSO FIELD-COUNT<br />

WHEN "cp" ALSO 3 PERFORM COPY-FILE<br />

WHEN "ls" ALSO 2 PERFORM LIST-DIRECTORY<br />

WHEN OTHER PERFORM SYNTAX-ERROR<br />

END-EVALUATE<br />

END-IF<br />

END-PERFORM.<br />

STOP RUN.<br />

*<br />

* Indicate input does not comply with syntax rules.<br />

*<br />

SYNTAX-ERROR.<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

SYNTAX-ERROR-FORMAT,<br />

DATA-BUFFER.<br />

*<br />

* Section to copy a file to a new location.<br />

*<br />

COPY-FILE SECTION.<br />

*<br />

* Open the source file read-only. Display an error message <strong>and</strong> give<br />

* up if the open() fails.<br />

*<br />

OPEN-INPUT-FILE.<br />

MOVE 0 TO <strong>CIFS</strong>-OFLAG.<br />

MOVE 1 TO <strong>CIFS</strong>-OFLAG-RDONLY.<br />

MOVE 0 TO <strong>CIFS</strong>-MODE.<br />

CALL "<strong>CIFS</strong>$OPEN" USING ARGUMENT-1,<br />

<strong>CIFS</strong>-OFLAG,<br />

<strong>CIFS</strong>-MODE,<br />

READ-FD,<br />

<strong>CIFS</strong>-STATUS.<br />

IF READ-FD < 0<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

OPEN-ERROR-FORMAT,<br />

ARGUMENT-1<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

GO TO COPY-DONE<br />

END-IF.<br />

*<br />

* Now try to create the output file. If the specific file already<br />

* exists in a writable state, it will be erased <strong>and</strong> overwritten.<br />

* Otherwise, a new file will be created. Any errors result in a<br />

* message being displayed <strong>and</strong> ab<strong>and</strong>onment of the copy.<br />

*<br />

7859 6137–009 6–161


Example Program<br />

OPEN-OUTPUT-FILE.<br />

MOVE 0 TO <strong>CIFS</strong>-MODE.<br />

COMPUTE <strong>CIFS</strong>-MODE-IRWXU = <strong>CIFS</strong>-MODE-IREAD +<br />

<strong>CIFS</strong>-MODE-IWRITE.<br />

COMPUTE <strong>CIFS</strong>-MODE-IRWXG = <strong>CIFS</strong>-MODE-IREAD;<br />

COMPUTE <strong>CIFS</strong>-MODE-IRWXO = <strong>CIFS</strong>-MODE-IREAD;<br />

CALL "<strong>CIFS</strong>$CREAT" USING ARGUMENT-2,<br />

<strong>CIFS</strong>-MODE,<br />

WRITE-FD,<br />

<strong>CIFS</strong>-STATUS.<br />

IF WRITE-FD < 0<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

OPEN-ERROR-FORMAT,<br />

ARGUMENT-2<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>E" USING READ-FD,<br />

<strong>CIFS</strong>-STATUS<br />

GO TO COPY-DONE<br />

END-IF.<br />

*<br />

* Both input <strong>and</strong> output files are open, so start reading <strong>and</strong> writing.<br />

* Display a message <strong>and</strong> punt if any errors encountered.<br />

*<br />

COPY-INPUT-TO-OUTPUT.<br />

MOVE 0 TO BYTES-TOTAL.<br />

PERFORM TEST AFTER UNTIL BYTES-READ = 0<br />

CALL "<strong>CIFS</strong>$READ" USING READ-FD,<br />

DATA-BUFFER,<br />

131072,<br />

BYTES-READ,<br />

<strong>CIFS</strong>-STATUS<br />

IF BYTES-READ < 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS,<br />

READ-ERROR-MESSAGE<br />

GO TO CL<strong>OS</strong>E-FILES<br />

END-IF<br />

IF BYTES-READ > 0<br />

CALL "<strong>CIFS</strong>$WRITE" USING WRITE-FD,<br />

DATA-BUFFER,<br />

BYTES-READ,<br />

BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STATUS<br />

IF BYTES-WRITTEN < 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS,<br />

WRITE-ERROR-MESSAGE<br />

GO TO CL<strong>OS</strong>E-FILES<br />

END-IF<br />

ADD BYTES-WRITTEN TO BYTES-TOTAL<br />

END-IF<br />

END-PERFORM.<br />

*<br />

6–162 7859 6137–009


Example Program<br />

* Indicate progress, then close both files. Note that we<br />

* ignore the status on closing the input file, but do report<br />

* a problem with the output, since that may result in the<br />

* underlying element not being created.<br />

*<br />

CL<strong>OS</strong>E-FILES.<br />

CALL "<strong>CIFS</strong>$PRINTF" USING BYTES-WRITTEN,<br />

COPY-FORMAT,<br />

BYTES-TOTAL.<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>E" USING READ-FD,<br />

<strong>CIFS</strong>-STATUS.<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>E" USING WRITE-FD,<br />

<strong>CIFS</strong>-STATUS.<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS,<br />

CL<strong>OS</strong>E-ERROR-MESSAGE<br />

END-IF.<br />

COPY-DONE.<br />

EXIT.<br />

*<br />

* Section to display the entries in a directory.<br />

*<br />

LIST-DIRECTORY SECTION.<br />

*<br />

* Save the current directory, <strong>and</strong> switch to the requested one.<br />

*<br />

CHANGE-CURRENT-DIRECTORY.<br />

CALL "<strong>CIFS</strong>$GETCWD" USING DATA-BUFFER,<br />

131072,<br />

<strong>CIFS</strong>-STATUS.<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS,<br />

GETCWD-ERROR-MESSAGE<br />

GO TO LIST-DONE<br />

END-IF.<br />

CALL "<strong>CIFS</strong>$CHDIR" USING ARGUMENT-1,<br />

<strong>CIFS</strong>-STATUS.<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

CHDIR-ERROR-FORMAT,<br />

ARGUMENT-1<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

GO TO LIST-DONE<br />

END-IF.<br />

*<br />

* Open the requested directory. Display a message <strong>and</strong> get out if there<br />

* are any errors.<br />

*<br />

OPEN-DIRECTORY.<br />

CALL "<strong>CIFS</strong>$OPENDIR" USING DOT-NAME,<br />

<strong>CIFS</strong>-DIR,<br />

7859 6137–009 6–163


Example Program<br />

<strong>CIFS</strong>-STATUS.<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

OPEN-ERROR-FORMAT,<br />

ARGUMENT-1<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

GO TO RESTORE-CURRENT-DIRECTORY<br />

END-IF.<br />

*<br />

* Scan the directory, do stat() <strong>and</strong> istat() on each entry, <strong>and</strong><br />

* display the info.<br />

*<br />

READ-DIRECTORY.<br />

PERFORM TEST AFTER UNTIL BYTES-READ = 0<br />

CALL "<strong>CIFS</strong>$READDIR" USING <strong>CIFS</strong>-DIR,<br />

INODE-NUMBER,<br />

ENTRY-NAME,<br />

4095,<br />

BYTES-READ,<br />

<strong>CIFS</strong>-STATUS<br />

MOVE nul to ENTRY-BYTE(BYTES-READ + 1)<br />

IF BYTES-READ SPACES<br />

CALL "<strong>CIFS</strong>$PRINTF" USING<br />

BYTES-WRITTEN,<br />

ISTAT-FILE-FORMAT,<br />

<strong>CIFS</strong>-ISTAT-DIRECTORY,<br />

<strong>CIFS</strong>-ISTAT-CONTAIN,<br />

<strong>CIFS</strong>-ISTAT-CYCLE<br />

6–164 7859 6137–009


END-IF<br />

IF <strong>CIFS</strong>-ISTAT-ELEMENT-NAME > SPACES<br />

CALL "<strong>CIFS</strong>$FPUTC" USING '.',<br />

<strong>CIFS</strong>-STDOUT-FILE,<br />

<strong>CIFS</strong>-STATUS<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

STOP RUN<br />

END-IF<br />

CALL "<strong>CIFS</strong>$FPUTS" USING<br />

<strong>CIFS</strong>-ISTAT-ELEMENT-NAME,<br />

<strong>CIFS</strong>-STDOUT-FILE,<br />

BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STATUS<br />

IF <strong>CIFS</strong>-ISTAT-ELEMENT-VERSION > SPACES<br />

CALL "<strong>CIFS</strong>$FPUTC" USING '/',<br />

<strong>CIFS</strong>-STDOUT-FILE,<br />

<strong>CIFS</strong>-STATUS<br />

CALL "<strong>CIFS</strong>$FPUTS" USING<br />

<strong>CIFS</strong>-ISTAT-ELEMENT-VERSION,<br />

<strong>CIFS</strong>-STDOUT-FILE,<br />

BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STATUS<br />

END-IF<br />

CALL "<strong>CIFS</strong>$PRINTF" USING<br />

BYTES-WRITTEN,<br />

ISTAT-TYPE-FORMAT,<br />

<strong>CIFS</strong>-ISTAT-ELEMENT-TYPE,<br />

<strong>CIFS</strong>-ISTAT-ELEMENT-SUB-TYPE<br />

END-IF<br />

CALL "<strong>CIFS</strong>$PRINTF" USING BYTES-WRITTEN,<br />

ISTAT-OWNER-FORMAT,<br />

<strong>CIFS</strong>-ISTAT-OWNER,<br />

<strong>CIFS</strong>-ISTAT-ACR<br />

ELSE<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

ISTAT-ERROR-FORMAT,<br />

ENTRY-NAME,<br />

<strong>CIFS</strong>-STAT-INO<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

END-IF<br />

ELSE<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

STAT-ERROR-FORMAT,<br />

ENTRY-NAME<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

END-IF<br />

END-PERFORM.<br />

*<br />

* Close the directory we were reading. Ignore any errors.<br />

Example Program<br />

7859 6137–009 6–165


Example Program<br />

*<br />

CL<strong>OS</strong>E-DIRECTORY.<br />

CALL "<strong>CIFS</strong>$CL<strong>OS</strong>EDIR" USING <strong>CIFS</strong>-DIR,<br />

<strong>CIFS</strong>-STATUS.<br />

*<br />

* Reestablish the directory we were in when we started.<br />

*<br />

RESTORE-CURRENT-DIRECTORY.<br />

CALL "<strong>CIFS</strong>$CHDIR" USING DATA-BUFFER,<br />

<strong>CIFS</strong>-STATUS.<br />

IF <strong>CIFS</strong>-STATUS NOT = 0<br />

CALL "<strong>CIFS</strong>$FPRINTF" USING BYTES-WRITTEN,<br />

<strong>CIFS</strong>-STDERR-FILE,<br />

CHDIR-ERROR-FORMAT,<br />

DATA-BUFFER<br />

CALL "<strong>CIFS</strong>$PERROR" USING <strong>CIFS</strong>-STATUS<br />

END-IF.<br />

LIST-DONE.<br />

EXIT.<br />

END PROGRAM <strong>CIFS</strong>-TEST.<br />

Following the compilation, the program can be executed. In order to list the contents of<br />

the <strong>2200</strong> file sys$lib$*ucob, per<strong>for</strong>m the following comm<strong>and</strong>s:<br />

@xqt object-module<br />

ls /os<strong>2200</strong>/sys$lib$/ucob<br />

This must result in output that looks like this:<br />

. 000000040777 455956 2 2983<br />

STD#sys$lib$*ucob(53) lewis/PUBLIC<br />

.. 000000040777 9 1062 38413<br />

cifs-admin/PRIVATE<br />

ucob-fgss..abs 100001100777 767829 1 2907640<br />

STD#sys$lib$*ucob(53).ucob-fgss (6.1) lewis/PUBLIC<br />

ucob-fgssf..abs 100001100777 768187 1 2975736<br />

STD#sys$lib$*ucob(53).ucob-fgssf (6.1) lewis/PUBLIC<br />

ucob..abs 100001100777 767896 1 72248<br />

STD#sys$lib$*ucob(53).ucob (6.3) lewis/PUBLIC<br />

ivp 100002100777 767910 1 14224<br />

STD#sys$lib$*ucob(53).ivp (1.9) lewis/PUBLIC<br />

solar$sgs 100002100777 767894 1 6832<br />

STD#sys$lib$*ucob(53).solar$sgs (1.1) lewis/PUBLIC<br />

deact-scss 100002100777 767895 1 1568<br />

STD#sys$lib$*ucob(53).deact-scss (1.1) lewis/PUBLIC<br />

6–166 7859 6137–009


Example Program<br />

In order to copy the file sys$lib$*ucob.ivp to another location, per<strong>for</strong>m the following<br />

comm<strong>and</strong>s:<br />

@xqt object-module<br />

cp /os<strong>2200</strong>/sys$lib$/ucob/ivp /os<strong>2200</strong>/my/file/ivp<br />

This must result in the following output:<br />

12674 bytes copied<br />

The file sys$lib$*ucob.ivp must now be copied to the file my*file.ivp.<br />

The following example illustrates what happens if the file that you are attempting to copy<br />

from does not exist:<br />

@xqt object-module<br />

cp /os<strong>2200</strong>/invalid/file/ivp /os<strong>2200</strong>/my/file/ivp<br />

This must result in the following output:<br />

*Error opening : *ERROR CFS000002: Object with specified<br />

name does not exist.<br />

7859 6137–009 6–167


Example Program<br />

6–168 7859 6137–009


Section 7<br />

<strong>CIFS</strong> Client<br />

The 5R1 <strong>and</strong> higher levels of <strong>CIFS</strong> includes a client capability, enabling <strong>CIFS</strong>-aware <strong>2200</strong><br />

programs to directly access files on remote servers, including other <strong>2200</strong>s, Windows 98,<br />

Windows NT, Windows 2000, Windows XP, Windows 2003, Windows Vista, <strong>and</strong> Linux<br />

or UNIX systems running Samba. Other <strong>2200</strong>s must be running the 5R1 or higher level in<br />

order <strong>for</strong> the client to connect to them, due to enhanced security requirements of the<br />

client.<br />

Accessing a Remote System<br />

To access a remote system, you must use a URL-like remote path reference:<br />

//[[domain;]userid[:password]@][server][:port]/share[/path...]<br />

This remote path reference may be used in most of the <strong>CIFS</strong> APIs that use paths, such<br />

as open(), opendir(), stat(), <strong>and</strong> so on. It may not be used in APIs that implement purely<br />

server functions, such as share(), or ones that manipulate security attributes, such as<br />

chmod(). Likewise, a remote path reference can be used in most <strong>CIFS</strong>UT comm<strong>and</strong>s,<br />

since <strong>CIFS</strong>UT serves primarily as a front end to the <strong>CIFS</strong> APIs.<br />

The <strong>CIFS</strong> client obtains the user ID <strong>and</strong> password <strong>for</strong> the remote server from one of the<br />

following, in the order listed:<br />

1. The specified remote reference<br />

2. The most recent connection to the same remote server<br />

3. Environnent variables (<strong>CIFS</strong>$USER, <strong>CIFS</strong>$PW)<br />

4. The most recent connection to anywhere<br />

5. The user's <strong>OS</strong> <strong>2200</strong> credentials<br />

Only the first non-null source of credentials is used, although user ID <strong>and</strong> password are<br />

h<strong>and</strong>led independently (<strong>for</strong> example, the user ID could come from the URL, the<br />

password from the environment variable).<br />

7859 6137–009 7–1


<strong>CIFS</strong> Client<br />

Example<br />

For example, to list executable files in a directory on the <strong>OS</strong> <strong>2200</strong> system RS17FE from a<br />

run on another <strong>2200</strong> (inputs are in bold):<br />

>@cifsut<br />

<strong>CIFS</strong>UT 5R1Q1 (2003/Aug/18 13:30:20) 2003 Aug 18 Mon 15:24:16<br />

>dir \\crc:MYPASS@rs17fe\caldarale\testing\*.abs<br />

2003/07/09 17:13:26 25779384 jvmhssg..abs<br />

1994/12/30 10:19:04 3032 fasg..abs<br />

1986/10/02 16:01:42 97000 fed..abs<br />

2002/11/14 15:10:04 307560 hjavag..abs<br />

2003/05/02 07:45:56 563928 memtime..abs<br />

2003/07/23 08:17:16 1032424 uedit..abs<br />

or all files in a Windows 2000 directory:<br />

>set <strong>CIFS</strong>$USER=na;caldarcr<br />

>set <strong>CIFS</strong>$PW=myNetworkPassword<br />

>ls -l //USRV-CALDARCR.na.uis.unisys.com/c$/test-dir<br />

-rwxr-xr-x 0 1275904 2003/08/17 21:58:21 cifs$util..omn<br />

-rwxr-xr-x 0 3032 2003/08/17 12:01:32 fasg..abs<br />

or to copy a directory tree to another <strong>2200</strong>:<br />

>pwd<br />

/os<strong>2200</strong>/caldarale<br />

>cp -r stjdk //rs17fe/caldarale<br />

Note: If your user ID <strong>and</strong> password <strong>for</strong> the server are the same as those on the client,<br />

you can leave the environment variables blank <strong>and</strong> leave off the fields on the remote<br />

reference; the client credentials are used automatically.<br />

7–2 7859 6137–009


Using Passwords<br />

<strong>CIFS</strong> Client<br />

Passwords <strong>for</strong> the <strong>CIFS</strong> client are always case-sensitive, so you need to use uppercase<br />

to access most <strong>2200</strong>s. Also, <strong>CIFS</strong> environment variable names must always be specified<br />

in uppercase. The environment variable is preferred over specifying the password<br />

directly in the remote reference, since that minimizes the possibility of displaying a<br />

password when echoing the path <strong>for</strong> an error message.<br />

Note that passwords are never sent over the network by <strong>CIFS</strong>, unlike telnet <strong>and</strong> FTP.<br />

Instead, <strong>CIFS</strong> uses at a minimum NTLM authentication, which creates a hash value from<br />

the password, <strong>and</strong> then uses that hash value as an encryption key against a<br />

server-supplied r<strong>and</strong>om challenge. Only the result of that one-way encryption is sent to<br />

the server, which compares it with its own computation to determine whether to allow<br />

the connection.<br />

7859 6137–009 7–3


<strong>CIFS</strong> Client<br />

7–4 7859 6137–009


Section 8<br />

ZIPUT Processor<br />

ZIPUT is an <strong>OS</strong> <strong>2200</strong> comm<strong>and</strong> line utility that allows you to create, update, view, <strong>and</strong><br />

extract ZIP files on the <strong>2200</strong> mainframe. ZIPUT is written primarily in Java, <strong>and</strong> there<strong>for</strong>e<br />

requires that the Virtual Machine <strong>for</strong> the Java Plat<strong>for</strong>m (in<strong>for</strong>mally, JVM) product be<br />

installed on the system.<br />

Using the ZIPUT Processor<br />

Use the following syntax when using the ZIPUT processor.<br />

Format 1<br />

ZIPUT is normally called using the un<strong>for</strong>matted processor call technique. In this case, the<br />

<strong>for</strong>mat would be the following:<br />

or<br />

@'ZIPUT [options] ZipFileName [EntryName1 [EntryName2]...]<br />

@'ZIPUT -g ArgsPathName<br />

Format 2<br />

ZIPUT can also be called using st<strong>and</strong>ard ECL with an element name specifying the<br />

location of the ZIPUT arguments. For example:<br />

@ZIPUT [[[[qual]*]file].]elt[/ver]<br />

where [[[[qual]*]file].]elt[/ver] contains the following:<br />

[option1]<br />

[option2]<br />

...<br />

ZipFileName<br />

[EntryName1]<br />

[EntryName2]<br />

...<br />

7859 6137–009 8–1


ZIPUT Processor<br />

Upon termination, ZIPUT sets T3 of the run condition word to one of the following four<br />

values:<br />

0 – Execution completed normally<br />

1 – Warnings generated, but execution completed<br />

2 – Errors detected; some processing accomplished<br />

3 – Fatal condition encountered; execution halted<br />

The run condition word can be examined with @TEST in an ECL script.<br />

ZIPUT Arguments<br />

The basic syntax of the ZIPUT arguments is<br />

[options] ZipFileName [EntryName1 [EntryName2]...]<br />

The arguments can either be supplied on the same line if you are using the un<strong>for</strong>matted<br />

processor call technique, or on the line following the @XQT of ZIPUT. ZipFileName <strong>and</strong><br />

all EntryName parameters must be specified as <strong>CIFS</strong> pathnames. Each may be<br />

expressed as either an absolute path starting with a <strong>for</strong>ward slash (‘/’) character, or as a<br />

relative path without a leading <strong>for</strong>ward slash. For relative paths, the current working<br />

directory name (as shown by the <strong>CIFS</strong>$CD environment variable value) is inserted be<strong>for</strong>e<br />

the specified name when ZIPUT is locating any file.<br />

If ZipFileName does not end with a .zip or .*ar extension, .zip is added to the name<br />

automatically. This prevents overwriting of the first EntryName file, if the ZipFileName is<br />

accidentally omitted.<br />

Note: ZIPUT operates only on ZIP-based archive <strong>for</strong>mats, such as .jar, .war, .ear, <strong>and</strong><br />

Java EE .rar files; it cannot create or read files in Winrar or UNIX .tar <strong>and</strong> .ar <strong>for</strong>mats.<br />

Since the ZIPUT-created files must have an extension, they cannot be located at the<br />

/os<strong>2200</strong>// level of the directory tree, but rather must be somewhere below<br />

that in the hierarchy or not under /os<strong>2200</strong> at all.<br />

ZIPUT allows "*" <strong>and</strong> "?" characters to be used as masking characters. A "*'matches zero<br />

or more characters <strong>and</strong> a "?" matches any single character. Mask characters may appear<br />

in any component of an EntryName path.<br />

Basic Argument Syntax<br />

The options that use the basic argument syntax are as follows:<br />

-a<br />

The -a option adds the EntryName(s) to ZipFileName. Each entry name placed into<br />

ZipFileName is as specified on the call line. If an EntryName already exists in<br />

ZipFileName, it is updated. If the ZipFileName does not currently exist, it is created.<br />

If ZipFileName <strong>and</strong> at least one EntryName are specified without any of the -a, -d, -v,<br />

-g, or -u options, the -a option is assumed.<br />

8–2 7859 6137–009


-n<br />

ZIPUT Processor<br />

If this option is specified along with the -a option, then any EntryName placed in<br />

ZipFileName contains the full path name, even if the EntryName is specified as a<br />

relative path.<br />

-b<br />

If this option is specified along with the -a option, then any EntryNames placed in<br />

ZipFileName is added in binary <strong>for</strong>m.<br />

-d<br />

The -d option deletes the specified EntryName entries from ZipFileName. The entry<br />

name must be specified exactly as it is named in ZipFileName.<br />

-u<br />

The unzip option decompresses the entries contained in ZipFileName into <strong>CIFS</strong><br />

directories. Entries are not removed from ZipFileName. When no EntryName(s) are<br />

specified, all the files contained in ZipFileName are decompressed into <strong>CIFS</strong> files<br />

having the same names. If a <strong>CIFS</strong> file has the same name as an entry in<br />

ZipFileName, the <strong>CIFS</strong> file is overwritten. If the zip entry name does not contain a<br />

leading <strong>for</strong>ward slash character, the zip entry is decompressed into<br />

/.<br />

-v<br />

The view option displays the contents of ZipFileName. This view includes each<br />

EntryName, size, <strong>and</strong> modification time. If no EntryName(s) are specified, all entries<br />

in ZipFileName are displayed. The -v option must not be used with other options.<br />

-r<br />

This option causes recursion into subdirectories, <strong>and</strong> may only be used with the -a<br />

option. The starting directory is specified as part of each EntryName. For example, if<br />

the following options are specified<br />

-a -n -r /a/b/c/x.y z.txt bbb/ccc/w.class<br />

the directory in which the search <strong>for</strong> x.y begins is /a/b/c. If the specified path is<br />

relative, the current working directory (as indicated by the <strong>CIFS</strong>$CD environment<br />

variable) is prefixed to the specified path to determine where to begin the search.<br />

The directory in which the search <strong>for</strong> z.txt starts is the current working directory; the<br />

starting directory <strong>for</strong> the search <strong>for</strong> w.class is<br />

-q<br />

/bbb/ccc<br />

If this option (quiet mode) is specified, then no file addition, deletion, or<br />

decompression messages are displayed to st<strong>and</strong>ard output.<br />

7859 6137–009 8–3


ZIPUT Processor<br />

Additional Syntax<br />

Arguments using a different syntax are as follows:<br />

-e compression_level<br />

This option allows you to set the compression level when adding to ZipFileName.<br />

The compression_level can be a number from 0 to 9, where 9 gives the strongest<br />

<strong>and</strong> slowest level of compression, <strong>and</strong> 0 results in no compression.<br />

-z SourceZipFile<br />

Indicates that entries added to ZipFileName are taken from the specified ZIP file<br />

rather than the <strong>CIFS</strong> file system. May only be used when the -a option is in effect.<br />

This option allows the merging of ZIP files without having to exp<strong>and</strong> them first.<br />

-g ArgsPathName1 [ArgsPathName2 [ArgsPathName3 ]... ]<br />

The -g option processes the arguments contained in each ArgsPathName. The -g<br />

option must be the only option on the comm<strong>and</strong> line. Each ArgsPathName may be<br />

expressed as either an absolute or relative path. Within each ArgsPathName,<br />

multiple arguments are allowed, but each argument must be on a separate line<br />

(leading spaces are ignored).<br />

-h<br />

The help option displays all ZIPUT options <strong>and</strong> parameters <strong>and</strong> a short description of<br />

what each option does. If no other options or names are specified on the call line,<br />

the -h option is assumed. The -h option must be the only option on the comm<strong>and</strong><br />

line.<br />

Multiple compatible options may be grouped together (<strong>for</strong> example, -ar); however, when<br />

used, the e-, g-, or z-option must be the last in any such group.<br />

8–4 7859 6137–009


Section 9<br />

Administration<br />

<strong>CIFS</strong> is installed with SOLAR <strong>and</strong> becomes active when the associated background run<br />

initializes the shared subsystem component. The /os<strong>2200</strong> directory is initially populated<br />

during the first execution of the background run. After initial population, <strong>CIFS</strong> monitors<br />

system log entries as described below (see “Directory Synchronization”) to keep the<br />

/os<strong>2200</strong> directory in sync with the Exec MFD directories.<br />

Administrative tasks include:<br />

• Setting system environment variables.<br />

• Ensuring that <strong>CIFS</strong>-BACK is running at all times.<br />

• Running <strong>CIFS</strong>-POP as needed.<br />

• Stopping <strong>CIFS</strong> if necessary, using <strong>CIFS</strong>-DEACT or the E <strong>CIFS</strong>B keyin.<br />

In<strong>for</strong>mation about per<strong>for</strong>ming each action is provided below.<br />

<strong>CIFS</strong> Installation Overview<br />

At <strong>CIFS</strong> installation time, the following elements are placed in SYS$LIB$*<strong>CIFS</strong>$LIB:<br />

• <strong>CIFS</strong>-BACK (runstream element <strong>for</strong> Monitor Services <strong>and</strong> network access)<br />

• <strong>CIFS</strong>-POP (runstream element <strong>for</strong> Populate)<br />

• <strong>CIFS</strong>-DEACT (runstream to deactivate the <strong>CIFS</strong> subsystem <strong>and</strong> stop <strong>CIFS</strong>B)<br />

• <strong>CIFS</strong>-BACK-Z (object module <strong>for</strong> Monitor Services <strong>and</strong> network access)<br />

• <strong>CIFS</strong>-POP-Z (object module <strong>for</strong> Populate)<br />

• <strong>CIFS</strong>-DEACT-Z (object module <strong>for</strong> deactivating the <strong>CIFS</strong> subsystem)<br />

In addition, the following elements are placed in the file SYS$LIB$*RUN$:<br />

• <strong>CIFS</strong>-BACK (runstream element <strong>for</strong> Monitor Services <strong>and</strong> network access)<br />

• <strong>CIFS</strong>-POP (runstream element <strong>for</strong> Populate)<br />

• <strong>CIFS</strong>-DEACT (runstream to deactivate the <strong>CIFS</strong> subsystem <strong>and</strong> stop <strong>CIFS</strong>B)<br />

Also, the following @START image is placed in SYS$LIB$*RUN$.AUTO$START:<br />

@START SYS$LIB$*RUN$.<strong>CIFS</strong>-BACK,,,<br />

7859 6137–009 9–1


Administration<br />

Notes:<br />

• The “” used on this @START image can be specified by SOLAR SGS<br />

statements during installation. Use the SOLAR SGSs,<br />

DEFAULT_RUNSTREAM_ACCOUNT <strong>and</strong> DEFAULT_RUNSTREAM_USERID, to<br />

specify the account/user ID on the @START images.<br />

• The / of <strong>CIFS</strong>-BACK <strong>and</strong> <strong>CIFS</strong>-POP requires<br />

− ER MODPS$ capability<br />

− Real-time capability<br />

• The account used must allow access by the subsystem user ID, if<br />

QUOTA_ENFORCEMENT_BY_USERID = TRUE. (See “<strong>CIFS</strong> Subsystem <strong>User</strong> ID” in<br />

this section.)<br />

• The run ID used by <strong>CIFS</strong>-BACK runstream is <strong>CIFS</strong>B.<br />

• The run ID used by the Populate run, automatically started by <strong>CIFS</strong>B, is <strong>CIFS</strong>P.<br />

• The user ID <strong>for</strong> <strong>CIFS</strong>-DEACT must have read <strong>and</strong> write access to<br />

SYS$LIB$*<strong>CIFS</strong>$SS <strong>and</strong> MODPS$ capability.<br />

• For Fundamental Security systems, the site administrator must modify the <strong>CIFS</strong>-<br />

DEACT runstream to include any keys used <strong>for</strong> assignment of the subsystem file.<br />

• If the Exec configuration tag APL_BANK_BDI_GT4K is set to TRUE, <strong>CIFS</strong> allocates its<br />

application level data banks from the bank descriptor index range above 4095. This<br />

reduces the impact on relatively scarce “low” BDIs.<br />

• The <strong>CIFS</strong> background run must be used to initialize the subsystem. All other<br />

requests to the subsystem are held until the background run has completed<br />

initialization.<br />

Directory Synchronization<br />

<strong>CIFS</strong> monitors the system log entries <strong>for</strong> purposes of keeping the <strong>CIFS</strong> directories<br />

synchronized with the Exec Master File Directories (MFDs). Specifically, <strong>CIFS</strong> retrieves<br />

the following entries from the system log, through Monitor Services (MSCP):<br />

• 403 - fixed file @ASG, @FREE, or @CAT<br />

• 407 - removable file @ASG, @FREE, or @CAT<br />

• 807 - ER SUMOD$ (file attributes change)<br />

As a result, every file that is cataloged, deleted, or has its accessibility changed in an<br />

Exec MFD automatically causes the associated update in the <strong>CIFS</strong> directories. These are<br />

additional considerations:<br />

• The original contents of the /os<strong>2200</strong> directory in <strong>CIFS</strong> is created from the Exec MFDs<br />

when <strong>CIFS</strong> is initialized or reloaded (through the <strong>CIFS</strong>-POP runstream). This retrieval<br />

of the current MFD in<strong>for</strong>mation is termed Populate.<br />

• Files in the shared MFD that are created on a file sharing host other than where <strong>CIFS</strong><br />

is running cannot be immediately detected by <strong>CIFS</strong>, because a log entry is not<br />

currently created on the other participating hosts.<br />

9–2 7859 6137–009


Administration<br />

• Changes in public <strong>and</strong> private accessibility <strong>for</strong> unowned files are not monitored by<br />

<strong>CIFS</strong>. The <strong>CIFS</strong> <strong>and</strong> Exec directories is resynchronized the next time <strong>CIFS</strong>-POP is<br />

run, <strong>and</strong> direct references to the file created on the other host also causes its<br />

inclusion in the <strong>CIFS</strong> file hierarchy.<br />

• Files that are deleted by F-cycling, <strong>for</strong> example @CYCLE, are not monitored.<br />

• Files introduced or removed with removable pack file registration <strong>and</strong> deregistration<br />

are not monitored.<br />

During initialization, <strong>CIFS</strong> per<strong>for</strong>ms the following processing to insure its directories are<br />

up to date:<br />

• The <strong>CIFS</strong>-BACK runstream (automatically started at Exec reboot) initializes system<br />

log monitoring through MSCP.<br />

• The <strong>CIFS</strong>-POP runstream is started by <strong>CIFS</strong> through @START,A/X to per<strong>for</strong>m the<br />

Populate process. This runstream is started even if <strong>CIFS</strong>-BACK fails to connect with<br />

MSCP.<br />

• While Populate is running, log entry processing <strong>for</strong> status changes to existing files<br />

are deferred until Populate completes, because such files might not yet have been<br />

entered into the <strong>CIFS</strong> directory by Populate. That is, if a file was cataloged when<br />

<strong>CIFS</strong> was not active or not connected to Monitor Services, then Populate finds out<br />

<strong>and</strong> enter it into the <strong>CIFS</strong> directories. However, file accessibility changes (such as<br />

from public to private) cannot be processed until Populate completes its<br />

synchronization.<br />

If <strong>CIFS</strong>-BACK is not running properly, the <strong>CIFS</strong> directory cannot be synchronized with the<br />

Exec MFD. Viewing /os<strong>2200</strong> files with <strong>CIFS</strong> might result in the display of files that have<br />

been deleted from the Exec MFD, or recently cataloged Exec files might not be<br />

displayed.<br />

The <strong>CIFS</strong>-BACK background run breakpoints its output to SYS$<strong>CIFS</strong>$*BACK-BRKPT. If<br />

the <strong>CIFS</strong>-BACK run errors, this file might contain useful diagnostic in<strong>for</strong>mation.<br />

Scanning a <strong>CIFS</strong> directory associated with a rolled out or exclusively assigned program<br />

file does not result in an error or initiation of a ROLBAK request <strong>for</strong> the file. However,<br />

<strong>CIFS</strong> can return outdated directory entries if the file was modified between the last time<br />

it was accessed through <strong>CIFS</strong> <strong>and</strong> the time when it became unavailable. <strong>CIFS</strong><br />

automatically updates the directory entries when the program file is again available<br />

during a <strong>CIFS</strong> access.<br />

7859 6137–009 9–3


Administration<br />

<strong>CIFS</strong> Subsystem <strong>User</strong> ID<br />

Populate<br />

The user ID of the <strong>CIFS</strong> subsystem must have the following properties:<br />

• On Fundamental systems, the user ID must be the Security Officer.<br />

• On Security Option 1 or higher, the SERVE$ <strong>and</strong> MODPS$ ERs are required as well<br />

as these privileges:<br />

− SSAUTHNTICAT<br />

− SSBAFC<br />

− SSBPFC<br />

− SSBYPASSOWNR<br />

− SSCONSOLE<br />

− SSDRG<br />

− SSGAP<br />

− SSLASH<br />

− SSMROOC<br />

− SSRUNXOPT<br />

• On Security Option 1 or higher, the subsystem user ID must not have the SSBROD<br />

privilege.<br />

• On Security Option 1 or higher, the subsystem user ID must not be set to create<br />

unowned files.<br />

• If QUOTA_ENFORCEMENT_BY_USERID = TRUE, then the account used on the<br />

<strong>CIFS</strong>-BACK run must be accessible by the subsystem user ID.<br />

• Clearance Level must not have a range. That is, the minimum <strong>and</strong> maximum<br />

clearance levels must be the same; <strong>for</strong> example, 0 to 0, or 20 to 20.<br />

• Compartment Set must be NULL. Compartments are not supported.<br />

The process of updating the <strong>CIFS</strong> directories with in<strong>for</strong>mation from the Exec master file<br />

directories is called Populate. This process is run every time the <strong>CIFS</strong>-BACK runstream is<br />

executed, thereby synchronizing the two sets of directories.<br />

Unless Populate is explicitly disabled, it runs <strong>for</strong> every two hours during the time when<br />

Monitor Services is not available.<br />

Populate can also be run at any time, independently of the <strong>CIFS</strong>-BACK runstream, by<br />

using the following console ST keyin:<br />

ST <strong>CIFS</strong>-POP,,,<br />

where the can be the same as used <strong>for</strong> <strong>CIFS</strong>-BACK. On Security Option<br />

1 systems, the only attribute required is ER MODPS$.<br />

9–4 7859 6137–009


Administration<br />

The Populate background run breakpoints its output to SYS$<strong>CIFS</strong>$*POP-BRKPT.<br />

In<strong>for</strong>mation on the number of files populated is written to this file, as well as any errors<br />

that occur.<br />

When Populate fails to start automatically, the <strong>CIFS</strong>-BACK run issues the following<br />

message:<br />

*ERROR* The <strong>CIFS</strong>-POP run failed to start: status.<br />

The <strong>CIFS</strong> directory will not be in sync with the Exec MFD.<br />

<strong>CIFS</strong> warning issued above. Answer OK<br />

where status is the 12-digit octal ACSF$ value returned by the @START attempt. On<br />

systems running with Security Option 1 or higher, the likely cause is that the <strong>CIFS</strong><br />

background run user ID does not have the SSRUNXOPT privilege.<br />

If the Populate run encounters an error, the following console message is displayed:<br />

*ERROR* the <strong>CIFS</strong>-POP run has failed.<br />

The <strong>CIFS</strong> directory will not be in synch with the Exec MFD.<br />

Diagnostics can be found in file SYS$<strong>CIFS</strong>$*<strong>CIFS</strong>$TRACE$$.<br />

<strong>CIFS</strong> warning issued above. Answer OK<br />

Starting the <strong>CIFS</strong> Background Run<br />

Be<strong>for</strong>e you start <strong>CIFS</strong>-BACK, MSCP must be running. Additionally, to enable the network<br />

access you must enable the desired Communications Application Program Interface<br />

modes <strong>and</strong> either CMS 1100 or Communications Plat<strong>for</strong>m (or both).<br />

<strong>CIFS</strong> displays a console message if MSCP is not active, since accuracy of the /os<strong>2200</strong><br />

directory hierarchy is not assured without MSCP. <strong>CIFS</strong> does not display a message if<br />

communication with the network cannot be established, but it does automatically retry<br />

connecting with the selected Communications Application Program Interface<br />

subsystems (one or more) every 30 seconds.<br />

The following console keyin is used to activate the <strong>CIFS</strong> background run:<br />

ST <strong>CIFS</strong>-BACK,,,<br />

Use the 1 in the SETC value field of the ST keyin to <strong>for</strong>ce <strong>CIFS</strong> directory verification. See<br />

the V option under <strong>CIFS</strong> Background Run Options <strong>for</strong> more in<strong>for</strong>mation.<br />

The account <strong>and</strong> user ID <strong>for</strong> the <strong>CIFS</strong>-BACK run require the following attributes:<br />

• On Fundamental Security systems, the security officer user ID must be used <strong>for</strong> the<br />

runstreams.<br />

• On Security Option 1 or higher, the following attributes are required:<br />

− Must have the capability to per<strong>for</strong>m ER MODPS$<br />

− Must have the SSCONSOLE <strong>and</strong> SSRUNXOPT privileges<br />

7859 6137–009 9–5


Administration<br />

− Must have real-time capability of level 30 or better (a value less than or equal to<br />

30)<br />

− Must not have the SSBROD privilege<br />

− Must not be set to create unowned files.<br />

Note: The account used on the <strong>CIFS</strong>-BACK run must be usable by the <strong>CIFS</strong><br />

subsystem user ID, if the configuration parameter,<br />

QUOTA_ENFORCEMENT_BY_USERID, is TRUE.<br />

At system recovery, this run must be allowed out of backlog.<br />

To determine the status of the <strong>CIFS</strong> background run, per<strong>for</strong>m an RC keyin (RC <strong>CIFS</strong>B).<br />

The response must indicate realtime (R/T) mode, not BATCH mode. However, during<br />

directory verification <strong>CIFS</strong>B is in batch mode.<br />

H<strong>and</strong>ling Errors from the <strong>CIFS</strong> Background Run<br />

The following are some of the error conditions that can occur during the <strong>CIFS</strong><br />

background run, including those related to Monitor Services:<br />

• If the account attributes of the background run do not allow real-time capability, the<br />

following console message is displayed:<br />

*ERROR* <strong>CIFS</strong> background run is running with account number nnnnnn<br />

that does not permit real-time priority. The <strong>CIFS</strong> background run<br />

requires real-time priority to access MSCP, which is needed to<br />

synchronize <strong>CIFS</strong> directories with the Exec Master File Directory.<br />

Should <strong>CIFS</strong> Exit or run Without Monitor Services? (Exit, Without)<br />

The <strong>CIFS</strong> subsystem is not functional until the message is answered. Responding<br />

with “Exit” causes the background run to terminate <strong>and</strong> leaves the subsystem<br />

disabled. Answering “Without” allows <strong>CIFS</strong> to function, but without real-time<br />

synchronization of the MFD <strong>and</strong> <strong>CIFS</strong> directories.<br />

• If MSCP is not accessible, the following console message is displayed:<br />

*ERROR* <strong>CIFS</strong> has detected that Monitor Services (MSCP)<br />

is not responsive. MSCP is needed to synchronize the <strong>CIFS</strong><br />

directories with the Exec Master File Directory.<br />

Should <strong>CIFS</strong> Retry or Disable Monitor Services? (Retry, Disable)<br />

A “Retry” response causes a 5-second delay <strong>and</strong> another attempt to register with<br />

MSCP; the preceding message is repeated every five minutes if necessary. A<br />

“Disable” response causes <strong>CIFS</strong> to stop attempting to connect to MSCP until the<br />

next time the <strong>CIFS</strong> background run is started.<br />

9–6 7859 6137–009


Administration<br />

• If <strong>CIFS</strong> is unable to process log entries from MSCP quickly enough, the following<br />

message is displayed:<br />

*WARNING* <strong>CIFS</strong> is not running as expected.<br />

<strong>CIFS</strong> filled log queue buffer b with n entries.<br />

Log monitoring will continue, but the <strong>CIFS</strong> directory<br />

may not reflect Exec file changes until these queued<br />

entries are processed.<br />

This indicates that adequate processing resources are not available.<br />

• If <strong>CIFS</strong> needs to use the Security Server <strong>and</strong> it has not been created (a normal part of<br />

the <strong>CIFS</strong>-BACK initialization), the following message is displayed:<br />

*WARNING* <strong>CIFS</strong> has detected that its background run <strong>CIFS</strong>B is not active.<br />

This run is required to process file security access checks.<br />

Please start the background run using:<br />

ST <strong>CIFS</strong>-BACK,,,/<br />

Answer: Retry, after <strong>CIFS</strong>B is running, or<br />

Error, to error all callers of <strong>CIFS</strong><br />

<strong>CIFS</strong> warning displayed above. (Retry, Error)<br />

Stopping the <strong>CIFS</strong> Subsystem <strong>and</strong> Background Run<br />

There are several ways to stop the <strong>CIFS</strong> background run:<br />

• Use the <strong>CIFS</strong> DEACT keyin to shut down <strong>CIFS</strong><br />

• Use the ST keyin to shut down <strong>CIFS</strong>.<br />

• Use the <strong>CIFS</strong> TERM keyin to stop the background run only.<br />

• Use the E keyin to stop the background run only.<br />

Stopping <strong>CIFS</strong> with the <strong>CIFS</strong> DEACT Keyin (Normal Shutdown<br />

Procedure)<br />

To stop the background run (<strong>CIFS</strong>B), deactivate the <strong>CIFS</strong> subsystem, <strong>and</strong> close the <strong>CIFS</strong><br />

trace file; then enter the following keyin:<br />

<strong>CIFS</strong>-DEACT<br />

Stopping <strong>CIFS</strong> with the ST Keyin (Alternate Shutdown Procedure)<br />

To stop the background run (<strong>CIFS</strong>B), deactivate the <strong>CIFS</strong> subsystem, <strong>and</strong> generate the<br />

<strong>CIFS</strong> trace file; then enter the following keyin:<br />

ST <strong>CIFS</strong>-DEACT,,,<br />

If the user ID used on the ST keyin does not have access to the SYS$LIB$*<strong>CIFS</strong>$SS file,<br />

the following console message is displayed:<br />

*ERROR* <strong>User</strong>id does not have read & write access to SYS$LIB$*<strong>CIFS</strong>$SS.<br />

Start <strong>CIFS</strong>-DEACT with a privileged userid. Answer OK<br />

7859 6137–009 9–7


Administration<br />

Note that <strong>CIFS</strong> maintains an internal trace area, which is written to disk when<br />

<strong>CIFS</strong>-DEACT is run. The file name used to hold this trace data is<br />

SYS$<strong>CIFS</strong>$*<strong>CIFS</strong>$TRACE$$.<br />

Stopping <strong>CIFS</strong>B with the <strong>CIFS</strong> TERM<br />

If the background run, <strong>CIFS</strong>B, needs to be stopped, enter the following keyin:<br />

<strong>CIFS</strong> TERM<br />

This causes the background run to fin, but it does not deactivate the <strong>CIFS</strong> subsystem. All<br />

network access <strong>and</strong> system log monitoring are suspended, as is access to private files<br />

on Fundamental Security systems. The background run can be restarted later in the<br />

normal fashion.<br />

If this keyin does not succeed, try the method using the E keyin.<br />

Stopping <strong>CIFS</strong>B with the E Keyin<br />

If the background run, <strong>CIFS</strong>B, needs to be stopped, enter the following keyin:<br />

E <strong>CIFS</strong>B<br />

This causes the background run to fin, but it does not deactivate the <strong>CIFS</strong> subsystem. All<br />

network access <strong>and</strong> system log monitoring are suspended, as is access to private files<br />

on Fundamental Security systems. The background run can be restarted later in the<br />

normal fashion.<br />

<strong>CIFS</strong> Background Run Options<br />

Various options can be used on the background run executable <strong>CIFS</strong>-BACK-Z to control<br />

its operation. These options are<br />

K Inhibit use of network authentication even when all of the<br />

prerequisites <strong>for</strong> network authentication are met.<br />

M Inhibit execution of the Monitor Services interface.<br />

N Disable network access.<br />

P Inhibit starting the <strong>CIFS</strong>-POP runstream.<br />

Q Prevent use of queue banks <strong>for</strong> network communications.<br />

S Inhibit execution of the security server.<br />

T Inhibit execution of the timer activity.<br />

V Per<strong>for</strong>m directory verification when <strong>CIFS</strong> is started.<br />

None of these options should be used during normal <strong>CIFS</strong> operation. The V-option can be<br />

used to correct suspected inconsistencies in the <strong>CIFS</strong> directory structure that might<br />

result from system errors; however, it might take an hour or more to run in a large file<br />

system, <strong>and</strong> <strong>CIFS</strong> is unusable <strong>for</strong> that time period.<br />

9–8 7859 6137–009


<strong>CIFS</strong> Background Run Console Keyins<br />

Administration<br />

<strong>CIFS</strong> includes a console keyin h<strong>and</strong>ler that provides the following unsolicited console<br />

keyins:<br />

• <strong>CIFS</strong> BRKPT – @BRKPT the background run print file to a new cycle of<br />

SYS$<strong>CIFS</strong>$*BACK-BRKPT; requires display console capability.<br />

• <strong>CIFS</strong> DEACT – Deactivates the <strong>CIFS</strong> subsystem <strong>and</strong> stops the background run<br />

without taking a dump of the subsystem; requires response console capability.<br />

• <strong>CIFS</strong> ERROR – Deactivates the <strong>CIFS</strong> subsystem with a dump written to the trace<br />

file, <strong>and</strong> stops the background run; requires response console capability.<br />

• <strong>CIFS</strong> HELP – Displays this list of keyins; requires basic console capability.<br />

• <strong>CIFS</strong> STATUS – Displays the installed <strong>CIFS</strong> version in<strong>for</strong>mation <strong>and</strong> the availability of<br />

network authentication.<br />

• <strong>CIFS</strong> TERM – Per<strong>for</strong>ms an orderly shutdown of the <strong>CIFS</strong> background run.<br />

• <strong>CIFS</strong> TRACE – Displays or alters the internal trace flag settings. The set of trace flags<br />

that can be manipulated is subject to change at any time. Modifying the default<br />

settings can impact per<strong>for</strong>mance <strong>and</strong> must be done judiciously.<br />

To see current trace settings, enter<br />

<strong>CIFS</strong> TRACE<br />

To see all the possible trace flags, enter<br />

<strong>CIFS</strong> TRACE ?<br />

To change trace flags, enter<br />

<strong>CIFS</strong> TRACE [+|-] [flag2]...<br />

The following is a list of modifiers that can be used along with their descriptions:<br />

+ The flags are added to the existing set<br />

- The flags are removed from the existing set<br />

Neither + nor - The specified flags replaces the existing set<br />

To clear all trace flags, enter:<br />

<strong>CIFS</strong> TRACE 0<br />

Note: The PRINT trace flag sends all trace output to the PRINT$ file <strong>and</strong> the circular<br />

internal trace buffer. This can have a significant impact on per<strong>for</strong>mance so do not leave<br />

the trace flags set <strong>for</strong> an extended period of time. The <strong>CIFS</strong> BRKPT keyin closes the<br />

current PRINT$ file (SYS$<strong>CIFS</strong>$*BACK-BRKPT) <strong>and</strong> starts a new cycle. None of the<br />

keyins are case-sensitive.<br />

7859 6137–009 9–9


Administration<br />

<strong>CIFS</strong> Backup Procedure<br />

The following files contain the internal data structures used by <strong>CIFS</strong> to manage the file<br />

system. It is critical that these files be saved together if a FAS-like backup procedure is<br />

used. If any of the files must be restored <strong>for</strong> any reason, restore all of them to insure the<br />

integrity of the file system. The files are<br />

SYS$<strong>CIFS</strong>$*<strong>CIFS</strong>$KERNEL$<br />

SYS$<strong>CIFS</strong>$*00030000600x<br />

SYS$<strong>CIFS</strong>$*00030000700x<br />

SYS$<strong>CIFS</strong>$*00030000900x<br />

SYS$<strong>CIFS</strong>$*00030000A00x<br />

SYS$<strong>CIFS</strong>$*00030000B00x<br />

SYS$<strong>CIFS</strong>$*00030000C00x<br />

where x is a hexadecimal digit used to guarantee uniqueness. It is normally 0. For <strong>CIFS</strong><br />

level 2R2 or later installed over level 1R1, the SYS$<strong>CIFS</strong>$*00030000B00x file is no<br />

longer used. For new <strong>CIFS</strong> level 2R2 or later installations, the<br />

SYS$<strong>CIFS</strong>$*00030000C00x file is not present.<br />

<strong>CIFS</strong> might create additional system files <strong>for</strong> sites with large numbers of directories. The<br />

<strong>CIFS</strong>UT backup -f comm<strong>and</strong> can be used to generate the FAS comm<strong>and</strong>s needed to<br />

save all <strong>CIFS</strong> system files.<br />

These files are assigned to <strong>and</strong> being updated by the <strong>CIFS</strong> subsystem whenever it is<br />

active. Consequently, if a FAS backup is used, the subsystem must be taken down<br />

during the backup procedure. As an alternative to FAS, use the <strong>CIFS</strong>UT backup<br />

comm<strong>and</strong> without the -f option to record the <strong>CIFS</strong> directory structure in a symbolic <strong>for</strong>m.<br />

This backup in<strong>for</strong>mation can then be used as input to <strong>CIFS</strong>UT to restore the directory<br />

structure. However, in a large file system, the backup comm<strong>and</strong> can take quite some<br />

time to run, <strong>and</strong> it can produce a large amount of output. In these cases, using the -f<br />

option on the backup comm<strong>and</strong> is the only recourse.<br />

9–10 7859 6137–009


<strong>CIFS</strong> File Security En<strong>for</strong>cement<br />

Administration<br />

<strong>CIFS</strong> relies on <strong>OS</strong> <strong>2200</strong> to per<strong>for</strong>m security policy en<strong>for</strong>cement. <strong>OS</strong> <strong>2200</strong> security<br />

privileges can be used to override this policy en<strong>for</strong>cement; <strong>for</strong> example, <strong>CIFS</strong> ignores any<br />

ACR-imposed access restrictions <strong>for</strong> user IDs with the Bypass ACR Evaluation privilege.<br />

<strong>CIFS</strong>, however, does en<strong>for</strong>ce an additional security policy, namely file permission bits.<br />

<strong>CIFS</strong> provides a privileged mode capability to override all <strong>CIFS</strong> security policy<br />

en<strong>for</strong>cement. This privileged mode is invoked by the caller having read <strong>and</strong> write access<br />

to the <strong>CIFS</strong> subsystem file, SYS$LIB$*<strong>CIFS</strong>$SS. In Fundamental Security systems, the<br />

caller must have the subsystem file assigned with the proper read/write keys prior to<br />

calling <strong>CIFS</strong>. In Security Option 1 <strong>and</strong> above, the caller must be able to pass an ER<br />

SUVAL$ security check <strong>for</strong> read <strong>and</strong> write access to the file; the caller does not need to<br />

have the file assigned.<br />

To ensure only appropriate personnel have <strong>CIFS</strong> privileged mode capability, the <strong>CIFS</strong><br />

subsystem file must be protected by read/write keys on Fundamental Security systems<br />

or by an ACR on Security Option 1 <strong>and</strong> above. The default SOLAR install of <strong>CIFS</strong> cannot<br />

attach keys or an ACR to the subsystem file.<br />

When supported by the Exec, accesses through <strong>CIFS</strong> to all owned files <strong>and</strong> any<br />

unowned files with ACRs attached are logged in type 801, subtype 0, error type 060<br />

entries. The logged in<strong>for</strong>mation includes the filename, type of access, time of access,<br />

<strong>and</strong> caller’s user ID, among other in<strong>for</strong>mation.<br />

<strong>CIFS</strong> <strong>and</strong> Clearance Levels / Compartment Sets<br />

<strong>CIFS</strong> is designed to work with only a single clearance level <strong>and</strong> single compartment set.<br />

When installed as documented in Appendix A of <strong>OS</strong> <strong>2200</strong> Software Products Installation<br />

Guide, the <strong>CIFS</strong> subsystem runs without privilege to bypass either clearance level or<br />

compartment set validation.<br />

Although Table A-3 of the <strong>OS</strong> <strong>2200</strong> Software Products Installation Guide indicates a<br />

clearance level range of 0 to 0, the user ID can be set up with any clearance level if the<br />

minimum <strong>and</strong> maximum clearance levels are the same. <strong>CIFS</strong> can then only be able to<br />

access files that have that specific clearance level.<br />

Likewise, this table shows a compartment set of NULL. The <strong>CIFS</strong> subsystem user ID<br />

can be given any set of compartments, but <strong>CIFS</strong> can then only be able to access files<br />

with that set of compartments.<br />

7859 6137–009 9–11


Administration<br />

<strong>CIFS</strong> Network Access Security<br />

To access <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong> through a network connection, the background run must be<br />

active (without the N option), <strong>and</strong> a valid <strong>OS</strong> <strong>2200</strong> host user ID <strong>and</strong> password<br />

combination must be used to establish the connection.<br />

For <strong>CIFS</strong> levels prior to 6R2, the user ID passed to <strong>CIFS</strong> must be a valid <strong>OS</strong> <strong>2200</strong> user ID<br />

<strong>and</strong> it must be authenticated with its matching <strong>OS</strong> <strong>2200</strong> password.<br />

Beginning with <strong>CIFS</strong> level 6R2, <strong>CIFS</strong> accepts either <strong>OS</strong> <strong>2200</strong> user IDs or Windows<br />

network user IDs if network authentication is configured through Messaging Integration<br />

Services (NTSI). NTSI maps the network user ID to an <strong>OS</strong> <strong>2200</strong> user ID once it has<br />

authenticated the network user ID.<br />

<strong>CIFS</strong> supports both network <strong>and</strong> local authentication concurrently <strong>and</strong> transparently to<br />

allow easy migration to the use of network authentication, while minimizing impact to<br />

customers that do not wish to migrate. If all of the prerequisites <strong>for</strong> network<br />

authentication are met, <strong>CIFS</strong> first attempts network authentication; if network<br />

authentication fails, <strong>CIFS</strong> automatically tries local NTLM or NTLMv2 authentication.<br />

The prerequisites <strong>for</strong> network authentication are<br />

• Flexible <strong>User</strong> Authentication (FLEX, or <strong>User</strong> Authentication) is installed <strong>and</strong> the ASIS<br />

background run is running.<br />

• NTSI (Messaging Integration Services) Mode A is installed <strong>and</strong> configured.<br />

The <strong>CIFS</strong> background run automatically detects the installation status of FLEX <strong>and</strong> NTSI<br />

on startup. The K execute option can be specified on the @XQT of the background run<br />

executable <strong>CIFS</strong>-BACK-Z to inhibit use of network authentication even when all of the<br />

prerequisites are met.<br />

The current status of <strong>CIFS</strong> network authentication can be found by using the <strong>CIFS</strong><br />

STATUS console keyin. This keyin displays either<br />

− Network authentication is available<br />

− Network authentication is not available<br />

If network authentication is not available when the <strong>CIFS</strong> background run is initially<br />

started, the background run must be shut down <strong>and</strong> restarted to detect a change in<br />

network authentication availability.<br />

9–12 7859 6137–009


Local <strong>OS</strong> <strong>2200</strong> Authentication<br />

Administration<br />

A valid <strong>OS</strong> <strong>2200</strong> host user ID <strong>and</strong> password combination must be used to establish the<br />

connection. For access through Windows 95/98/Me, the user must also log onto the<br />

workstation with the <strong>OS</strong> <strong>2200</strong> user ID, since those plat<strong>for</strong>ms do not support separate<br />

workstation <strong>and</strong> network user IDs. The workstation password need not be the same as<br />

the <strong>OS</strong> <strong>2200</strong> host password.<br />

Passwords are not sent over the network. In <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> Release 7.1 <strong>and</strong> higher,<br />

long passwords (up to 18 characters) are supported, <strong>and</strong> passwords are saved in hashed<br />

<strong>for</strong>m. The hash key is computed whenever a password is created or changed. When a<br />

user attempts to sign on, <strong>CIFS</strong> uses the hash key to generate an authentication key, <strong>and</strong><br />

then uses the authentication key to verify the user’s password.<br />

In releases lower than 7.1, <strong>CIFS</strong> uses the saved plain-text password (up to 6 characters<br />

long) to generate an encryption key on a challenge string supplied to the client by the<br />

SMB server within <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong>. The <strong>CIFS</strong> client sends the plain-text user ID <strong>and</strong> the<br />

encrypted challenge to the server, where the encrypted value is compared to the one<br />

calculated by the server.<br />

(For more in<strong>for</strong>mation, see “About Authentication <strong>and</strong> Passwords,” below.)<br />

There are Windows registry settings that defeat encryption <strong>and</strong> result in the client<br />

sending plain-text passwords over the network; this is not supported by <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong>.<br />

For Windows 95/98/Me, the offending registry key is<br />

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Service\VxD\Vnetsup<br />

For Windows NT4, the key is<br />

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Rdr\Parameters<br />

For Windows 2000, XP, 2003, <strong>and</strong> Vista, the key is<br />

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkStation\Parameters<br />

Ensure that either the registry key does not exist, or the value of<br />

EnablePlainTextPassword under the key is zero. (The key <strong>and</strong> value names are not<br />

case-sensitive.)<br />

7859 6137–009 9–13


Administration<br />

Network Authentication<br />

Messaging Integration Services (NTSI) allows authentication against a Windows domain.<br />

A user logged on at a workstation to a Windows domain can be authenticated to <strong>CIFS</strong><br />

using its Windows user name <strong>and</strong> credentials without having to enter a separate user ID<br />

<strong>and</strong> password. NTSI supports authentication through both Kerberos <strong>and</strong> NTLM.<br />

<strong>2200</strong> Network Authentication is a Messaging Integration Services feature that allows<br />

network users to be authenticated <strong>for</strong> access to an <strong>OS</strong> <strong>2200</strong> server against a Windows<br />

domain instead of against the local <strong>OS</strong> <strong>2200</strong> security database. An <strong>OS</strong> <strong>2200</strong> Network<br />

Authentication adapter supplied by Unisys running under the <strong>OS</strong> <strong>2200</strong> computer name<br />

authenticates the network users on the Windows server using the Windows Security<br />

Domain model instead of on the <strong>OS</strong> <strong>2200</strong> server.<br />

To use network authentication with <strong>CIFS</strong>, the <strong>User</strong> Authentication product must be<br />

installed <strong>and</strong> the NTSI product must be installed <strong>and</strong> configured. See the Messaging<br />

Integration Services <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> Help <strong>and</strong> <strong>ClearPath</strong> Enterprise Servers <strong>User</strong><br />

Authentication Administration Guide.<br />

NTSI configuration allows selection of three Authentication Choices: <strong>User</strong>id/Password,<br />

Kerberos, <strong>and</strong> Windows NT LAN Manager (NTLM). Only Kerberos <strong>and</strong> NTLM are<br />

relevant to <strong>CIFS</strong>. Either, both, or neither can be configured.<br />

Note: This NTSI configuration is a system global specification. It applies to all<br />

applications using NTSI, including <strong>CIFS</strong> <strong>and</strong> Dem<strong>and</strong>/TIP signon.<br />

This NTSI configuration is per<strong>for</strong>med using Security Admin Security Client install <strong>and</strong><br />

update Network Authentication menu items.<br />

9–14 7859 6137–009


Figure 9–1. Network Authentication Menu Items<br />

Administration<br />

The following paragraphs describe the various selections shown in Figure 9-1 that are<br />

relevant to <strong>CIFS</strong>:<br />

Authentication Choices<br />

• Kerberos only - Microsoft Windows does not attempt Kerberos authentication if the<br />

server is addressed by IP address or if an <strong>OS</strong> <strong>2200</strong> user ID <strong>and</strong> password are<br />

supplied. If only Kerberos is configured, Windows 2000 <strong>and</strong> Vista users will not be<br />

able to access <strong>CIFS</strong>. Windows XP users receive a LOGON Error on the initial attempt<br />

to authenticate to <strong>2200</strong> <strong>CIFS</strong> because NTSI is not configured to per<strong>for</strong>m network<br />

NTLM authentication. If the user retries the logon attempt, <strong>2200</strong> <strong>CIFS</strong> attempts to<br />

per<strong>for</strong>m NTLM authentication against the <strong>OS</strong> <strong>2200</strong> user ID database.<br />

Note: Unisys strongly advises that NTSI should not be configured specifying<br />

Kerberos only.<br />

• NTLM only - Microsoft Windows attempts NTLM authentication. If the user ID <strong>and</strong><br />

password specified by the user are an <strong>OS</strong> <strong>2200</strong> user ID/password, <strong>CIFS</strong> attempts<br />

local NTLM authentication transparently if NTSI fails the authentication.<br />

• Neither selected - <strong>CIFS</strong> treats this situation as if NTSI is not available <strong>and</strong> falls back<br />

to per<strong>for</strong>ming native NTLM against <strong>OS</strong> <strong>2200</strong> user IDs only.<br />

• Both selected - NTSI offers Kerberos <strong>and</strong> NTLM authentication during SMB protocol<br />

negotiation. Microsoft Windows normally attempts Kerberos authentication <strong>and</strong>, if<br />

necessary, falls back to attempting NTLM authentication. If the user ID <strong>and</strong><br />

password specified by the user are an <strong>OS</strong> <strong>2200</strong> user ID/password, Microsoft<br />

7859 6137–009 9–15


Administration<br />

Windows is unable to obtain a Kerberos ticket <strong>and</strong> thus immediately falls back to<br />

attempting NTLM authentication.<br />

Map Network Logon Name to Local Account by Matching<br />

<strong>CIFS</strong> requires an <strong>OS</strong> <strong>2200</strong> user ID. NTSI provides the following methods of mapping<br />

network user names to <strong>OS</strong> <strong>2200</strong> user IDs. These are<br />

• Fully-qualified network logon name to local account network user ID<br />

• Network account name to local account name exactly<br />

• Fully-qualified name; if this fails, attempt account name exact match<br />

Fully-qualified network logon name to local account network user ID<br />

This option uses the Network <strong>User</strong> ID field in the <strong>OS</strong> <strong>2200</strong> user ID record to map the<br />

network user name to the <strong>OS</strong> <strong>2200</strong> user ID. This is the recommended option.<br />

In the example shown in Figure 9-2, the fully-qualified network user name<br />

NA.UIS.UNISYS.COM\DOEJG is mapped to <strong>OS</strong> <strong>2200</strong> user ID JGD.<br />

Note: As with <strong>OS</strong> <strong>2200</strong> user IDs, the Network <strong>User</strong> IDs must be unique; that is, only<br />

one <strong>OS</strong> <strong>2200</strong> user ID can map to a Network <strong>User</strong> ID.<br />

Network account name to local account name exactly<br />

This option accepts a fully-qualified network user name (NA.UIS.UNISYS.COM\DOEJG)<br />

<strong>and</strong> looks <strong>for</strong> an <strong>OS</strong> <strong>2200</strong> user ID (DOEJG).<br />

Network Authentication Logging<br />

<strong>CIFS</strong> uses the FLEX Authentication API AUTH_CONTEXT to per<strong>for</strong>m network<br />

authentication. FLEX generates type 17006 log entries <strong>for</strong> successful <strong>and</strong> unsuccessful<br />

authentications. Windows clients often attempt to establish an IPC connection using a<br />

null user ID. These connection attempts are always NTLM because Windows cannot get<br />

a Kerberos ticket <strong>for</strong> a null user ID. FLEX <strong>and</strong> NTSI return an authentication failure <strong>for</strong><br />

these requests, which results in a subtype 2 17006 authentication failure log entry.<br />

Note: Microsoft Windows clients do not attempt to per<strong>for</strong>m Kerberos authentication if<br />

the <strong>CIFS</strong> server is addressed by IP address (see KB 322979). To use Kerberos, the server<br />

must be referenced by DNS name; then Microsoft Windows attempts to use NTLM, if<br />

possible.<br />

9–16 7859 6137–009


Figure 9–2. Example Fully-Qualified Network <strong>User</strong> Name<br />

Administration<br />

7859 6137–009 9–17


Administration<br />

<strong>OS</strong> <strong>2200</strong> <strong>User</strong> ID Requirements<br />

Each user ID that is used on any network connection must have first been made known<br />

to <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong> through batch or dem<strong>and</strong>. This is accomplished using @<strong>CIFS</strong>UT to<br />

enter a simple comm<strong>and</strong>, such as pwd or cd that registers the user ID with <strong>OS</strong> <strong>2200</strong><br />

<strong>CIFS</strong>.<br />

Other <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong> requirements <strong>for</strong> user IDs are these:<br />

• The user ID must not be disabled.<br />

• For Fundamental Security systems where files are private by account, the user ID<br />

must have at least one account listed in the <strong>OS</strong> <strong>2200</strong> user ID record.<br />

• The first account in the <strong>OS</strong> <strong>2200</strong> user ID record must not be blank.<br />

• <strong>OS</strong> <strong>2200</strong> <strong>CIFS</strong> uses the value q$q$q$ if the project from the <strong>OS</strong> <strong>2200</strong> user ID record<br />

is missing or blank.<br />

About Authentication <strong>and</strong> Passwords<br />

The following table identifies the SMB authentication protocols supported by <strong>OS</strong> <strong>2200</strong><br />

<strong>CIFS</strong>. <strong>CIFS</strong> 3R1 <strong>and</strong> later (starting with <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> Release 7.1) can use either of<br />

the authentication protocols shown in this table, depending on the length <strong>and</strong><br />

case-sensitivity of the user’s password:<br />

<strong>CIFS</strong><br />

Authentication<br />

Protocol<br />

cifs_lm_12 SMB<br />

protocol<br />

(NTLM 0.12)<br />

cifs_pre_lm_12 SMB<br />

protocol<br />

(prior to NTLM 0.12)<br />

Password/Authentication<br />

Characteristics<br />

MD4 message digest of the user’s<br />

plain-text password, case-sensitive,<br />

converted to Unicode. Long<br />

passwords are supported. The<br />

plain-text password is hashed <strong>and</strong><br />

saved. Machine-generated passwords<br />

are permitted.<br />

DES encryption of a constant using<br />

the uppercased password as the key.<br />

The plain-text password is saved.<br />

Machine-generated passwords are not<br />

permitted.<br />

NTLMv2 A stronger enhancement to NTLM<br />

developed by Microsoft that<br />

significantly improves the<br />

authentication security mechanism.<br />

The key space <strong>for</strong> password-derived<br />

keys is 128 bits. NTLMv2 uses the<br />

same MD4 hash of the password as<br />

cifs_lm_12 SMB protocol, but uses<br />

this hash as the key to per<strong>for</strong>m an<br />

HMAC-MD5 hash.<br />

<strong>CIFS</strong> Level Support<br />

<strong>CIFS</strong> 3R1 <strong>and</strong> later<br />

<strong>CIFS</strong> 3R1 <strong>and</strong> later<br />

<strong>CIFS</strong> 6R2 <strong>and</strong> later<br />

9–18 7859 6137–009


<strong>CIFS</strong><br />

Authentication<br />

Protocol<br />

Password/Authentication<br />

Characteristics<br />

NTLM2 A variant of NTLMv2 used by<br />

Windows XP <strong>and</strong> later Microsoft<br />

operating systems when extended<br />

security negotiation is used <strong>and</strong> LAN<br />

Manager Authentication Level is set to<br />

Send LM & NTLM responses.<br />

Administration<br />

<strong>CIFS</strong> Level Support<br />

<strong>CIFS</strong> 6R2 <strong>and</strong> later<br />

If <strong>CIFS</strong> uses the cifs_pre_lm_12 protocol to h<strong>and</strong>le a long password, it converts the<br />

password to uppercase <strong>and</strong> allows only 14 characters. The following example illustrates<br />

this case:<br />

Example<br />

If the user’s password is… …then only the following is accepted <strong>for</strong> authentication:<br />

SIXTEENCHARACTER SIXTEENCHARACT<br />

These are rejected:<br />

SIXTEENCHARACTER<br />

SIXTEENCHARACTXX<br />

The following table shows how <strong>CIFS</strong> h<strong>and</strong>les passwords on different release levels <strong>and</strong><br />

under different conditions:<br />

<strong>CIFS</strong><br />

Level<br />

3R1 <strong>and</strong><br />

later<br />

3R1 <strong>and</strong><br />

later<br />

3R1 <strong>and</strong><br />

later<br />

<strong>ClearPath</strong><br />

Release<br />

Level<br />

7.1 <strong>and</strong><br />

later<br />

7.1 <strong>and</strong><br />

later<br />

Conditions Protocol Used<br />

<strong>User</strong> ID record <strong>for</strong> the user accessing<br />

<strong>CIFS</strong> is marked as having a<br />

case-sensitive password, <strong>and</strong> a<br />

cifs_lm_12 hash key is present.<br />

<strong>User</strong> ID record is not marked as<br />

having a case-sensitive password, or<br />

no hash key is present (or both).<br />

cifs_lm_12<br />

cifs_pre_lm_12,<br />

using only the<br />

first 14 characters<br />

of the password<br />

Pre-7.1 N/A cifs_pre_lm_12,<br />

using the<br />

6-character<br />

plain-text<br />

password saved<br />

in the user ID<br />

record<br />

7859 6137–009 9–19


Administration<br />

<strong>CIFS</strong><br />

Level<br />

<strong>ClearPath</strong><br />

Release<br />

Level<br />

Conditions Protocol Used<br />

Pre-3R1 Pre-7.1 N/A cifs_pre_lm_12,<br />

using the 6character<br />

plain-text<br />

password saved<br />

in the user ID<br />

record<br />

LAN Manager Authentication Level<br />

<strong>CIFS</strong> 6R2 <strong>and</strong> later allow Windows clients to be configured to inhibit use of LM <strong>and</strong><br />

NTLM authentication <strong>and</strong> allow only NTLMv2 to be used if Kerberos is not being used.<br />

LAN Manager Authentication Level may be set to “Send NTLMv2 response only” when<br />

using either Network Authentication or Local <strong>2200</strong> Authentication.<br />

See Microsoft Knowledge Base articles 239869, 823659, <strong>and</strong> 147706.<br />

You can also reference:<br />

• http://www.microsoft.com/technet/security/prodtech/windowsxp/secwinxp/xpsgch0<br />

3.mspx<br />

• http://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c16621675.mspx<br />

• http://www.microsoft.com/technet/security/topics/serversecurity/tcg/tcgch05n.mspx<br />

9–20 7859 6137–009


Environment Variables<br />

Initial Values of Environment Variables<br />

Administration<br />

The site administrator might want to set the system’s initial values <strong>for</strong> environment<br />

variables <strong>for</strong> <strong>CIFS</strong> (see Section 3 <strong>for</strong> the list) using the setsys comm<strong>and</strong> described in<br />

Section 4 or through the PUT$ENV <strong>and</strong> GET$ENV interfaces as documented in the<br />

System Services Programming Reference Manual. See the System Services<br />

Programming Reference Manual <strong>and</strong> the documentation <strong>for</strong> the security management<br />

product <strong>for</strong> more in<strong>for</strong>mation about active <strong>and</strong> passive system profiles.<br />

File I/O Buffer Cache<br />

The default <strong>CIFS</strong> I/O buffer cache size is 64 megawords. This may be changed with the<br />

<strong>CIFS</strong>$CACHE environment variable, which can be set globally in the <strong>CIFS</strong>-BACK<br />

runstream, or in the <strong>CIFS</strong>-BACK user ID profile. The minimum value is 16 megawords,<br />

<strong>and</strong> the value may be specified in words, kilowords, megawords, or gigawords.<br />

Example<br />

set <strong>CIFS</strong>$CACHE=1073741824<br />

set <strong>CIFS</strong>$CACHE=1048576K<br />

set <strong>CIFS</strong>$CACHE=1024m<br />

set <strong>CIFS</strong>$CACHE=1G<br />

The above are all equivalent. The variable name must be upper case; the multiplier suffix<br />

is not case sensitive.<br />

If necessary, <strong>CIFS</strong> may overflow the specified limit to hold unflushed data <strong>for</strong> written<br />

files, but avoids the usage of the overflow area once the processing returns to normal.<br />

The virtual space <strong>for</strong> the overflow buffers is not released back to the Exec, since it is not<br />

being referenced, the system will page out the associated data from real memory when<br />

other programs require it.<br />

Communications Configuration Variables<br />

By default, <strong>CIFS</strong> listens <strong>for</strong> network requests through the Communications Application<br />

Program Interface installation mode A subsystem. You can select other or multiple<br />

Communications Application Program Interface modes <strong>for</strong> <strong>CIFS</strong> by specifying the desired<br />

mode letters in the <strong>CIFS</strong>$COMAPI environment variable <strong>for</strong> the <strong>CIFS</strong> background run.<br />

For example, <strong>CIFS</strong>$COMAPI=FC tells <strong>CIFS</strong> to use Communications Application Program<br />

Interface modes F <strong>and</strong> C <strong>for</strong> network connections. You may specify mode letters in any<br />

order, in uppercase or lowercase. (But note that the variable name, <strong>CIFS</strong>$COMAPI, must<br />

be uppercase.) <strong>CIFS</strong> gives a slight preference to the first modes in the string when<br />

establishing listening connections.<br />

You can specify the value of <strong>CIFS</strong>$COMAPI <strong>for</strong> the <strong>CIFS</strong> background run (<strong>CIFS</strong>B) in<br />

several ways:<br />

• Edit the <strong>CIFS</strong>-BACK runstream in SYS$LIB$*RUN$ to add a <strong>CIFS</strong>UT set comm<strong>and</strong><br />

<strong>for</strong> the <strong>CIFS</strong>$COMAPI variable. You can insert this comm<strong>and</strong> just be<strong>for</strong>e the existing<br />

set comm<strong>and</strong> in the runstream that displays current environment variable settings.<br />

7859 6137–009 9–21


Administration<br />

• Establish a user profile <strong>for</strong> the <strong>CIFS</strong> background run’s user ID, <strong>and</strong> insert the<br />

<strong>CIFS</strong>$COMAPI setting there. Note that <strong>CIFS</strong>B must always run with this specific<br />

user ID <strong>for</strong> this method to be effective.<br />

• Add the <strong>CIFS</strong>$COMAPI setting to the system profile, making it available to all runs in<br />

the system. Be sure to update both the active <strong>and</strong> passive profiles when changing<br />

the value.<br />

File Assignment, Equipment Type, Size, <strong>and</strong> Placement<br />

By default, <strong>CIFS</strong> creates <strong>OS</strong> <strong>2200</strong> data <strong>and</strong> program files on fixed mass storage, using<br />

F///262143 <strong>for</strong> equipment type <strong>and</strong> maximum size. A site administrator can specify<br />

alternative settings with the <strong>CIFS</strong>$CAT variable, including removable disk pack IDs, if<br />

desired. When used in the <strong>CIFS</strong> background run, the <strong>CIFS</strong>$CAT settings are applied to<br />

<strong>CIFS</strong> system files <strong>and</strong> any files created in response to network client requests. When<br />

used in the system profile, the <strong>CIFS</strong>$CAT settings apply to all runs, including TIP<br />

transactions <strong>and</strong> the <strong>CIFS</strong> background run. However, an individual batch or dem<strong>and</strong> run<br />

can override the global setting by establishing its own value <strong>for</strong> the variable.<br />

When attempting to access rolled out or exclusively assigned <strong>OS</strong> <strong>2200</strong> files, you can<br />

control the <strong>CIFS</strong> behavior with the <strong>CIFS</strong>$WAITROLBAK <strong>and</strong> <strong>CIFS</strong>$WAITXUSE variables.<br />

The default values are 600 (10 minutes) <strong>and</strong> 0, respectively.<br />

The variables can be set to the number of seconds to wait <strong>for</strong> file availability, if the<br />

open() request triggering the assign has the O_NONBLOCK flag bit clear. As with<br />

<strong>CIFS</strong>$CAT, variables visible to the background run affect <strong>CIFS</strong> system files <strong>and</strong> network<br />

access. Batch <strong>and</strong> dem<strong>and</strong> runs can override any global settings.<br />

Time-Dependent Environment Variables<br />

The <strong>OS</strong> <strong>2200</strong> operating system does not h<strong>and</strong>le time zones or daylight savings time as<br />

other systems do, yet <strong>CIFS</strong> access through the network depends on <strong>and</strong> references<br />

Coordinated Universal Time (UTC). There<strong>for</strong>e, there is a dependency on two<br />

environment variables, TZ <strong>and</strong> TIMEBASE, which establish time relationships.<br />

Proper client-server interaction requires that the background run be invoked with these<br />

variables in place <strong>and</strong> with values that represent the desired relationship between the<br />

system dayclock <strong>and</strong> UTC. The set <strong>and</strong> setsys comm<strong>and</strong>s of @<strong>CIFS</strong>UT are a convenient<br />

means by which to set these variables.<br />

The following example shows how a runstream can be used to set a variable <strong>for</strong> a<br />

system in the central time zone running with a system dayclock set 6 hours behind UTC.<br />

...<br />

@<strong>CIFS</strong>UT<br />

set TZ=CST6CDT<br />

set TIMEBASE=6<br />

@EOF<br />

...<br />

9–22 7859 6137–009


The TZ Environment Variable<br />

Administration<br />

The TZ environment variable is part of the normal user environment on systems similar<br />

to Unix <strong>and</strong> specifies:<br />

• The time zone.<br />

• The relation of local time to st<strong>and</strong>ard time at the prime meridian.<br />

• The dates to change between st<strong>and</strong>ard time <strong>and</strong> daylight saving time.<br />

If the TZ variable is not in the environment, the UTC time zone is assumed.<br />

Format<br />

TZ=StdOffset[dst[Offset],[start[/time],end[/time]]]<br />

where:<br />

Std<br />

Offset<br />

dst<br />

is three or more characters <strong>for</strong> the name of the time zone during st<strong>and</strong>ard time, <strong>for</strong><br />

example, CST <strong>for</strong> central st<strong>and</strong>ard time. This field is required. Any characters are<br />

valid except digits, plus (+) <strong>and</strong> minus (-) signs, or a comma (,).<br />

indicates the difference between local time <strong>and</strong> UTC (the value to add to local time<br />

to obtain UTC). Offset has the <strong>for</strong>m [+|-]hh[:mm[:ss]].<br />

An optional “+” or “- “sign may precede the first digit. Time zones east of the prime<br />

meridian <strong>and</strong> west of the international date line need a leading minus sign. Time<br />

zones west of the prime meridian are indicated by an optional preceding plus sign.<br />

hh indicates the number of hours on a 24-hour clock. Its value is one or more<br />

decimal digits in the range 0 through 24. mm, if included, indicates the number of<br />

minutes. Its value is one or more decimal digits in the range 0 - 59. ss, if included,<br />

indicates the number of seconds. Its value is one or more decimal digits in the range<br />

0- 59. The ss field cannot exist if mm does not exist.<br />

The Offset following Std is required.<br />

is three or more characters <strong>for</strong> the name of the time zone during daylight savings<br />

time, <strong>for</strong> example, EDT <strong>for</strong> eastern daylight time. This field is optional. If dst is not<br />

included, then daylight savings time does not apply in this locale. Any characters are<br />

valid except digits, plus (+) <strong>and</strong> minus (-) signs, or a comma (,).<br />

The Offset following dst is optional. If no Offset follows dst, daylight savings time is<br />

assumed to be one hour ahead of st<strong>and</strong>ard time.<br />

7859 6137–009 9–23


Administration<br />

start /time, end /time<br />

Jn<br />

n<br />

start /time indicates the day <strong>and</strong> time to change from st<strong>and</strong>ard time to daylight<br />

savings time. end /time indicates the day <strong>and</strong> time to change from daylight savings<br />

time to st<strong>and</strong>ard time. Each time field indicates the time of day, in current local time,<br />

the change is made. The time fields have the same <strong>for</strong>mat as the Offset fields,<br />

except that no leading plus or minus field is allowed. If a time field is not included, it<br />

has the default value of 02:00:00.<br />

The start <strong>and</strong> end fields are optional. Implementation-specific defaults are used if<br />

they are not specified. The start <strong>and</strong> end fields have one of the following <strong>for</strong>mats:<br />

where n represents the day of the year, except leap day. The value of n ranges from<br />

1 through 365. Leap day is not represented. February 28 is always day 59 <strong>and</strong> March<br />

1 is always day 60. It is impossible to refer to the occasional February 29.<br />

where n represents the number of days since January 1. The value of n ranges from<br />

0 through 365. February 28 is day 58. March 1 is either day 59 or 60, depending on<br />

whether the year is a leap year.<br />

Mm.n.d<br />

where:<br />

m represents the month; values range from 1 through 12.<br />

n represents the week of the month; values range from 1 through 5. If n is 5, the<br />

date references the last day of the month.<br />

d represents the day of the week; values ranges from 0 through 6. Day 0 is Sunday.<br />

The date indicated is the nth d day of month m.<br />

Example<br />

TZ=CST6CDT,M4.1.0,M10.5.0<br />

This code indicates the following time-zone values:<br />

• The st<strong>and</strong>ard time designator is CST (Central St<strong>and</strong>ard Time).<br />

• St<strong>and</strong>ard time is 6 hours behind UTC.<br />

• The daylight savings time designator is CDT (Central Daylight Time).<br />

• Daylight savings time is 5 hours behind UTC.<br />

9–24 7859 6137–009


Administration<br />

• The time-zone designator switches from CST to CDT on the first Sunday in April at<br />

2:00 A.M. st<strong>and</strong>ard time.<br />

• The time-zone designator switches from CDT to CST on the last Sunday in October<br />

at 2:00 A.M. daylight savings time.<br />

TIMEBASE Environment Variable<br />

The TIMEBASE environment variable is unique to the <strong>OS</strong> <strong>2200</strong> system. Most systems<br />

similar to UNIX set their internal clock to UTC, but that is usually not true <strong>for</strong> <strong>OS</strong> <strong>2200</strong><br />

systems. Traditionally, most <strong>OS</strong> <strong>2200</strong> systems set their internal clock to local time,<br />

which can include biases <strong>for</strong> the time zone <strong>and</strong> daylight savings time. The TIMEBASE<br />

environment variable specifies the relationship between UTC <strong>and</strong> the site's system<br />

dayclock.<br />

If the TIMEBASE variable is not present, <strong>CIFS</strong> assumes that the dayclock is set to local<br />

time, as indicated by the TZ variable setting. If the TIMEBASE variable is present, <strong>CIFS</strong><br />

always interprets a value of 0 as an indication that the site is running UTC in the<br />

dayclock, regardless of the TZ variable setting.<br />

Consequently, if a site is operating with a local time in the dayclock that has an offset of<br />

0 from UTC, the TIMEBASE variable must be omitted. Otherwise, <strong>CIFS</strong> per<strong>for</strong>ms an<br />

incorrect conversion on times outside of the current st<strong>and</strong>ard or daylight time period.<br />

Format<br />

TIMEBASE=offset<br />

where offset indicates the amount of time that the system dayclock varies from UTC <strong>and</strong><br />

has the <strong>for</strong>m [+|-]hh[:mm[:ss]]<br />

An optional “+” or “-“ sign may precede the first digit. Time zones east of the prime<br />

meridian <strong>and</strong> west of the international date line need a leading minus sign. Time zones<br />

west of the prime meridian are indicated by an optional preceding plus sign. hh indicates<br />

the number of hours on a 24-hour clock. Its value is one or more decimal digits in the<br />

range 0 through 24. mm, if included, indicates the number of minutes. Its value is one or<br />

more decimal digits in the range 0 through 59. ss, if included, indicates the number of<br />

seconds. Its value is one or more decimal digits in the range 0 through 59. The ss field<br />

cannot exist if mm does not exist.<br />

Example<br />

TIMEBASE=6<br />

TZ=CST6CDT<br />

This code specifies the following:<br />

• During st<strong>and</strong>ard time, the system dayclock is 6 hours earlier than UTC.<br />

• During daylight savings time, the system dayclock is 5 hours earlier than UTC (since<br />

we know that TZ=CST6CDT).<br />

7859 6137–009 9–25


Administration<br />

But if the dayclock changed during CDT, then the TIMEBASE variable must be changed<br />

as well:<br />

TIMEBASE=5<br />

TZ=CST6CDT<br />

File Filtering<br />

File filtering provides site administrators with the capability to control access to the <strong>2200</strong><br />

file system through <strong>CIFS</strong> by implementing site file system policy in local code that<br />

executes within the <strong>CIFS</strong> subsystem. This can be useful, <strong>for</strong> example, in a consolidated<br />

server environment, where users from previously independent systems with identical<br />

application environments are now operating on a single host, yet must continue to<br />

reference separate sets of files. In such a situation, file filtering can adjust the names in a<br />

user’s file requests to insure that segregation of application data continues.<br />

Filtering is implemented by a set of APIs called by the <strong>CIFS</strong> subsystem to en<strong>for</strong>ce the<br />

site policy. These APIs are fielded by the FILTER object module (OM) in the <strong>CIFS</strong><br />

subsystem file (SYS$LIB$*<strong>CIFS</strong>$SS). To employ filtering, per<strong>for</strong>m the following steps:<br />

1. If it is running, deactivate the <strong>CIFS</strong> subsystem.<br />

2. Change SYS$LIB$*<strong>CIFS</strong>$SS to write-enabled, if it is not already.<br />

3. Replace the FILTER object module supplied by Unisys with one or more OMs that<br />

implement the site file system policy through the APIs described below. (If none of<br />

the site OMs is named FILTER, the Unisys one must be deleted.)<br />

4. Pack <strong>and</strong> prep SYS$LIB$*<strong>CIFS</strong>$SS.<br />

5. Start <strong>CIFS</strong>-BACK. The replacement OMs are automatically loaded during the <strong>CIFS</strong><br />

subsystem activation.<br />

The three APIs that a site must implement to enable file filtering are briefly documented<br />

below. For details about the interfaces, including parameters <strong>and</strong> return values, consult<br />

the FILTER/H header file in SYS$LIB$*<strong>CIFS</strong>$SS.<br />

• filter_userid() – Determines whether a particular combination of user ID, account,<br />

<strong>and</strong> project is subject to file filtering; called during creation of the internal process<br />

descriptor structure <strong>for</strong> each process as it registers with <strong>CIFS</strong>.<br />

• filter_check() – Determines whether a particular qualifier <strong>and</strong> filename must be<br />

visible to a given <strong>CIFS</strong> user; called during scans of the directories /os<strong>2200</strong> <strong>and</strong><br />

/os<strong>2200</strong>/ (or equivalent network shares) to eliminate passing back entries the<br />

site does not want this user to access.<br />

• filter_apply() – Modifies a particular qualifier <strong>and</strong> filename requested by a user, as<br />

determined by site file system policy. Called during path resolution <strong>and</strong> file creation<br />

<strong>for</strong> /os<strong>2200</strong>// <strong>and</strong> /os<strong>2200</strong>/ or when a name from<br />

the <strong>CIFS</strong>$NEXTFILE environment variable is used.<br />

9–26 7859 6137–009


Administration<br />

The carefully controlled execution environment of the <strong>CIFS</strong> subsystem imposes certain<br />

restrictions on how a site’s filter code can be implemented. In particular, the header file<br />

“universal.h” MUST be included first in any UC-based filter OMs, <strong>and</strong> site-supplied code<br />

must use only the APIs available through the header files supplied in<br />

SYS$LIB$*<strong>CIFS</strong>$SS. Site-supplied code must not call outside of the <strong>CIFS</strong> subsystem,<br />

other than to the Exec. This prohibition includes any URTS or UC library functions not<br />

specified in the supplied header files.<br />

To build a module <strong>for</strong> file filtering, you must observe the following points:<br />

• Do an @USE UC$PF,SYS$LIB$*<strong>CIFS</strong>$SS be<strong>for</strong>e any compilations.<br />

• Make #include “universal.h” the first include in every compilation.<br />

• Any or all of the additional header files from SYS$LIB$*<strong>CIFS</strong>$SS may also be<br />

included, but they must be referenced with quotation marks, not angle brackets.<br />

• Do not call any interfaces outside of the ones supplied by your filter OMs other than<br />

Exec entry points or those in the supplied header files.<br />

• If any compiler other than UC is used, it must con<strong>for</strong>m to UC register conventions<br />

<strong>and</strong> the limitations listed above.<br />

Examine the header files in SYS$LIB$*<strong>CIFS</strong>$SS <strong>for</strong> details about what interfaces are<br />

available to filtering code.<br />

7859 6137–009 9–27


Administration<br />

9–28 7859 6137–009


Appendix A<br />

Limitations, Considerations, <strong>and</strong><br />

Restrictions<br />

Limitations<br />

The <strong>CIFS</strong> level 6R3 release has the following limitations, considerations, <strong>and</strong> restrictions.<br />

• <strong>CIFS</strong> cannot per<strong>for</strong>m I/O to portions of files beyond byte 34,359,738,367. This is<br />

equivalent to 4,793,490 <strong>OS</strong> <strong>2200</strong> tracks or 74,898 positions. This is a limit imposed<br />

by the <strong>2200</strong> 36-bit architecture <strong>and</strong> the P<strong>OS</strong>IX API specification that uses a signed<br />

integer field to hold the byte offset in a file. The byte offset overflows a 36-bit word<br />

<strong>and</strong> goes negative above 74,898 positions.<br />

• <strong>CIFS</strong> path names are limited to a total of 1,046,496 bytes.<br />

• <strong>CIFS</strong> path name components (directory <strong>and</strong> file names) are limited to 4,095 bytes.<br />

• The maximum number of concurrently open files <strong>for</strong> a process is 2,048. Due to this<br />

limit, certain <strong>CIFS</strong>UT functions (<strong>for</strong> example, deltree <strong>and</strong> rm –r) will not complete<br />

normally if the number of nested directories causes the open-file limit to be<br />

exceeded.<br />

• Environment variables cannot be set by transaction processing (TIP) programs.<br />

• A share name cannot be more than 31 characters long.<br />

Considerations<br />

Note: Many network clients cannot access share names with more than 12<br />

characters.<br />

These considerations apply:<br />

• <strong>CIFS</strong> uses a large amount of virtual memory in order to cache file data. This<br />

consumes a significant number of application-level Bank Descriptor Indices (BDIs)<br />

<strong>and</strong> can impact the availability of BDIs to other programs. Consequently, Unisys<br />

strongly recommends that sites set the Exec dynamic configuration parameter<br />

apl_bank_bdi_gt4k (short name APLBDIGT4K) to TRUE. This allows <strong>CIFS</strong> to allocate<br />

its data banks from the 28,000 slots in the upper BDI range rather than from the<br />

4,000 in the lower range. The amount of memory used by the file cache can be<br />

specified by the <strong>CIFS</strong>$CACHE environment variable.<br />

• The ZIPUT processor is written primarily in the Java language. Use of ZIPUT requires<br />

that the Virtual Machine <strong>for</strong> the Java Plat<strong>for</strong>m on <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> product be<br />

installed. This product is known in<strong>for</strong>mally as the <strong>2200</strong> JVM.<br />

7859 6137–009 A–1


Limitations, Considerations, <strong>and</strong> Restrictions<br />

• <strong>CIFS</strong> supports SMB clients that utilize long file names, including Windows 95/98/Me,<br />

Windows NT4/2000/XP/2003/Vista, j<strong>CIFS</strong>, <strong>and</strong> Samba. Because of this, some<br />

comm<strong>and</strong>s entered from the D<strong>OS</strong> comm<strong>and</strong> prompt under Windows 95/98/Me<br />

might not be usable. For example, the dir <strong>and</strong> copy comm<strong>and</strong>s fail because they rely<br />

upon fixed-length 13-character fields to hold file names. The D<strong>OS</strong> comm<strong>and</strong> prompt,<br />

under Windows 95/98/Me, can be used <strong>for</strong> launching programs that use the Win32<br />

APIs, such as Notepad, WordPad, Java compiler, <strong>and</strong> so on, that use files on drives<br />

mapped to <strong>CIFS</strong> directories. In addition, redirection to or from a <strong>CIFS</strong> directory is<br />

supported. For example, the more comm<strong>and</strong> can be used to display the contents of<br />

a file. Other comm<strong>and</strong>s might or might not work depending on the client software's<br />

implementation <strong>and</strong> reliance upon 8.3 style file names. Windows<br />

NT4/2000/XP/2003/Vista does not have these restrictions. All comm<strong>and</strong>s to the<br />

comm<strong>and</strong> prompt (shell) under Windows NT4/2000/XP/2003/Vista should function.<br />

• When you use Windows NT4 to access <strong>CIFS</strong>, Service Pack 4, 6a, or higher is<br />

recommended. (Service pack 5 can have connection problems when using IP<br />

addresses.)<br />

• Files in the <strong>CIFS</strong> file system might consume more physical disk space than<br />

previously used in <strong>OS</strong> <strong>2200</strong>. This is because <strong>CIFS</strong> always allocates all physical disk<br />

space, which differs from <strong>OS</strong> <strong>2200</strong>. For example, in <strong>OS</strong> <strong>2200</strong>, if you do not write a<br />

file sequentially from the beginning, <strong>OS</strong> <strong>2200</strong> can leave unwritten areas of the file<br />

unallocated; <strong>CIFS</strong> allocates all areas of the file.<br />

• If read/write keys are used on container files <strong>for</strong> <strong>CIFS</strong> directories, <strong>and</strong> directories are<br />

nested, you cannot per<strong>for</strong>m a change directory across multiple directories unless the<br />

read/write keys are the same. Instead, you must do individual change directory<br />

comm<strong>and</strong>s after setting the <strong>CIFS</strong>$KEYS environment variable <strong>for</strong> each directory<br />

individually. Example (assume a path of /dir-a/dir-b/dir-c):<br />

@<strong>CIFS</strong>UT<br />

set <strong>CIFS</strong>$KEYS=dirak1<br />

cd /dir-a<br />

SET <strong>CIFS</strong>$KEYS=dirak2<br />

cd /dir-b<br />

SET <strong>CIFS</strong>$KEYS=dirak3<br />

cd /dir-c<br />

• Read/write keys cannot be used over network connections to <strong>CIFS</strong> because the<br />

protocol does not provide a means of specifying them. Consequently, great care<br />

must be taken on Fundamental Security systems to balance accessibility <strong>and</strong><br />

vulnerability. Moving to Security Option 1 or higher <strong>and</strong> using Access Control<br />

Records on files is strongly recommended.<br />

• The Communications Application Program Interface configuration impacts <strong>CIFS</strong>. For<br />

example, <strong>CIFS</strong> uses up to 65 activities to h<strong>and</strong>le network access through each<br />

instance of Communications Application Program Interface. Make note of this when<br />

configuring the MAX_USERS_TCP value in Communications Application Program<br />

Interface.<br />

• The host name can be expressed as a shortname (<strong>for</strong> example, rs06), fully qualified<br />

name (<strong>for</strong> example, rs06.rsvl.unisys.com), or an IP address. Depending on the client<br />

<strong>and</strong> the local network configuration, any or all of these will work.<br />

A–2 7859 6137–009


Limitations, Considerations, <strong>and</strong> Restrictions<br />

• When a <strong>CIFS</strong> file is updated by an application, any existing SDF record structure<br />

remains unchanged. There<strong>for</strong>e, if new record delimiters (ASCII newline characters)<br />

do not exactly overwrite existing delimiters, the resulting file might not make sense<br />

if read outside of <strong>CIFS</strong>. Copying such a file with <strong>CIFS</strong>UT to another location will<br />

rebuild the SDF record structure, making the file readable by st<strong>and</strong>ard <strong>OS</strong> <strong>2200</strong><br />

programs.<br />

• Dates prior to 1980 cannot display correctly in SMB client programs such as<br />

Windows Explorer due to inherent restrictions with the SMB protocol.<br />

• Files accessed through <strong>CIFS</strong> are normally stored as SDF elements in <strong>OS</strong> <strong>2200</strong><br />

program files. The environment variable, <strong>CIFS</strong>$NEXTFILE, can be used to <strong>for</strong>ce<br />

storage in a data file, if required. The SDF <strong>for</strong>mat is transparent to network clients<br />

<strong>and</strong> programs using the <strong>CIFS</strong> APIs because on read operations, <strong>CIFS</strong> always returns<br />

the exact byte sequences supplied on write requests. To facilitate data access by<br />

programs using traditional <strong>OS</strong> <strong>2200</strong> I/O mechanisms, <strong>CIFS</strong> interprets various line<br />

termination sequences as record breaks.<br />

− A single line feed (0x0A): the Linux/UNIX st<strong>and</strong>ard, compatible with UCS<br />

Runtime System I/O h<strong>and</strong>ling<br />

− A carriage return, line feed sequence (0x0D <strong>and</strong> 0x0A): typically used by<br />

Windows text files<br />

− A single carriage return (0x0D): the normal Apple Mac <strong>OS</strong> line terminator<br />

Files using terminators other than a plain line feed can be filtered to make them<br />

compatible with Linux/UNIX based programs through the w-option of the <strong>CIFS</strong>UT CP<br />

<strong>and</strong> COPY comm<strong>and</strong>s. There is no limit on record length, though files are limited to<br />

approximately 29 MB when stored as st<strong>and</strong>ard <strong>OS</strong> <strong>2200</strong> elements (34 GB in LEPF).<br />

• Using cpFTP to transfer files created by <strong>CIFS</strong> can corrupt the data at the receiver<br />

unless extreme care is taken with the procedure. Any files to be sent through cpFTP<br />

must first be converted to binary using the <strong>CIFS</strong>UT cp -b or binjar comm<strong>and</strong>s. Once<br />

this is done, the cpFTP mode must be set to binary <strong>and</strong>, if the <strong>CIFS</strong> file is stored as<br />

an element, set ftype to OMN. This insures that critical in<strong>for</strong>mation (such as data<br />

bytes with values equal to carriage return or line feed) are not discarded or modified<br />

during the transfer. Using the <strong>CIFS</strong> client to transfer data to another system requires<br />

no such considerations.<br />

• <strong>CIFS</strong> automatically converts the program file that is associated with a directory to a<br />

Large Program File (LPF) if the Table of Contents (TOC) of the program file fills-up.<br />

This conversion can occur both <strong>for</strong> implicitly-created program files <strong>and</strong> <strong>for</strong> files at the<br />

/os<strong>2200</strong>/qual/file level of the directory hierarchy (whether they are created by <strong>CIFS</strong> or<br />

not ). A normal program file TOC can hold entries between 2671 to 5000 entries,<br />

depending on whether there are Assembler/COBOL/Fortran PROC entries or a<br />

relocatable entry point table existing in the program file. An LPF can hold up to<br />

26146 TOC entries. A program file is not converted to an LPF if the TOC has deleted<br />

element entries in it. This is because a pack is done on the file <strong>and</strong> this recovers the<br />

space <strong>for</strong> those deleted entries. Note that a FURPUR @PACK,M cannot be done on<br />

an LPF. If you want to compress the program files <strong>for</strong> your directories using<br />

@PACK,M, ensure that the directories have less than 5000 elements in them so that<br />

they are not converted to LPFs by <strong>CIFS</strong>.<br />

7859 6137–009 A–3


Limitations, Considerations, <strong>and</strong> Restrictions<br />

Restrictions<br />

• <strong>CIFS</strong> also automatically packs the underlying program file <strong>for</strong> a directory if the TOC or<br />

the text area of the program file fills up <strong>and</strong> an overflow could occur that might result<br />

in truncation of user files(elements). The pack recovers space <strong>for</strong> the deleted TOC<br />

entries <strong>and</strong> <strong>for</strong> text space that is allocated <strong>for</strong> deleted elements in the program file.<br />

The <strong>CIFS</strong>UT touch comm<strong>and</strong> with the -p option will also pack the program file<br />

associated with a directory. Using the -pr options with touch (adding the recursive<br />

option) will pack all the program files <strong>for</strong> a directory tree.<br />

• <strong>CIFS</strong> can create Large Element Program Files (LEPFs) using the <strong>CIFS</strong>UT comm<strong>and</strong><br />

mkdir or the C program interface mkdir(). <strong>CIFS</strong> creates LEPFs as needed <strong>for</strong> <strong>CIFS</strong><br />

implicitly created containers (ones created by <strong>CIFS</strong> not at the /os<strong>2200</strong>/qual/file level<br />

of the directory hierarchy <strong>and</strong> not explicitly specified using <strong>CIFS</strong>$NEXTFILE). Such<br />

automatic LEPF creation occurs only when the element to be written is larger than<br />

262,143 sectors <strong>and</strong> the existing container is not already an LEPF. <strong>CIFS</strong> can also<br />

work with existing LEPFs. If you use <strong>CIFS</strong>UT to copy or move a directory that has an<br />

LEPF container associated with it, <strong>and</strong> the corresponding directory at the target<br />

location does not exist, then the new directory default container is created as normal<br />

program file. However, any files within the container that are larger than the normal<br />

element limit are placed in the automatically created auxiliary LEPF containers.<br />

These are the restrictions applied to:<br />

Note: On <strong>CIFS</strong> level 3R1 (<strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> Release 7.1), the restriction against<br />

machine-generated passwords was removed. The restriction still exists on lower levels.<br />

• Files larger than 262,143 tracks cannot be copied or moved by <strong>CIFS</strong>UT.<br />

• <strong>CIFS</strong> does not maintain an 8.3 <strong>for</strong>mat alias <strong>for</strong> long file names.<br />

• Programs that use the 8.3 file naming interfaces might experience problems<br />

interacting with <strong>CIFS</strong>. This includes, but is not limited to, the dir comm<strong>and</strong> of the<br />

D<strong>OS</strong> shell running under Windows 95/98/Me.<br />

• If a symbolic element is cycled, <strong>CIFS</strong> provides access only to the current cycle. Data<br />

in older cycles is not available.<br />

• Windows Explorer cannot be used to create directories one or two levels below<br />

/os<strong>2200</strong> because Windows uses “New Folder” <strong>for</strong> the initial name. The space in<br />

“New Folder” conflicts with Exec file naming requirements. Directories at these<br />

levels can be created from the comm<strong>and</strong> prompt, or through Windows APIs.<br />

• Some desktop applications, including Microsoft Word, cannot be used to manipulate<br />

<strong>OS</strong> <strong>2200</strong> data files because they attempt to create temporary files in the<br />

/os<strong>2200</strong>/qualifier directory that are not valid <strong>OS</strong> <strong>2200</strong> file names. These applications<br />

operate successfully on <strong>OS</strong> <strong>2200</strong> elements, or on any files not in the /os<strong>2200</strong><br />

directory hierarchy.<br />

• Calling <strong>CIFS</strong> from a protected subsystem can be problematical. First, any activity<br />

calling <strong>CIFS</strong> from a protected subsystem must first call <strong>CIFS</strong> from the home<br />

subsystem, or never call <strong>CIFS</strong> from any subsystem (including home) other than that<br />

protected one. Second, any <strong>CIFS</strong> files opened by a protected subsystem are<br />

accessible by all activities of the run that per<strong>for</strong>med the open() requests, even when<br />

they are not executing in the protected subsystem. This restriction will be removed<br />

in a future level.<br />

A–4 7859 6137–009


Limitations, Considerations, <strong>and</strong> Restrictions<br />

• <strong>CIFS</strong> does not currently detect file name changes made by @CHG,N. Direct access<br />

to the new name results in <strong>CIFS</strong> becoming aware of the file, but the old name<br />

remains. Running <strong>CIFS</strong>-POP corrects the discrepancy. This restriction will be<br />

removed in a future level.<br />

• If network authentication is not installed when the <strong>CIFS</strong> background run is initially<br />

started, the background run must be shut down <strong>and</strong> restarted to detect a change in<br />

network authentication availability.<br />

• Files whose type is not yet known are not visible over network connections. The<br />

SMB protocol does not allow <strong>for</strong> an unknown or “none-of-the-above” file attribute,<br />

so some batch or dem<strong>and</strong> <strong>CIFS</strong> operation must be per<strong>for</strong>med on such a file to<br />

establish the type be<strong>for</strong>e it can be used from the network.<br />

• When accessing <strong>CIFS</strong> from a Windows Vista workstation, the lmcompatibility setting<br />

in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa<br />

must have a value less than 2 unless FLEX <strong>and</strong> NTSI are installed <strong>and</strong> operational.<br />

7859 6137–009 A–5


Limitations, Considerations, <strong>and</strong> Restrictions<br />

A–6 7859 6137–009


Appendix B<br />

Error Codes<br />

Error Code Description<br />

2 Object with specified name does not exist.<br />

3 No such process.<br />

5 Input/output error.<br />

12 Not enough space.<br />

13 Access permission denied.<br />

22 Invalid argument.<br />

24 Too many open files.<br />

27 File address too large.<br />

33 Domain error.<br />

34 Result too large.<br />

222 Argument list too long.<br />

224 Resource temporarily unavailable.<br />

225 Invalid file descriptor.<br />

226 Resource busy.<br />

227 No child processes.<br />

228 Waiting <strong>for</strong> resource would cause deadlock.<br />

230 Object already exists.<br />

231 Addressing exception.<br />

233 Interrupted function call.<br />

236 Is a directory.<br />

238 Too many links.<br />

239 Name is too long.<br />

240 Too many open files in system.<br />

241 No such device.<br />

243 Is not an object file.<br />

244 No locks available.<br />

7859 6137–009 B–1


Error Codes<br />

Error Code Description<br />

246 No space left on device.<br />

247 Function not implemented.<br />

248 Is not a directory.<br />

249 Directory is not empty.<br />

250 Inappropriate I/O control operation.<br />

251 No such device or address.<br />

252 Operation not permitted.<br />

253 Broken pipe.<br />

255 Read-only file system.<br />

256 Pipe is an invalid file type <strong>for</strong> lseek.<br />

258 Attempt to link across different file systems.<br />

701 BSP$ error: specified length of FCT is less than minimum required.<br />

702 BSP$ error: file is not a program file.<br />

703 BSP$ error: specified interface level not supported.<br />

704 BSP$ error: file is not sector <strong>for</strong>matted or TOC is corrupt.<br />

705 BSP$ error: program file revision level not supported.<br />

706 BSP$ error: specified size indicator is illegal.<br />

707 BSP$ error: no starting sector address <strong>for</strong> large program file table.<br />

708 BSP$ error: program file does not contain a valid size indicator.<br />

710 BSP$ error: FTI not in memory.<br />

711 BSP$ error: no starting sector <strong>for</strong> large program file table.<br />

712 BSP$ error: sequence number out of range.<br />

718 BSP$ error: specified table not in memory.<br />

720 BSP$ error: buffer too small.<br />

721 BSP$ error: buffer too large.<br />

734 BSP$ error: at least one table not written back.<br />

735 BSP$ error: invalid next sector <strong>for</strong> text.<br />

736 BSP$ error: no room in file to create table entry.<br />

737 BSP$ error: attempt to change item size.<br />

738 BSP$ error: illegal element type <strong>for</strong> large element program file.<br />

739 BSP$ error: illegal element length granularity <strong>for</strong> large element program<br />

file.<br />

822 <strong>CIFS</strong> not initialized.<br />

823 Not enough system memory.<br />

B–2 7859 6137–009


Error Code Description<br />

824 <strong>OS</strong> <strong>2200</strong> facility rejection.<br />

825 Not enough stack space.<br />

826 Process table entry already exists.<br />

827 Internal error.<br />

828 The underlying file is corrupt.<br />

829 <strong>CIFS</strong> initialization failed.<br />

830 Error on file assignment switch.<br />

831 You are not permitted to use <strong>CIFS</strong>.<br />

832 Attempt to process an invalid SDF file or update an SDF file not<br />

produced by <strong>CIFS</strong>.<br />

834 Imported file name is not valid <strong>OS</strong> <strong>2200</strong> file name.<br />

835 ERESTART error.<br />

838 Operation not allowed at the current position in the <strong>CIFS</strong> directory<br />

hierarchy.<br />

839 <strong>OS</strong> <strong>2200</strong> F-cycle has been dropped.<br />

Error Codes<br />

840 The path name contains characters not allowed in <strong>CIFS</strong> file or directory<br />

names.<br />

841 A fatal error occurred within the <strong>CIFS</strong> kernel.<br />

842 Unlink not allowed in /os<strong>2200</strong> directory hierarchy if link count not equal<br />

to two <strong>for</strong> program files or one <strong>for</strong> non-program files.<br />

843 The <strong>CIFS</strong> background run is already active. Only one copy of the<br />

background run allowed at one time.<br />

844 An error occurred during <strong>CIFS</strong> library initialization.<br />

845 A limit imposed by the <strong>2200</strong> architecture, <strong>OS</strong> <strong>2200</strong>, or the <strong>CIFS</strong><br />

implementation has been exceeded.<br />

846 Object already exists.<br />

847 The <strong>CIFS</strong>B background run is not active when it is required.<br />

848 The Coded Character Set name is not known to <strong>CIFS</strong>.<br />

849 The specified network path cannot be found.<br />

850 Remote authentication failed with the given network userid/password.<br />

851 Request not completed due to network error.<br />

852 Network path not permitted <strong>for</strong> this function.<br />

853 No password available <strong>for</strong> network authentication.<br />

854 Function could not be completed by network server.<br />

855 Cross-linking not allowed <strong>for</strong> elements in program files.<br />

856 MSCP interface cannot be initialized.<br />

7859 6137–009 B–3


Error Codes<br />

Error Code Description<br />

901 Files may not be created in the /os<strong>2200</strong> directory.<br />

902 Directories may not be created at this level in the /os<strong>2200</strong> directory<br />

hierarchy.<br />

903 Unknown file type.<br />

904 Links may not be created in the /os<strong>2200</strong> directory hierarchy.<br />

905 This functionality has not yet been implemented in <strong>CIFS</strong>.<br />

906 <strong>CIFS</strong>$NEXTFILE directed file cannot be created in an implicitly created<br />

program file directory.<br />

908 A fatal error occurred attempting to populate a program file directory.<br />

909 <strong>CIFS</strong>$NEXTFILE may not be used when creating files or directories in<br />

the /os<strong>2200</strong> hierarchy.<br />

910 ER SUMOD$ SYS$*SACRD$ I/O error.<br />

911 ER SUMOD$ error 01240. File specified in the packet is not assigned or<br />

is a removable disk pack file assigned with the Y option.<br />

912 ER SUMOD$ error 01241. An attempt was made to per<strong>for</strong>m a<br />

modification without possessing the proper privilege or privileges.<br />

913 ER SUMOD$ error 01242. New clearance level does not lie in modifier's<br />

clearance level range.<br />

914 ER SUMOD$ error 01243. To-be-attached ACR does not exist.<br />

915 ER SUMOD$ error 01244. Invalid data specified in packet.<br />

916 ER SUMOD$ error 01245. MFDF contains bad links.<br />

917 ER SUMOD$ error 01246. MFDF I/O error during read/write of file's<br />

lead or main item.<br />

918 ER SUMOD$ error 01247. Attached ACR does not exist <strong>for</strong> the<br />

specified owner.<br />

919 ER SUMOD$ error 0540. <strong>User</strong> ID specified does not exist in<br />

SYS$*SACRD$.<br />

920 ER SUMOD$ error 0542. <strong>User</strong> ID specified has been deleted.<br />

921 ER SUMOD$ error 01252. Bad packet length.<br />

922 ER SUMOD$ error 01253. New compartment set is not a subset of<br />

modifier's compartment set.<br />

923 Request requires the <strong>CIFS</strong> Security Server to complete, <strong>and</strong> the<br />

Security Server activity of the <strong>CIFS</strong> background run is not active.<br />

924 ER SUMOD$ error 01255. Attempt to modify privilege mask by a<br />

requestor not possessing the privilege to do so.<br />

925 ER SUMOD$ error 01256. Attempt to modify interface mask by a<br />

requestor not possessing the privilege to do so.<br />

926 ER SUMOD$ error 01257. Modifier failed write object security record<br />

access.<br />

B–4 7859 6137–009


Error Code Description<br />

Error Codes<br />

927 ER SUMOD$ error 01260. Attributes of the new owner <strong>and</strong> the object<br />

are not compatible.<br />

928 ER SUMOD$ error 01261. Ring number, subsystem level designator bit,<br />

<strong>and</strong> ACR count fields may be modified only when the user ID record is<br />

owned.<br />

929 ER SUMOD$ error 01262. Unowned shared file cannot have an ACR.<br />

930 ER SUMOD$ error 01263. Value specified <strong>for</strong> maximum ACR is out of<br />

bounds <strong>for</strong> the object or its owner.<br />

931 ER SUMOD$ error 01264. Owner of object <strong>and</strong> owner of ACR must be<br />

the same.<br />

932 ER SUMOD$ error 01265. The ring number, subsystem level, or<br />

designator bits are not in the owner's range.<br />

933 ER SUMOD$ error 01266. New owner does not exist or is deleted.<br />

934 ER SUMOD$ error 01267. The default compartment set is not a subset<br />

of the maximum compartment set.<br />

935 ER SUMOD$ error 01270. The table version number has changed <strong>and</strong><br />

has affected the supplied bit mask.<br />

936 ER SUMOD$ error 01271. ER SUMOD$ can only be per<strong>for</strong>med by the<br />

home subsystem.<br />

937 ER SUMOD$ error 01272. On Security Option 3 systems, when<br />

changing clearance level or compartment set, the file must be<br />

exclusively assigned unless it is in the to-be-catalogued state.<br />

938 ER SUMOD$ error 01273. On Security Option 3 systems, when<br />

changing clearance level or compartment set, only the caller can have<br />

other F-cycles assigned.<br />

939 ER SUMOD$ error 01274.<br />

940 Cannot mkdir with an existing Q*F specified via <strong>CIFS</strong>$NEXTFILE unless<br />

the current link count equals 2.<br />

941 Cannot mkdir with an existing Q*F specified via <strong>CIFS</strong>$NEXTFILE unless<br />

Q*F is a program file.<br />

942 <strong>CIFS</strong> encountered a conflict between a temporary file assigned to the<br />

caller's home name section <strong>and</strong> the cataloged file <strong>CIFS</strong> was requested<br />

to create.<br />

943 <strong>CIFS</strong> failed unowned file private by account check.<br />

944 <strong>CIFS</strong> failed unowned file private by project-id check.<br />

945 Failed <strong>CIFS</strong> read key check.<br />

946 Failed <strong>CIFS</strong> write key check.<br />

947 Failed <strong>CIFS</strong> security check due to data in the lead item or main item<br />

being slashed.<br />

948 An invalid <strong>OS</strong> <strong>2200</strong> MFD name was specified via <strong>CIFS</strong>$MFD.<br />

7859 6137–009 B–5


Error Codes<br />

Error Code Description<br />

949 An error occurred while <strong>CIFS</strong> was getting or putting an <strong>OS</strong> <strong>2200</strong><br />

environment variable.<br />

950 Failed <strong>CIFS</strong> ER SUVAL$ security check.<br />

951 File has read-only access <strong>and</strong> request requires write access.<br />

952 Security check could not be per<strong>for</strong>med due to G option file. <strong>CIFS</strong> does<br />

not support private unowned G option files or G option files with<br />

read/write keys.<br />

953 <strong>CIFS</strong>$ACR other than PUBLIC or PRIVATE not valid on FUNDAMENTAL<br />

Security systems.<br />

954 File size exceeds the <strong>CIFS</strong> maximum file size of 74898 <strong>OS</strong> <strong>2200</strong><br />

positions.<br />

955 Rename of qualifiers or file names in the /os<strong>2200</strong> directory hierarchy is<br />

not allowed.<br />

956 Files may not be created in the root directory, only directories.<br />

957 File has write-only access <strong>and</strong> request requires read access.<br />

960 Populate (of the /os<strong>2200</strong> directory) failed. The <strong>CIFS</strong> directory will not be<br />

in sync with the <strong>OS</strong> <strong>2200</strong> MFD.<br />

961 Populate is already running. Another run must be active.<br />

962 A request to the security server completed with status indicating it is<br />

still in progress.<br />

963 File was rolled out <strong>and</strong> ROLBAK inhibit was specified.<br />

964 <strong>CIFS</strong> attempted to assign a file <strong>and</strong> received status indicating the file<br />

was already assigned to <strong>CIFS</strong>.<br />

2000 : Operations on . or .. not allowed.<br />

2001 : Cannot change to directory .<br />

2002 : Cannot create directory .<br />

2003 : Failure to get working directory.<br />

2004 : Insufficient memory.<br />

2005 : Cannot remove directory .<br />

2006 : Directory not empty.<br />

2007 : Cannot remove . or .. directory entries.<br />

2008 : Unable to access object .<br />

2009 : Cannot open directory .<br />

2010 : Cannot close directory .<br />

2011 : is a directory.<br />

2012 : Cannot remove file .<br />

2013 : Cannot change to parent directory during directory<br />

B–6 7859 6137–009


Error Code Description<br />

traversal.<br />

2014 : Environment variable does not exist.<br />

2015 : Either setting or retrieval of the environment variable<br />

failed.<br />

2016 : Changing network share name failed.<br />

2017 : Copying multiple sources to a file<br />

2018 : Target not found.<br />

2019 : Target contains mask characters.<br />

2020 : Target same as source.<br />

2021 : Cannot create file .<br />

2022 : Cannot change user id.<br />

2023 : Cannot set file access time <strong>and</strong> modification time on<br />

.<br />

2024 : Cannot set mode on .<br />

2025 : Cannot open file .<br />

2026 : File I/O error.<br />

2027 : Option -r must be specified.<br />

2028 : Get stat on failed.<br />

2029 : Cannot close file.<br />

2030 : Attempt to link multiple sources to a file.<br />

2031 : Link of two directories not allowed.<br />

2032 : Attempt to link two existing files without -f specified.<br />

2033 : Link file fail.<br />

2034 : No filename specified with /s option.<br />

2035 : Error reading directory.<br />

2036 : More than one entry matches the mask.<br />

2037 : is not a directory.<br />

2038 : Attempt to move the source directory to itself.<br />

2039 : Cannot create directory .<br />

2040 : Cannot change owner on .<br />

2041 : Cannot get uid from .<br />

Error Codes<br />

2042 : Share name may not be useable due to length of<br />

more than 12 characters.<br />

2043 : Error retrieving <strong>CIFS</strong> subsystem identity.<br />

2044 : Error switching to kernel root directory.<br />

7859 6137–009 B–7


Error Codes<br />

Error Code Description<br />

2045 : @use name is longer than 12 characters.<br />

2046 : Path has no file-level container.<br />

2048 : Cannot move file .<br />

2049 : Specific file requested with recursion or<br />

extensions.<br />

2050 : Specified file is not SDF <strong>for</strong>mat.<br />

2051 : Rename of failed.<br />

2052 : Specified extension () must not<br />

be null or all periods.<br />

2053 : Time conversion error; value must be in<br />

"[[CC]YY]MMDDhhmm[:ss]" <strong>for</strong>mat.<br />

2054 : Option conflict; cannot specify both the<br />

-e option <strong>and</strong> the -n option.<br />

2055 : Cannot create FIFO .<br />

2056 : Cannot create FIFO .<br />

2057 : <strong>CIFS</strong> requires exclusive access to pack directory<br />

. Even your <strong>CIFS</strong>UT run cannot have the backing program file<br />

assigned.<br />

3000–3034 ZIPUT error <strong>and</strong> warnings.<br />

100000 Unrecognized errno: .<br />

B–8 7859 6137–009


Glossary<br />

/<br />

/os<strong>2200</strong> directory<br />

The directory in <strong>CIFS</strong> that contains an image of all files in the <strong>OS</strong> <strong>2200</strong> MFDs. Contrast<br />

with non-/os<strong>2200</strong> directory.<br />

A<br />

absolute (.abs)<br />

An <strong>OS</strong> <strong>2200</strong> element type. <strong>CIFS</strong> recognizes the file name extension .abs as indicative of<br />

an executable element.<br />

absolute reference<br />

A file path name reference that begins with a slash, indicating the root directory.<br />

access control record (ACR)<br />

A record containing lists of users <strong>and</strong> the user access to a file, tape, or subsystem, <strong>and</strong><br />

the conditions under which those users are allowed that access. You create ACRs by<br />

using SIMAN. Attaching an ACR to an object makes it semiprivate.<br />

application program interface (API)<br />

The interface (calling conventions) by which an application program accesses <strong>CIFS</strong><br />

services. An API is defined at source code level <strong>and</strong> provides a level of abstraction<br />

between the application <strong>and</strong> <strong>CIFS</strong> to ensure the portability of the code.<br />

ASCII<br />

B<br />

byte<br />

Abbreviation <strong>for</strong> American St<strong>and</strong>ard Code <strong>for</strong> In<strong>for</strong>mation Interchange: an 8–bit code<br />

used to represent data <strong>and</strong> certain control functions (such as a carriage return). ASCII is<br />

used in both computers <strong>and</strong> data communications. Unlike Fieldata, ASCII can represent<br />

both uppercase <strong>and</strong> lowercase letters, as well as numbers <strong>and</strong> special characters.<br />

Smallest granularity of file storage that <strong>CIFS</strong> manipulates. Bytes in <strong>OS</strong> <strong>2200</strong> are 9 bits<br />

wide, but only 8 bits on communications networks.<br />

7859 6137–009 Glossary–1


Glossary<br />

C<br />

clearance level<br />

A hierarchical classification <strong>for</strong> objects. Clearance levels can range from 0 to 63, with 63<br />

being the most restrictive. Clearance levels can also be associated with symbolic labels<br />

such as unclassified, classified, secret, <strong>and</strong> top secret.<br />

Common Internet File System (<strong>CIFS</strong>)<br />

<strong>CIFS</strong> is a file system that allows access to <strong>OS</strong> <strong>2200</strong> files through st<strong>and</strong>ard Internet<br />

protocols. The <strong>CIFS</strong> specification was created by Microsoft Corporation <strong>and</strong> is based on<br />

the existing Server Messages Block (SMB) protocol.<br />

control statement<br />

An instruction (such as in ECL <strong>and</strong> FURPUR) that directs the processing of a run. Control<br />

statements begin with a masterspace (@).<br />

current working directory<br />

The directory that the user is currently in. The current working directory can be displayed<br />

with the pwd or cd <strong>CIFS</strong>UT comm<strong>and</strong>s.<br />

cycle<br />

E<br />

element<br />

One of the stages a file or symbolic element goes through as it is updated. Cycles of<br />

files are called file cycles or F-cycles; cycles of symbolic elements are called element<br />

cycles or S-cycles. Each cycle can be identified with either an absolute cycle number,<br />

which never changes, or a relative cycle number, which changes as new cycles of a file<br />

or element are created.<br />

A part of a program file or element file, usually used to store a program or subprogram.<br />

Elements can contain either symbolic images or binary data such as machine-language<br />

instructions.<br />

Executive or Exec<br />

A software program on <strong>OS</strong> <strong>2200</strong> systems that processes user runs, controls files,<br />

manages system resources, <strong>and</strong> per<strong>for</strong>ms input/output operations <strong>for</strong> the user. The<br />

Exec, along with the System Control Software products, provide the<br />

hardware-independent environment in which other <strong>OS</strong> <strong>2200</strong> products execute.<br />

F<br />

Fieldata<br />

file<br />

A 6-bit character set originally developed <strong>for</strong> Unisys <strong>for</strong>erunner systems. It includes<br />

neither lower case letters nor any control characters.<br />

An organized collection of data, treated as a unit <strong>and</strong> stored so as to facilitate the<br />

retrieval of each individual data item. Files are retained on auxiliary storage devices.<br />

Glossary–2 7859 6137–009


Glossary<br />

file cycle (F-cycle)<br />

A generation (version) of a file. A new cycle of a file is created by using the relative cycle<br />

number +1. File cycles are sometimes called F-cycles.<br />

FURPUR<br />

Abbreviation <strong>for</strong> File Utility Routines/Program File Utility Routines.<br />

H<br />

host<br />

host-id<br />

I<br />

inode<br />

A host consists of a main storage memory, unique (local) peripheral <strong>and</strong> central complex<br />

devices, <strong>and</strong> operating system software.<br />

A single character (A, B, C, or D) that an <strong>OS</strong> <strong>2200</strong> identifies a host within a Multi-Host<br />

File Sharing system.<br />

An internal structure used to manage each file in the system. In<strong>for</strong>mation from an inode<br />

can be retrieved by using the ls <strong>and</strong> dir comm<strong>and</strong>s or the stat() <strong>and</strong> istat() functions.<br />

input/output (I/O)<br />

The process of transferring in<strong>for</strong>mation between the processor <strong>and</strong> peripheral devices.<br />

I/O devices include magnetic tapes, magnetic disks, consoles, card readers, printers, <strong>and</strong><br />

punches.<br />

K<br />

keyin<br />

M<br />

A sequence of characters entered from a console that requests in<strong>for</strong>mation or tells the<br />

Exec to per<strong>for</strong>m certain tasks.<br />

master file directory (MFD)<br />

The file catalog of the Exec. It is a directory maintained by the Exec to control permanent<br />

files. Files listed in the MFD are said to be cataloged <strong>and</strong> are retained even after a run<br />

terminates.<br />

7859 6137–009 Glossary–3


Glossary<br />

N<br />

node<br />

A system component.<br />

non-/os<strong>2200</strong> directory<br />

Any <strong>CIFS</strong> directory that is not the /os<strong>2200</strong> directory. Non-/os<strong>2200</strong> directories contain only<br />

the files placed in them by users. All files in non-/os<strong>2200</strong> directories also have an entry in<br />

the /os<strong>2200</strong> directory.<br />

O<br />

omnibus (.omn)<br />

An <strong>OS</strong> <strong>2200</strong> element type. <strong>CIFS</strong> recognizes the file name extension .omn as indicative of<br />

an omnibus element.<br />

P<br />

password<br />

A character string used to authenticate a user ID. A user must enter the correct<br />

password when signing on to the system. Each user ID has its own unique <strong>and</strong> private<br />

password associated with it. Passwords are used to prevent others from signing on the<br />

system with a user-id that is not their own.<br />

populate<br />

The process of updating the <strong>CIFS</strong> directories with in<strong>for</strong>mation from the Exec master file<br />

directories (MFDs).<br />

position<br />

P<strong>OS</strong>IX<br />

An increment <strong>for</strong> measuring mass storage space, equal to 64 tracks, 4,096 sectors, or<br />

114,688 words, 458,752 bytes.<br />

Portable operating system interfaces. A set of IEEE st<strong>and</strong>ards designed to provide<br />

application portability among UNIX variants.<br />

privilege<br />

The mechanism that lets specified users override restrictions <strong>and</strong> validations.<br />

Q<br />

qualifier<br />

A string of characters used to prefix a file name to make sure that the name is unique.<br />

The qualifier is separated from the basic file name with an asterisk (<strong>for</strong> example,<br />

QUAL*FILE). If the user does not provide a qualifier when a file is named, the system<br />

uses the user’s project–id.<br />

Glossary–4 7859 6137–009


R<br />

relative reference<br />

A file path name reference that is relative to the current working directory.<br />

Glossary<br />

relocatable element (.rel)<br />

An <strong>OS</strong> <strong>2200</strong> element type. <strong>CIFS</strong> recognizes the file name extension as indicative of a<br />

relocatable element.<br />

S<br />

SDF<br />

Symbolic element (SDF). Default <strong>for</strong> <strong>CIFS</strong>-created files if a type is not explicitly specified.<br />

security management product<br />

The product used to manage security on <strong>OS</strong> <strong>2200</strong> systems—either Security<br />

Administration <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> or SIMAN.<br />

Security Administration <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong> <strong>2200</strong> is a product <strong>for</strong> controlling <strong>and</strong><br />

administering <strong>OS</strong> <strong>2200</strong> security. It has a Security Client <strong>for</strong> creating <strong>and</strong> modifying<br />

system, application, <strong>and</strong> user security records from a remote Windows or LINUX or UNIX<br />

workstation. <strong>Administrator</strong>s use this application to configure security features, set up<br />

user-ids, <strong>and</strong> control access to system resources. Nonadministrators can use it to view<br />

or modify their individual security records. A batch processor (@SECMGR) provides a<br />

batch/dem<strong>and</strong> interface to per<strong>for</strong>m those same administrator or end-user operations at<br />

an <strong>OS</strong> <strong>2200</strong> terminal. Communication between the remote Security Client workstations<br />

<strong>and</strong> the <strong>OS</strong> <strong>2200</strong> host is enabled by an SNMP agent running on the host.<br />

Site Management Complex (SIMAN) is the TeamQuest interactive software product that<br />

provides a tool with a menu-driven interface <strong>for</strong> creating <strong>and</strong> maintaining security <strong>and</strong><br />

resource control in an <strong>OS</strong> <strong>2200</strong> system. You can set up security <strong>for</strong> the whole system,<br />

<strong>for</strong> a particular application, or <strong>for</strong> individual user security.<br />

server message block protocol (SMB)<br />

Server message block (SMB) protocol is a client/server request/response protocol <strong>for</strong><br />

sharing files, printers, serial ports, <strong>and</strong> communication abstractions.<br />

W<br />

word<br />

A sequence of bits or characters treated as a unit that can be stored in a single main<br />

storage location (an <strong>OS</strong> <strong>2200</strong> word by contains 36 bits).<br />

working directory<br />

See current working directory.<br />

7859 6137–009 Glossary–5


Glossary<br />

Glossary–6 7859 6137–009


Index<br />

A<br />

absolute<br />

element type (.abs), 1-8<br />

pathname resolution, 3-9<br />

reference, 1-6<br />

access<br />

control records (ACRs), 3-15<br />

permissions, 1-10<br />

to data, 1-11<br />

access() function, 5-6<br />

administrative tasks, 9-1<br />

advisory<br />

record locking, 3-26<br />

advisory record lock, deadlocks, 3-28<br />

alias, 1-2, 1-7<br />

APIs <strong>for</strong> file filtering, 9-26<br />

associate specific file descriptor index with<br />

existing open file description, 5-19,<br />

6-23<br />

associate stream with pathname, 5-42, 6-50<br />

attributes of open file description, 3-11<br />

audience, 1-3<br />

B<br />

background run options, 9-8<br />

backup comm<strong>and</strong>, 4-4<br />

binary <strong>for</strong>mat, 3-21<br />

binjar comm<strong>and</strong>, 4-5<br />

C<br />

C API table, 5-1<br />

case, h<strong>and</strong>ling of, 1-5<br />

cat (type), 4-6<br />

cd comm<strong>and</strong>, 4-7<br />

change<br />

current working directory, 4-7, 5-8, 6-8<br />

file permissions, 4-8, 5-9<br />

logical length of a file, 4-32<br />

owner of file or directory, 4-10<br />

pathname of existing file or<br />

directory, 5-111, 6-119<br />

change access time <strong>and</strong> modification time file<br />

or directory, 5-132, 6-147<br />

character file, 3-1<br />

characteristics of<br />

a file hierarchy, 3-6<br />

locks, 3-27<br />

chdir comm<strong>and</strong>, 4-7<br />

chdir() function, 5-8<br />

chmod comm<strong>and</strong>, 4-8<br />

chmod() function, 5-9<br />

chown comm<strong>and</strong>, 4-10<br />

<strong>CIFS</strong> background run, 9-6<br />

<strong>CIFS</strong> components, 1-1<br />

<strong>CIFS</strong> diagram, 1-2<br />

<strong>CIFS</strong> subsystem user-id, 9-4<br />

<strong>CIFS</strong> TRACE, 9-9<br />

cifs$access service subprogram, 6-5<br />

<strong>CIFS</strong>$ACR, 3-32<br />

<strong>CIFS</strong>$CACHE, 3-32, 9-21<br />

<strong>CIFS</strong>$CAT, 3-32<br />

<strong>CIFS</strong>$CD, 3-32<br />

cifs$chdir service subprogram, 6-8<br />

cifs$chown service subprogram, 6-12<br />

cifs$clearerr service subprogram, 6-14<br />

cifs$close service subprogram, 6-15<br />

cifs$closedir service subprogram, 6-17<br />

<strong>CIFS</strong>$COMAPI, 3-33<br />

cifs$creat service subprogram, 6-19<br />

cifs$dup service subprogram, 6-21<br />

cifs$dup2 service subprogram, 6-23<br />

cifs$fclose service subprogram, 6-25<br />

cifs$fcntl service subprogram, 6-26<br />

cifs$fdatasync service subprogram, 6-39<br />

cifs$fdopen service subprogram, 6-41<br />

cifs$feof service subprogram, 6-43<br />

cifs$ferror service subprogram, 6-44<br />

cifs$fflush service subprogram, 6-45<br />

cifs$fgetc service subprogram, 6-46<br />

cifs$fgetpos service subprogram, 6-47<br />

cifs$fgets service subprogram, 6-48<br />

7859 6137–009 Index–1


Index<br />

cifs$fileno service subprogram, 6-49<br />

cifs$fopen service subprogram, 6-50<br />

cifs$fprintf service subprogram, 6-52<br />

cifs$fputc service subprogram, 6-57<br />

cifs$fputs service subprogram, 6-58<br />

cifs$fread service subprogram, 6-59<br />

cifs$freopen service subprogram, 6-61<br />

cifs$fscanf service subprogram, 6-63<br />

cifs$fseek service subprogram, 6-67<br />

cifs$fsetpos service subprogram, 6-68<br />

cifs$fstat service subprogram, 6-69<br />

cifs$fsync service subprogram, 6-71<br />

cifs$ftell service subprogram, 6-72<br />

cifs$ftruncate service subprogram, 6-73<br />

cifs$fwrite service subprogram, 6-74<br />

cifs$getc service subprogram, 6-75<br />

cifs$getchar service subprogram, 6-75<br />

cifs$getcwd service subprogram, 6-77<br />

cifs$gets service subprogram, 6-78<br />

cifs$istat service subprogram, 6-79<br />

<strong>CIFS</strong>$KEYS, 3-33<br />

cifs$link service subprogram, 6-81<br />

cifs$lseek service subprogram, 6-84<br />

cifs$mask service subprogram, 6-87<br />

<strong>CIFS</strong>$MFD, 3-33<br />

cifs$mkdir service subprogram, 6-88<br />

cifs$mkfifo service subprogram, 6-90<br />

<strong>CIFS</strong>$NEXTFILE, 1-8, 3-33<br />

cifs$open service subprogram, 6-92<br />

cifs$opendir service subprogram, 6-100<br />

<strong>CIFS</strong>$PACK, 6-102<br />

cifs$perror service subprogram, 6-104<br />

cifs$pipe service subprogram, 6-105<br />

cifs$printf service subprogram, 6-107<br />

cifs$putc service subprogram, 6-108<br />

cifs$putchar service subprogram, 6-109<br />

cifs$puts service subprogram, 6-110<br />

<strong>CIFS</strong>$RAW, 3-33<br />

cifs$read service subprogram, 6-111<br />

cifs$readdir service subprogram, 6-115<br />

cifs$remove service subprogram, 6-118<br />

cifs$rename service subprogram, 6-119<br />

cifs$rewind service subprogram, 6-123<br />

cifs$rewinddir service subprogram, 6-124<br />

cifs$rmdir service subprogram, 6-126<br />

cifs$scanf service subprogram, 6-128, 6-129<br />

cifs$share service subprogram, 6-129<br />

cifs$sprintf service subprogram, 6-130<br />

cifs$sscanf service subprogram, 6-131<br />

cifs$stat service subprogram, 6-132<br />

cifs$stderr service subprogram, 6-134<br />

cifs$stdin service subprogram, 6-135<br />

cifs$stdout service subprogram, 6-136<br />

cifs$strerror service subprogram, 6-137<br />

<strong>CIFS</strong>$SUBTYPE, 3-33<br />

cifs$tmpfile service subprogram, 6-138<br />

cifs$tmpnam service subprogram, 6-139<br />

cifs$truncate service subprogram, 6-140<br />

cifs$umask service subprogram, 6-141<br />

cifs$uname service subprogram, 6-143<br />

cifs$ungetc service subprogram, 6-144<br />

cifs$unlink service subprogram, 6-145<br />

cifs$utime service subprogram, 6-147<br />

cifs$write service subprogram, 6-150<br />

cifs$xlate service subprogram, 6-155<br />

<strong>CIFS</strong>-DEACT, 9-8<br />

<strong>CIFS</strong>-F-DUPFD, 6-31<br />

<strong>CIFS</strong>HI, 1-1<br />

<strong>CIFS</strong>LIB, 1-1<br />

<strong>CIFS</strong>UT, 1-1<br />

class permission values, 3-20<br />

clear<br />

end-of-file indicators <strong>for</strong> the stream, 5-13,<br />

6-14<br />

error indicators <strong>for</strong> the stream, 5-13, 6-14<br />

clearance level, 9-11<br />

clearerr() function, 5-13<br />

close an open directory stream, 5-15, 6-17<br />

close() function, 5-14<br />

closedir() function, 5-15<br />

COBOL API table, 6-1<br />

common permission assignments, 3-16<br />

communications interface, 1-11<br />

compartment set, 9-11<br />

components, <strong>CIFS</strong>, 1-1<br />

conflicts with file access specification, 3-27<br />

consolidating servers, 9-26<br />

conversion specifications, 5-44, 6-53<br />

convert files from SDF to binary, 4-5<br />

copy a file or directory to a target, 4-11<br />

copy comm<strong>and</strong>, 4-11<br />

cp comm<strong>and</strong>, 4-11<br />

creat() function, 5-16<br />

create<br />

additional file descriptor, 5-18, 6-21<br />

directory, 4-22, 5-82, 6-88<br />

directory entries <strong>for</strong> file, 5-75, 6-81<br />

file, 5-16, 6-19<br />

file mode creation mask, 5-127, 6-141<br />

network-visible name <strong>for</strong> a directory, 4-31<br />

new FIFO file, 5-84, 6-90<br />

pipe, 5-98, 6-105<br />

share directory, 2-3<br />

stream <strong>and</strong> associate file descriptor, 5-34,<br />

6-41<br />

temporary binary file, 5-124, 6-138<br />

Index–2 7859 6137–009


creation mask, file mode, 3-19<br />

current working directory, 1-6, 3-8, 0-2<br />

D<br />

data<br />

access privileges, 1-11<br />

storage, 1-8<br />

data access security <strong>and</strong> network<br />

connections, 2-2<br />

deadlock, 3-28<br />

default working directory, 2-3<br />

delete a specific directory <strong>and</strong> all files <strong>and</strong><br />

subdirectories, 4-14<br />

deltree comm<strong>and</strong>, 4-14<br />

determine<br />

if a file exists, 5-6, 6-5<br />

permission, 5-6, 6-5<br />

dir comm<strong>and</strong>, 4-19<br />

directories synchronized, 9-2<br />

directory, 3-4<br />

/dev, 1-7<br />

/os<strong>2200</strong>, 1-6<br />

create, 4-22<br />

entry, 3-4, 3-25<br />

main_dir, 3-4<br />

name length, 1-5<br />

non-/os<strong>2200</strong>, 1-7<br />

rename, 5-113, 6-121<br />

stream, 3-25<br />

directory structure of <strong>CIFS</strong>, 1-5<br />

directory, files, <strong>and</strong> links diagram, 3-5<br />

display environmental variables, 4-29<br />

display system environmental variables, 4-30<br />

dot file, 3-8<br />

dot-dot file, 3-8<br />

dup() function, 5-18<br />

dup2() function, 5-19<br />

duplicate file descriptor, 5-27, 6-31<br />

E<br />

E keyin, 9-8<br />

E1100CORRUPT, 5-96<br />

E1100INTERNAL, 5-96<br />

EACCES, 5-95<br />

EBUSY, 5-96<br />

EFAULT, 5-95<br />

EIO, 5-96<br />

Index<br />

elements placed in SYS$LIB$*<strong>CIFS</strong>$LIB<br />

during installation, 9-1<br />

ENONMEM, 5-96<br />

ENOTDIR, 5-96<br />

environment variables<br />

initial values, 9-21<br />

table, 3-32<br />

environmental variables, display, initialize, or<br />

update, 4-29<br />

examples or valid pathnames, 3-7<br />

exclusive locks, 3-27<br />

execute permission, 3-14<br />

7859 6137–009 Index–3<br />

F<br />

F_DUPFD, 5-27<br />

fclose() function, 5-21<br />

fcntl() function, 5-22<br />

fdatasync() function, 5-33<br />

fdopen() function, 5-34<br />

feof() function, 5-35<br />

ferror() function, 5-36<br />

fflush() function, 5-37<br />

fgetc() function, 5-38<br />

fgetpos() function, 5-39<br />

fgets() function, 5-40<br />

Fieldata, 1-8, 5-106, 6-114<br />

file<br />

access<br />

specification, 3-12<br />

attributes, 1-10<br />

character, 3-1<br />

concepts, 3-1<br />

definition <strong>and</strong> file types, 3-1<br />

descriptor, 3-13<br />

descriptor services, 5-27, 6-31<br />

dot, 3-8<br />

dot-dot, 3-8<br />

<strong>for</strong>mat, 3-21<br />

hierarchy, 3-6<br />

name length, 1-5<br />

permissions, 3-14, 3-19<br />

pipe, 3-2<br />

regular, 3-1<br />

renaming, 5-112, 6-121<br />

status flags, 3-11<br />

status flags <strong>and</strong> access specification<br />

services, 5-27, 6-32<br />

system structure, 1-5<br />

type, 3-21<br />

file access


Index<br />

by multiple processes, 3-24<br />

File Assignment, 9-22<br />

file descriptor closure mode services, 5-27<br />

file filtering, 9-26<br />

APIs, 9-26<br />

File I/O Buffer Cache, 9-21<br />

file mode, 3-18<br />

filename, 3-2<br />

fileno() function, 5-41<br />

files deleted by @CYCLE, 9-3<br />

filtering files in a consolidated server<br />

environment, 9-26<br />

flock structure, 5-25, 6-29<br />

fopen() function, 5-42<br />

<strong>for</strong>mat string, 5-44, 5-53, 6-52, 6-63<br />

<strong>for</strong>ward slash, 1-6, 1-7<br />

fprintf() function, 5-44<br />

fputc() function, 5-49<br />

fputs() function, 5-50<br />

fread() function, 5-51<br />

freopen() function, 5-52<br />

fscanf() function, 5-53<br />

fseek() function, 5-57<br />

fsetpos() function, 5-58<br />

fstat() function, 5-59<br />

fsync() function, 5-61<br />

ftell() function, 5-62<br />

ftruncate() function, 5-63<br />

FURPUR @PACK, 4-33<br />

fwrite() function, 5-64<br />

G<br />

generate string to use as filename, 5-125,<br />

6-139<br />

get<br />

current value of file position indicator, 5-39,<br />

6-47<br />

current value of stream file position<br />

indicator, 5-62, 6-72<br />

next character from input stream, 5-38,<br />

5-65, 6-46, 6-75<br />

next character from st<strong>and</strong>ard input, 5-66,<br />

6-75<br />

GET$ENV, 3-32<br />

getc() function, 5-65<br />

getchar() function, 5-66<br />

getcwd() function, 5-67<br />

gets() function, 5-71<br />

group activities into logical processes, 5-20<br />

Index–4 7859 6137–009<br />

I<br />

i, 9-15<br />

I/O operations, file, 3-24<br />

identify process' current working<br />

directory, 5-67, 6-77<br />

implementation of SMB, 1-11<br />

inheriting file mode creation mask, 3-19<br />

initial values <strong>for</strong> environment variables, 9-21<br />

initialize environmental variables, 4-29<br />

initialize system environmental variables, 4-30<br />

input <strong>and</strong> output (I/O) operations <strong>and</strong><br />

functions, 3-31<br />

istat() function, 5-73<br />

K<br />

keys comm<strong>and</strong>, 4-17<br />

L<br />

limitations, A-1<br />

link, 3-4<br />

link count, 3-4<br />

link() function, 5-75<br />

ln comm<strong>and</strong>, 4-18<br />

lock or unlock an entire file, 5-27, 6-31<br />

lock request failure, 3-27<br />

locking, records, 3-26<br />

log entries, type 801, 9-11<br />

ls comm<strong>and</strong>, 4-19<br />

lseek() function, 5-78<br />

M<br />

main_dir directory, 3-4<br />

make open directory stream inaccessible to<br />

calling process, 5-15, 6-17<br />

manage an open file, 5-22, 6-26<br />

managing files from the workstation, 2-1<br />

map drive to share directory, 2-4<br />

masking with @<strong>CIFS</strong>UT, 4-3<br />

md comm<strong>and</strong>, 4-22<br />

merge adjacent locks, 5-27, 6-31<br />

Microsoft networks redirector, 2-2<br />

mkdir comm<strong>and</strong>, 4-22<br />

mkdir() function, 5-82<br />

mkfifo() function, 5-84


mode argument, 3-19, 5-93, 6-98<br />

Monitor Services, 9-2<br />

move a file, 4-24<br />

move comm<strong>and</strong>, 4-24<br />

mv comm<strong>and</strong>, 4-24<br />

N<br />

networking <strong>CIFS</strong> with Windows, 2-1<br />

networking implementation, 2-2<br />

network-visible name<br />

create share, 4-31<br />

remove share, 4-35<br />

node, 3-6<br />

non-/os<strong>2200</strong> directory hierarchy, 1-7<br />

notation conventions, 1-4<br />

O<br />

oflag argument, 5-90, 6-95<br />

omnibus element type (.omn), 1-8, 0-1, 0-4<br />

open<br />

directory stream, 5-94, 6-100<br />

file, 5-87, 6-92<br />

new file, 5-16, 6-19<br />

pathname, 5-42, 6-50<br />

pathname <strong>and</strong> associate stream, 5-52, 6-61<br />

open file<br />

description, 3-11<br />

descriptions time in<strong>for</strong>mation, 3-17<br />

in<strong>for</strong>mation, 3-18<br />

open() function, 5-87<br />

opendir() function, 5-94<br />

P<br />

pack(), 5-95<br />

parent directory, 3-8<br />

pathname, 3-7<br />

pathname resolution, 3-9<br />

permission mask, 3-16<br />

perror() function, 5-97<br />

Persistent Connections, 2-3<br />

pipe, 3-2<br />

using, 3-29<br />

pipe file, 3-2<br />

pipe() function, 5-98<br />

populate, 9-4<br />

prevent access to a file, 5-14, 6-15<br />

Index<br />

print message corresponding to error, 5-97,<br />

6-104<br />

printf() function, 5-100<br />

private files, 3-15<br />

protecting data against loss from system<br />

outage, 5-61, 6-71<br />

public files, 3-15<br />

PUT$ENV, 3-32<br />

putc() function, 5-101<br />

putchar() function, 5-102<br />

puts() function, 5-103<br />

7859 6137–009 Index–5<br />

R<br />

rd comm<strong>and</strong>, 4-28<br />

read<br />

current entry in directory stream, 5-107,<br />

6-115<br />

data from a file, 5-104, 6-111<br />

elements from input stream to array, 5-51,<br />

6-59<br />

<strong>for</strong>matted input, 5-53, 6-63<br />

<strong>for</strong>matted input from st<strong>and</strong>ard<br />

input, 5-118, 6-128<br />

<strong>for</strong>matted input from string, 5-121, 6-131<br />

next character from input stream to<br />

array, 5-40, 6-48<br />

permission, 3-14<br />

read() function, 5-104<br />

read/write offset, 3-11<br />

readdir() function, 5-107<br />

reading or writing data to <strong>CIFS</strong> files, 3-24<br />

realpath() function, 5-109<br />

record locking, 3-26<br />

services, 5-30, 6-35<br />

redirecting st<strong>and</strong>ard files to pipes, 5-18, 5-99,<br />

6-21, 6-106<br />

reference one file in multiple ways, 5-75, 6-81<br />

regular file, 3-1<br />

relative pathname resolution, 3-10<br />

release certain file attributes, 5-14, 6-15<br />

release grouped activities, 5-86<br />

relocatable element type (.rel), 1-8, 0-1, 0-4<br />

remove<br />

empty directory, 4-28, 5-117, 6-126<br />

file, 5-110, 6-118<br />

link from file, 5-131, 6-145<br />

network-visible name <strong>for</strong> a directory, 4-35<br />

remove() function, 5-110<br />

removing locks, 3-28<br />

rename


Index<br />

directory, 5-113, 6-121<br />

files, 4-24, 5-112, 6-121<br />

rename() function, 5-111<br />

replace the previous lock, 5-27, 6-31<br />

replacing <strong>and</strong> merging locks, 3-28<br />

reposition directory stream at<br />

beginning, 5-116, 6-124<br />

restrictions, A-1<br />

restrictions <strong>for</strong> file<br />

descriptors, 3-13<br />

<strong>for</strong>mat attributes, 3-21<br />

retrieve<br />

<strong>CIFS</strong>-unique in<strong>for</strong>mation about <strong>CIFS</strong> file or<br />

directory, 5-73, 6-79<br />

file descriptor, 5-41, 6-49<br />

in<strong>for</strong>mation about open file, 5-59, 5-122,<br />

6-69, 6-132<br />

return<br />

character to the input stream, 5-130, 6-144<br />

fully resolved name of specified file, 5-109<br />

rewind() function, 5-115<br />

rewinddir() function, 5-116<br />

rmdir comm<strong>and</strong>, 4-28<br />

rmdir() function, 5-117<br />

root directory, 3-6<br />

rules <strong>for</strong><br />

creating directories, 3-4<br />

pathnames, 3-7<br />

S<br />

save <strong>CIFS</strong> directory structure, 4-4<br />

scanf() function, 5-118<br />

SDF elements, 1-8<br />

search/execute permission, 3-14<br />

securing data to disk storage, 3-24<br />

Security Administration <strong>for</strong> <strong>ClearPath</strong> <strong>OS</strong><br />

<strong>2200</strong>, See security management<br />

product<br />

security considerations, 1-10<br />

security management product, 4-30, 9-21<br />

security policy en<strong>for</strong>cement, 9-11<br />

server message block (SMB), 1-11<br />

servers, consolidating, 9-26<br />

set<br />

end-of-file position <strong>for</strong> file, 5-126, 6-140<br />

end-of-file position <strong>for</strong> open file, 5-63, 6-73<br />

file position indicator to beginning of<br />

stream, 5-115, 6-123<br />

permissions, 3-20<br />

stream file position indicator, 5-57, 5-58,<br />

6-67, 6-68<br />

the read/write offset <strong>for</strong> open file, 5-78,<br />

6-84<br />

set comm<strong>and</strong>, 4-29<br />

set the file mode creation mask, 5-127, 6-142<br />

setsys comm<strong>and</strong>, 4-30<br />

share<br />

names, 1-11<br />

reference, 1-11<br />

share comm<strong>and</strong>, 4-31<br />

shared locks, 3-27<br />

size comm<strong>and</strong>, 4-32<br />

SMB protocol, 1-11<br />

specify network-visible name <strong>for</strong><br />

directory, 5-119, 6-129<br />

sprintf() function, 5-120<br />

sscanf() function, 5-121<br />

SSCONSOLE, 9-4<br />

SSRUNXOPT, 9-5<br />

ST keyin, 9-4, 9-7<br />

st<strong>and</strong>ard<br />

error, 3-13<br />

input, 3-13<br />

output, 3-13<br />

starting the <strong>CIFS</strong> background run, 9-5<br />

stat structure table, 5-59<br />

stat() function, 5-122<br />

status of advisory record locks, 3-26<br />

stderr, 3-13<br />

stdin, 3-13<br />

stdout, 3-13<br />

stop the <strong>CIFS</strong> background run, 9-7<br />

subordinate directory, 3-4<br />

system data <strong>for</strong>mat (SDF), 3-21<br />

system environmental variables, display,<br />

initialize, or update, 4-30<br />

system recovery, 9-6<br />

Index–6 7859 6137–009<br />

T<br />

TCP port, 2-2<br />

test<br />

end of file <strong>for</strong> stream, 5-35, 6-43<br />

<strong>for</strong> file type, 3-22<br />

<strong>for</strong> read/write error, 5-36, 6-44<br />

text-based utility, <strong>CIFS</strong>, 4-1<br />

time dependent environment variables, 9-22<br />

time in<strong>for</strong>mation, 3-17<br />

TIMEBASE environment variable, 9-22<br />

TIP considerations, 1-12


tmpfile() function, 5-124<br />

tmpnam() function, 5-125<br />

truncate() function, 5-126<br />

type 801 log entry, 9-11<br />

types of file permissions, 3-14<br />

TZ environment variable, 9-22<br />

U<br />

umask() function, 5-127<br />

UNC, 2-1, 2-5<br />

ungetc() function, 5-130<br />

universal naming convention, 2-1, 2-5<br />

unlink() function, 5-131<br />

unlocks whole files, 3-27<br />

unshare comm<strong>and</strong>, 4-35<br />

update environmental variables, 4-29<br />

update system environmental variables, 4-30<br />

URTS I/O h<strong>and</strong>ling, 1-8<br />

use comm<strong>and</strong>, 4-36<br />

user-id <strong>for</strong> <strong>CIFS</strong>, 9-4<br />

using<br />

advisory record locks, 3-27<br />

directory streams, 3-25<br />

file descriptors, 3-13<br />

file permissions, 3-17<br />

pipes, 3-29<br />

the file mode, 3-19<br />

utility comm<strong>and</strong> list, 4-2<br />

utility interfaces, 4-1<br />

utimbuf structure, 5-133, 6-148<br />

utime() function, 5-132<br />

V<br />

valid filenames, example, 3-3<br />

version comm<strong>and</strong>, 4-37<br />

vfprintf() function, 5-135<br />

viewing <strong>CIFS</strong> files, 2-7<br />

vprintf() function, 5-136<br />

vsprintf() function, 5-137<br />

Index<br />

7859 6137–009 Index–7<br />

W<br />

what <strong>CIFS</strong> does, 1-2<br />

working directory, 3-8<br />

write<br />

characters to output stream, 5-49, 5-101,<br />

6-57, 6-108<br />

characters to st<strong>and</strong>ard output, 5-102, 6-109<br />

data currently in buffer cache <strong>for</strong> file, 5-61,<br />

6-71<br />

data in buffer without closing file, 5-37,<br />

6-45<br />

data to file at current read/write<br />

position, 5-138, 6-150<br />

elements to output stream, 5-64, 6-74<br />

<strong>for</strong>matted output, 5-44, 5-135, 6-52<br />

<strong>for</strong>matted output to character array, 5-120,<br />

5-137, 6-130<br />

<strong>for</strong>matted output to st<strong>and</strong>ard<br />

output, 5-100, 5-136, 6-107<br />

in<strong>for</strong>mation to st<strong>and</strong>ard output, 4-19<br />

permission, 3-14<br />

remaining data to file <strong>and</strong> close file, 5-21,<br />

6-25<br />

string of characters to st<strong>and</strong>ard<br />

output, 5-103, 6-110<br />

string to output stream, 5-50, 6-58<br />

write all data currently in portion of buffer<br />

cache <strong>for</strong> file, 5-33, 6-39<br />

write() function, 5-138<br />

X<br />

xlate comm<strong>and</strong>, 4-38<br />

Special Characters<br />

/os<strong>2200</strong> directory hierarchy, 1-6<br />

@<strong>CIFS</strong>UT, 4-1


Index<br />

Index–8 7859 6137–009


© 2009 Unisys Corporation.<br />

All rights reserved.<br />

*78596137-009*<br />

7859 6137–009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!