arch/um/os-Linux/file.c
Source file repositories/reference/linux-study-clean/arch/um/os-Linux/file.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/os-Linux/file.c- Extension
.c- Size
- 13382 bytes
- Lines
- 727
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hunistd.hstdlib.hstring.herrno.hfcntl.hsignal.hlinux/falloc.hsys/ioctl.hsys/mount.hsys/socket.hsys/stat.hsys/sysmacros.hsys/un.hsys/mman.hsys/types.hsys/eventfd.hpoll.hos.h
Detected Declarations
function Copyrightfunction os_stat_fdfunction os_stat_filefunction os_accessfunction os_ioctl_genericfunction os_get_ifnamefunction os_mode_fdfunction os_file_typefunction os_file_modefunction os_open_filefunction os_connect_socketfunction os_dup_filefunction os_close_filefunction os_seek_filefunction os_read_filefunction os_pread_filefunction os_write_filefunction os_sync_filefunction os_pwrite_filefunction os_file_sizefunction os_file_modtimefunction os_set_exec_closefunction os_pipefunction os_set_fd_asyncfunction os_clear_fd_asyncfunction os_set_fd_blockfunction os_accept_connectionfunction os_shutdown_socketfunction os_rcv_fd_msgfunction os_create_unix_socketfunction os_flush_stdoutfunction os_lock_filefunction os_majorfunction os_minorfunction os_makedevfunction os_falloc_punchfunction os_falloc_zeroesfunction os_eventfdfunction os_sendmsg_fdsfunction os_poll
Annotated Snippet
if (fd < 0) {
err = -errno;
printk(UM_KERN_ERR "Couldn't open \"%s\", "
"errno = %d\n", file, errno);
return err;
}
if (ioctl(fd, BLKGETSIZE, &blocks) < 0) {
err = -errno;
printk(UM_KERN_ERR "Couldn't get the block size of "
"\"%s\", errno = %d\n", file, errno);
close(fd);
return err;
}
*size_out = ((long long) blocks) * 512;
close(fd);
}
else *size_out = buf.ust_size;
return 0;
}
int os_file_modtime(const char *file, long long *modtime)
{
struct uml_stat buf;
int err;
err = os_stat_file(file, &buf);
if (err < 0) {
printk(UM_KERN_ERR "Couldn't stat \"%s\" : err = %d\n", file,
-err);
return err;
}
*modtime = buf.ust_mtime;
return 0;
}
int os_set_exec_close(int fd)
{
int err;
CATCH_EINTR(err = fcntl(fd, F_SETFD, FD_CLOEXEC));
if (err < 0)
return -errno;
return err;
}
int os_pipe(int *fds, int stream, int close_on_exec)
{
int err, type = stream ? SOCK_STREAM : SOCK_DGRAM;
err = socketpair(AF_UNIX, type, 0, fds);
if (err < 0)
return -errno;
if (!close_on_exec)
return 0;
err = os_set_exec_close(fds[0]);
if (err < 0)
goto error;
err = os_set_exec_close(fds[1]);
if (err < 0)
goto error;
return 0;
error:
printk(UM_KERN_ERR "os_pipe : Setting FD_CLOEXEC failed, err = %d\n",
-err);
close(fds[1]);
close(fds[0]);
return err;
}
int os_set_fd_async(int fd)
{
int err, flags;
flags = fcntl(fd, F_GETFL);
if (flags < 0)
return -errno;
flags |= O_ASYNC | O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0) {
err = -errno;
printk(UM_KERN_ERR "os_set_fd_async : failed to set O_ASYNC "
"and O_NONBLOCK on fd # %d, errno = %d\n", fd, errno);
Annotation
- Immediate include surface: `stdio.h`, `unistd.h`, `stdlib.h`, `string.h`, `errno.h`, `fcntl.h`, `signal.h`, `linux/falloc.h`.
- Detected declarations: `function Copyright`, `function os_stat_fd`, `function os_stat_file`, `function os_access`, `function os_ioctl_generic`, `function os_get_ifname`, `function os_mode_fd`, `function os_file_type`, `function os_file_mode`, `function os_open_file`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.