System Calls
System Calls
1. **Open**:
- `open()` is a system call used to open or create a file or device. It returns a file descriptor, which is
a small, non-negative integer that the system uses to uniquely identify an open file. The file
descriptor is used in subsequent system calls to read, write, and perform other operations on the file.
- Parameters:
- `flags`: A set of flags that determine the behavior of the `open()` call, such as whether the file
should be opened for reading, writing, or both, and whether the file should be created if it does not
exist.
2. **Create**:
- `create()` is not actually a system call itself, but it's often used in conjunction with `open()`. When
you use the `open()` system call to open a file with the `O_CREAT` flag and the file does not exist,
`open()` will create the file.
- Parameters:
- `flags`: A set of flags that determine the behavior of the `open()` call, including `O_CREAT`.
- `mode`: A set of permission bits that determine the file's permissions if it is created. This
parameter is only used if the `O_CREAT` flag is set.
3. **Read**:
- `read()` is a system call used to read data from an open file descriptor into a buffer.
- Parameters:
4. **Write**:
- `write()` is a system call used to write data from a buffer to an open file descriptor.
- Parameters:
5. **Close**:
- Parameters:
6. **lseek**:
- `lseek()` is a system call used to change the read/write position within a file.
- Parameters:
- `whence`: Specifies the reference point for the offset (where to start counting from), it can take
one of the following values:
- Return value: Returns the new offset (position) within the file, or -1 on failure.
7. **Stat**:
- Parameters:
- `buf`: A pointer to a `struct stat` where the file information will be stored.
8. **Ioctl**:
- `ioctl()` is a system call used for device-specific input/output operations. It allows for control over
various aspects of device behavior that are not covered by other system calls.
- Parameters: