cmpsc 311 test 2 IO Flashcards

1
Q

fopen() syntax

A

FILE *fopen(const char *path, const char *mode);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

IO, pointer

A

the fopen function opens a file for — and returns a —- to a FILE* structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

stream

A

A FILE* structure is also referred to as a —-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

r

A

–: open text file for reading. The stream is positioned at the beginning of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

r+

A

— Open for reading and writing. The stream is positioned at the beginning of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

w

A

–: truncate file to zero length or create text file for writing. the stream is positioned at the beginning of the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

w+

A

—: Open for reading and writing. The file is created if it does not exist, otherwise it is truncated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

a

A

Open for appending (writing at the end of file). The file is created if it does not exist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

a+

A

Open for reading and appending (writing at end of file). the file is created if it does not exist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

fscanf, fgets

A

there are two dominant ways to read the file: ——- and ——

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

fscanf, scanf

A

— reads the data from the file just like —–, just reading and writing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

fgets

A

— reads a line of text from the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

fprintf, fputs

A

there are two dominant ways to write the file, —- and —-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

fprintf, printf

A

— writes data to the file just like —-, just reading and writing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

fputs

A

—- writes a line of text to the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

FILE*

A

—- based IO is buffered

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

fflush

A

—- attempts to reset/the flush state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

int fflush(FILE *stream)

A

fflush syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

buffered, written, pushed, OS/disk

A

FILE* based writes are —–, so there may be data ——-, but not yet —– to the —/—–

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

fflush()

A

—– forces a write of all buffered data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

buffered, current, current

A

FILE* based reads are —-, so the — data (in the process space) may not be —-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

fflush()

A

—– discards buffered data from the underlying file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

NULL, fflush, all

A

If the stream argument is —–, ——() flushes —- open output streams

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

fclose()

A

—– closes the file and releases the memory associated with the FILE* structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

storage

A

fclose() implicitly flushes the data to ——

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

file, integer file handle

A

the open function opens a —- for IO and returns an —— —— —–

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

int open(const char *path, int flags, mode_tmode);

A

open() syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

path

A

open():

— is a string containing the absolute or relative path to the file to be opened

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

flags

A

open():

— indicates the kind of open you are requesting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

mode

A

open():

—- sets a security policy for the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

file handle

A

open() returns a —- —-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

O_RDONLY

A

open() flags:

—- read only

33
Q

O_WRONLY

A

open() flags:

—- write only

34
Q

O_RDWR

A

open() flags:

—- read and write

35
Q

O_CREAT

A

open() options:

—- if the file does not exist it will be created

36
Q

O_EXCL

A

open() options:

— ensure that this call creates the file, fail otherwise (fail if already exists)

37
Q

O_TRUNC

A

open() options:

— if the file already exists it will be truncated to length 0

38
Q

bitwise or (|)

A

You —— —- the mode/options you want in open()

39
Q

discretionary access control, user

A

The UNIX filesystem implements —– —– —- through file permissions set by user. The permissions are set at the discretion of the —

40
Q

bits, access

A

Every file in the file system ha has a set of —– which determine who has —– to the files.

41
Q

user

A

—— the owner is typically the creator of the file, and the entity in control of the access control policy

42
Q

group

A

—- a set of users on the system setup by the admin

43
Q

world

A

—– the set of everyone on the system

44
Q

root

A

Not discretionary access control can be overridden by the —- user

45
Q

READ

A

3 rights in UNIX filesystem:

—-: allows the subject(process) to read the contents of the file

46
Q

WRITE

A

3 rights in UNIX filesystem:

—-: allows the subject (process) to alter the contents of the file

47
Q

EXECUTE

A

3 rights in UNIX filesystem:

—: allows the subject (process) to execute the contents of the file (eg, shell program, executable, …)

48
Q

r, w, x, -

A

UNIX Access policy:

Really, this is a bit string encoding an access policy.
And a policy is encoded as —, —-, — if enabled and — if not

49
Q

rwxrw—x

A

encoding syntax example. says user can read, write and execute, group can read and write, and world can execute only

50
Q

S_IRWXU 00700

A

Specify a file access policy by bit-wise ORing(|):

——–: user (file owner) has read, write and execute

51
Q

S_IRUSR 00400

A

Specify a file access policy by bit-wise ORing(|):

——–: user has read permission

52
Q

S_IWUSR 00200

A

Specify a file access policy by bit-wise ORing(|):

——–: user has write permission

53
Q

S_IXUSR 0100

A

Specify a file access policy by bit-wise ORing(|):

——–: user has execute permission

54
Q

S_IRGRP 00040

A

Specify a file access policy by bit-wise ORing(|):

——–: group has read permission

55
Q

S_IWGRP 00020

A

Specify a file access policy by bit-wise ORing(|):

——–: group has write permission

56
Q

S_IXGRP 00010

A

Specify a file access policy by bit-wise ORing(|):

——–: group has execute permission

57
Q

S_IRWXO 00007

A

Specify a file access policy by bit-wise ORing(|):

——–: world has read, write, and execute permission

58
Q

S_IROTH 00004

A

Specify a file access policy by bit-wise ORing(|):

——–: world has read permission

59
Q

S_IWOTH 00002

A

Specify a file access policy by bit-wise ORing(|):

——–: world has write permission

60
Q

S_IXOTH 00001

A

Specify a file access policy by bit-wise ORing(|):

——–: world has execute permission

61
Q

S_IRWXG 00070

A

Specify a file access policy by bit-wise ORing(|):

——–: group has read, write, and execute permission

62
Q

int

A

Why is an —- returned by open() file

63
Q

file descriptor

A

a —– —– is an index assigned by the kernel into a table of file information maintained in the OS.

64
Q

unique, process, open

A

The file descriptor table is —– to each —– and contains the details of —- files

65
Q

calling IO system

A

File descriptors are used to reference when —– the —– —— calls

66
Q

kernel, process, system call

A

The —- accesses the file for the —– and returns the results in —– — response

67
Q

primitive

A

—— reading and writing mechanisms that only process only blocks of opaque data

68
Q

ssize_twrite(int fd, const void *buf, size_tcount);

A

primitive write syntax

69
Q

ssize_tread(int fd, void *buf, size_tcount);

A

primitive read syntax

70
Q

fd, buf, count

A

primitive read/write syntax:

Where — is the file descriptor, —- is an array of bytes to write from or read into, and —- is the number of bytes to read or write

71
Q

number, bytes, result

A

both read() and write(0 returned the —- of —— read and written. Be sure to always check the —-

72
Q

buffer, output

A

On reads, you are responsible for supplying a —– that is large enough to put the —– into

73
Q

close(), -1

A

—– closes the file and deletes the file’s entry in the file descriptor table. Always reset your file handles to —- to avoid use after close

74
Q

fopen

A

—- provides you with buffering IO that may or may not turn out to be a faster than what you’re doing with open

75
Q

fopen, binary mode

A

—– does line ending translation if the file is not opened in —– —, which can be very helpful if your program is ever ported to a non-UNIX environment`

76
Q

FILE*, fscanf, stdio

A

A —- gives you the ability to use —- and other — functions that parse out data and support formatted output

77
Q

FILE*, file handle

A

IMO: use —– style I/O for ASCII processing, and —- —— I/O for binary data processing

78
Q

include, stdio.h, sys/types.h, sys/stat.h, fcnt1.h, unistd.h

A

each of the styles of I/O requires a different set of —– files.

file handle I/O requires: