WikiPendium

(beta)

Fcntl()

WikiPendium :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-18-191-228-88.us-east-2.compute.amazonaws.com

Fcntl()

(File control)

LONG Fcntl( handle, arg, cmd )

WORD handle;
LONG arg;
WORD cmd;

Fcntl() executes a given operation on a file.

Opcode

260 (0x104)

Availability

All MiNT versions.

Parameters

handle is the handle of file opened by Fopen()?.
arg is either a long value or a pointer to a structure needed by the command, or NULL if unused.
cmd is the command to perform.

Binding

	move.w	cmd,-(sp)
	move.l	arg,-(sp)
	move.w	handle,-(sp)
	move.w	#$104,-(sp)
	trap	#1
	lea	10(sp),sp


Return Value

The LONG value contains 0 if the operation was successful, or a negative error code.

Commands and arguments


File specific commands
cmd (name) cmd (value) arg Operation
F_DUPFD 0x0000 Minimum value for returned handle Duplicate the file handle. The return value will be between arg and 32.
F_GETFD 0x0001 NULL (arg is ignored) Return the inheritance flag for the file. 1 means that child processes started with Pexec() will inherit this file handle, otherwise 0 is returned.
F_SETFD 0x0002 0: don't inherit,
1: inherit
Set the inheritance flag for the file.
F_GETFL 0x0003 NULL (arg is ignored) Return the file descriptor flags for the specified file. These are the same flags passed to Fopen()?.
F_SETFL 0x0004 Flags to be specified for the file decriptor Set the file decriptor flags for the specified file to arg. Only user-modifyable bits are considered and all others should be 0. It is not possible to change a file's read/write mode or sharing modes with this call. Attempts to do this will fail without returning an error code.
F_GETLK 0x0005 Points to a FLOCK structure Test for the presence of a lock on the specified file. If a prior lock exists which would prevent the specified lock from being applied, the interfering lock is copied into the structure with the process ID of the locking process. Otherwise, Fcntl() returns F_UNLCK (3).
F_SETLK 0x0006 Points to a FLOCK structure Set or remove an advisory lock on the specified file.
Setting l_type to F_RDLOCK (0) or F_WRLCK (1) will cause a lock to be set. Setting l_type to F_UNLCK (3) wil attempt to remove the specified lock. When locking and unlocking FIFO's, l_whence, l_start, and l_len should be 0. The command returns 0 if successful or a negative GEMDOS error code otherwise.
F_SETLKW 0x0007 Points to a FLOCK structure The calling procedure is the same as above, however, if other processes already have a conflicting lock set, it will suspend the calling process until the lock is freed.
FSTAT 0x4600 Points to a XATTR structure which is filled in with the file's extended attributes Get the extended attributes for a file. If successful, the function returns 0, otherwise a negative GEMDOS error code is returned.
FIONREAD 0x4601 Points to a LONG where the estimated number will be put Return (in the LONG pointed to by arg) an estimate of the number of bytes available for reading from the specified file without causing the process to block (while waiting for more input).
FIONWRITE 0x4602 Points to a LONG where the estimated number will be put Return (in the LONG pointed to by arg) an estimate of the number of bytes that may be written to the specified file without causing the process to block.
FUTIME 0x4603
FTRONCATE 0x4604
FIOEXCEPT 0x4605

Shared memory specific commands
cmd (name) cmd (value) arg Operation
SHMGETBLK 0x4d00 NULL (for future compatibility) Returns the address of the memory block associated to the file.
Note: Different processes may reveive different addresses for a shared block.
SHMSETBLK 0x4d01 Address of an allocated memory block to be associated with the file Associate a block of memory with the file. The file must have been created in u:\shm\ before this call.

Process specific commands
cmd (name) cmd (value) arg Operation
PPROCADDR 0x5001 Points to a LONG Return (in the LONG pointed by arg) the offset of the control structure of the specified process (opened as a file). See the discussion of MiNT processes for information about this structure (StabyloRmv: couldn't find this structure in the specified section).
PBASEADDR 0x5002 Points to a LONG Return (in the LONG pointed by arg) the offset of the GEMDOS basepage of the specified process (opened as a file).
PCTXTSIZE 0x5003 Points to a LONG Return (in the LONG pointed by arg) the length of the context structure of the specified process (opened as a file).

Two context structures are located at the end of the control structure (they are the current user context and the last system context of the process). This means that seeking to the offset returned by PPROCADDR minus this number (returned by PCTXTSIZE) and reading this many bytes will yield the current user context of the process. Seeking back this many bytes more and reading the same amount of bytes will yield the last system context of the process. This structure is volatile and is likely to change from one MiNT version to the next.
PSETFLAGS 0x5004 Points to a LONG The process memory allocation flags (PRGFLAGS?) will be set from the LONG pointed by arg.
PGETFLAGS 0x5005 Points to a LONG The process memory allocation flags (PRGFLAGS) will be placed into the LONG pointed by arg.
PTRACEGFLAGS 0x5006 Points to a WORD The trace flags of the specified process (opened as a file) will be placed into the WORD pointed by arg.

Setting bit #0 of arg causes the parent process to receive signals destined for the child. See the discussion on program debugging for more information.
PTRACESFLAGS 0x5007 Points to a WORD The trace flags of the specified process (opened as a file) will be set to the WORD value pointed by arg.

See the discussion on program debugging for more information.
PTRACEGO 0x5008 Points to a WORD This call restarts a process which was stopped because of a signal. The WORD pointed by arg contains the signal value to send to the process or 0 to clear all of the child processes' pending signals.
PTRACEFLOW 0x5009 0 or a signal value This call restarts a process in a special tracing mode in which the process is stopped and a SIGTRACE signal is generated whenever program flow changes (ex: JSR/BSR/JMP/BEQ). If arg is 0, then all the pending signals of the process being traced are cleared. Otherwise, arg is a signal value which is to be sent to the child.
PTRACESTEP 0x500a NULL This call restarts a process and allows it to execute one instruction before a SIGTRAP instruction is generated.
PTRACE11 0x500b
PLOADINFO 0x500c Points to a ploadinfo structure The cmdlin field (see ploadinfo) points to a 128 byte character buffer into which the process command line will be copied. The fname field (see ploadinfo) points to a buffer fnamelen bytes long into which the complete path and filename of the process' parent will be copied. If the buffer is too short, the call will return ENAMETOOLONG.
PFSTAT 0x500d

Socket specific commands
cmd (name) cmd (value) arg Operation
SIOCGLOWAT 0x5301
SIOCSLOWAT 0x5302
SIOCGHIWAT 0x5303
SIOCSHIWAT 0x5304
SIOCSPGRP 0x5305
SIOCGPGRP 0x5306
SIOCATMARK 0x5307
SIOCGIFCONF 0x530c
SIOCGIFFLAGS 0x530d
SIOCSIFFLAGS 0x530e
SIOCGIFADDR 0x530f
SIOCSIFADDR 0x5310
SIOCGIFDSTADDR 0x5311
SIOCSIFDSTADDR 0x5312
SIOCGIFBRDADDR 0x5313
SIOCSIFBRDADDR 0x5314
SIOCGIFNETMASK 0x5315
SIOCSIFNETMASK 0x5316
SIOCGIFMETRIC 0x5317
SIOCSIFMETRIC 0x5318
SIOCGIFMTU 0x531b
SIOCSIFMTU 0x531c
SIOCADDRT 0x531e
SIOCDELRT 0x531f
SIOCDARP 0x5328
SIOCGARP 0x5329
SIOCSARP 0x532a

CD-ROM specific commands
cmd (name) cmd (value) arg Operation
CDROMREADOFFSET 0x4300 Points to a LONG to store result Get block number of first sector in last session of a multisession CD
CDROMPAUSE 0x4301 NULL Pause audio CD operation
CDROMRESUME 0x4302 NULL Resume audio CD operation
CDROMPLAYMSF 0x4303 Points to a cdrom_msf_t structure Play audio CD
CDROMPLAYTRKIND 0x4304 Points to a cdrom_ti_t structure Play audio CD
CDROMREADTOCHDR 0x4305 Points to a cdrom_tochdr_t structure Read header of table of contents (TOC) of CD
CDROMREADTOCENTRY 0x4306 Points to a cdrom_tocentry_t structure Read table of contents (TOC) entry of CD
CDROMSTOP 0x4307 NULL Stop CD-ROM drive motor
CDROMSTART 0x4308 NULL Start CD-ROM drive motor
CDROMEJECT 0x4309 NULL Eject CD
CDROMVOLCTRL 0x430a Points to a cdrom_volctrl_t structure Set volume level
CDROMSUBCHNL 0x430b Points to a cdrom_subchnl_t structure Read sub-channel information
CDROMREADMODE2 0x430c Points to a cdrom_read_t structure Read mode 2 sectors (Mode 2 sectors are 2336 bytes long).
CDROMREADMODE1 0x430d Points to a cdrom_read_t structure Read mode 1 sectors (Mode 1 sectors are 2048 bytes long).
CDROMPREVENTREMOVAL 0x430e NULL Lock CD-ROM drive tray
CDROMALLOWTREMOVAL 0x430f NULL Unlock CD-ROM drive tray
CDROMAUDIOCTRL 0x4310 Points to a cdrom_audioctrl_t structure Control audio settings
CDROMREADDA 0x4311 Points to a cdrom_read_t structure Read audio CD sectors (Audio CD sectors are 2352 bytes long).
CDROMGETMCN 0x4313 Points to a cdrom_mcn_t structure Read media catalog number
CDROMGETTISRC 0x4314 Points to a cdrom_tisrc_t structure Read track international standard recording code

Terminal specific commands
cmd (name) cmd (value) arg Operation
TIOCGETP 0x5400 Points to an sgttyb structure Get terminal parameters from the TTY? device with the specified file handle.
TIOCSETN 0x5401 Points to an sgttyb structure Set the terminal parameters of the TTY? device specified. You should first get the terminal control parameters, modify what you wish to change, and then set them with this call.
TIOCGETC 0x5402 Points to a tchars structure Get the terminal control characters of the TTY? device specified.
TIOCSETC 0x5403 Points to a tchars structure Set the terminal control characters of the TTY? device specified. Setting any structure element to 0 disables that feature.
TIOCGLTC 0x5404 Points to a ltchars structure Get the extended terminal control characters from the TTY? device specified.
TIOCSLTC 0x5405 Points to a ltchars structure Set the extended terminal control characters for the TTY? device specified. The control characters are set from the ltchars structure pointed to by arg.
TIOCGPGRP 0x5406 Points to a LONG Return (in the LONG pointed to by arg) the process group ID for the TTY? specified.
TIOCSPGRP 0x5407 Points to a LONG Set (from the LONG pointed to by arg) the process group ID of the TTY? specified.
TIOCFLUSH 0x5408
TIOCSTOP 0x5409 NULL (arg is ignored) Stop terminal output (as if the user had pressed Ctrl-S).
TIOCSTART 0x540a NULL (arg is ignored) Restart output to the terminal (as if the user had pressed Ctrl-Q) if it had been previously stopped with Ctrl-S or a TIOCSTOP command.
TIOCGWINSZ 0x540b Points to a winsize structure Get information regarding the window for this terminal.
TIOCSWINSZ 0x540c Points to a winsize structure Change the extents of the terminal window for the specified TTY?. The winsize structure pointed by arg contains the new window information. It is up to the window manager to modify the window extents and raise the SIGWINCH signal if necessary.
TIOCGXKEY 0x540d Points to a xkey structure Return the current definition of a system key. The xk_def field will be filled in with the NULL terminated name associated with the key specified in the xk_num field (see xkey for details).
TIOCSXKEY 0x540e Points to a xkey structure Set the current definition of a system key. The xk_num and xk_def fields are used to set the text associated with a system key (see xkey for details).

If a terminal recognizes special keys (by having its XKEY bit set in the sg_flags field of its sgttyb structure) then setting a system key will cause the text specified by xk_def to be sent to a process whenever the key is struck. Note: this works only if the terminal is reading characters using Fread()?.
TIOCIBAUD 0x5412 If not NULL, points to a LONG Read/Write the input baud rate for the specified terminal device. If arg is NULL, the DTR? on the terminal will be dropped (if this feature is supported). If arg points to a LONG then the input baud rate will be set to that value. If arg is negative, the baud rate will not be changed. The old baud rate is returned in the value pointed to by arg (if arg is not NULL).

If the terminal does not support separate input and output baud rates then this call will set both rates.
TIOCOBAUD 0x5413 If not NULL, points to a LONG Read/Write the output baud rate for the specified terminal device. If arg is NULL, the DTR? on the terminal will be dropped (if this feature is supported). If arg points to a LONG then the output baud rate will be set to that value. If arg is negative, the baud rate will not be changed. The old baud rate is returned in the value pointed to by arg (if arg is not NULL).

If the terminal does not support separate input and output baud rates then this call will set both rates.
TIOCCBRK 0x5414 NULL (arg is ignored) Clear the break condition on the specified device.
TIOCSBRK 0x5415 NULL (arg is ignored) Set the break condition on the specified device.
TIOCGFLAGS 0x5416 Points to a LONG Return the current stop bit/data bit configuration for the terminal device in the lower 16 bits of the LONG pointed to by arg. See the entry for TIOCSFLAGS for the flags required to parse arg.
TIOCSFLAGS 0x5417 Set the current stop bit/data bit configuration for the terminal device. The new configuration is contained in arg. Valid mask values for arg are as follows:
Name Mask Meaning
TF_1STOP 0x0001 1 stop bit
TF_15STOP 0x0002 1.5 stop bits
TF_2STOP 0x0003 2 stop bits
TF_8BIT 0x0000 8 data bits
TF_7BIT 0x0004 7 data bits
TF_6BIT 0x0008 6 data bits
TF_5BIT 0x000C 5 data bits
TIOCOUTQ 0x5418
TIOCSETP 0x5419
TIOCHPCL 0x541a
TIOCCAR 0x541b
TIOCNCAR 0x541c
TIOCWONLINE 0x541d
TIOCSFLAGSB 0x541e
TIOCGSTATE 0x541f
TIOCGSTATEB 0x5420
TIOCGVMIN 0x5421
TIOCSVMIN 0x5422
TIOCGHUPCL 0x5462
TIOCSHUPCL 0x5463
TIOCGSOFTCAR 0x5464
TIOCSSOFTCAR 0x5465
TIOCBUFFER 0x5480
TIOCCTLMAP 0x5481
TIOCCTLGET 0x5482
TIOCCTLSET 0x5483
TIOCCTLSFAST 0x5484
TIOCCTLSSLOW 0x5485
TIONOTSEND 0x5486
TIOCERROR 0x5487
TIOCLBIS 0x54f6
TIOCLBIC 0x54f7
TIOCMGET 0x54f8
TIOCCDTR 0x54f9
TIOCSDTR 0x54fa
TIOCNOTTY 0x54fb
TIOCGETD 0x54fc
TIOCSETD 0x54fd
TIOCLGET 0x54fe
TIOCLSET 0x54ff

Terminal cursor specific commands
cmd (name) cmd (value) arg Operation
TCURSOFF 0x6300 NULL (arg is ignored) Hide the cursor on the selected terminal device.
TCURSON 0x6301 NULL (arg is ignored) Show the cursor on the selected terminal device.
TCURSBLINK 0x6302 NULL (arg is ignored) Enable cursor blinking on the selected terminal device.
TCURSSTEADY 0x6303 NULL (arg is ignored) Disable cursor blinking on the selected terminal device.
TCURSSRATE 0x6304 Points to a WORD Set the cursor blink rate to the WORD pointed to by arg.
TCURSGRATE 0x6305 Points to a WORD Return the current cursor blink rate in the WORD pointed to by arg.

See Also

Flock()?, Fopen()?, Fxattr()?, Pgetpgrp()?, Psetpgrp()?

Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]