tools/hv/hv_fcopy_uio_daemon.c
Source file repositories/reference/linux-study-clean/tools/hv/hv_fcopy_uio_daemon.c
File Facts
- System
- Linux kernel
- Corpus path
tools/hv/hv_fcopy_uio_daemon.c- Extension
.c- Size
- 13663 bytes
- Lines
- 560
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dirent.herrno.hfcntl.hgetopt.hlocale.hstdbool.hstddef.hstdint.hstdio.hstdlib.hstring.hsyslog.hunistd.hwchar.hsys/stat.hlinux/hyperv.hlinux/limits.hvmbus_bufring.h
Detected Declarations
function get_ring_buffer_sizefunction hv_fcopy_create_filefunction hv_copy_datafunction hv_copy_finishedfunction print_usagefunction vmbus_prep_negotiate_respfunction ICMSG_NEGOTIATE_PKT_SIZEfunction wcstoutf8function hv_fcopy_startfunction hv_fcopy_send_datafunction fcopy_pkt_processfunction fcopy_get_first_folderfunction main
Annotated Snippet
if (!dir) {
syslog(LOG_ERR, "Failed to open channels directory: %s", strerror(errno));
return 0;
}
}
retry_once:
while ((entry = readdir(dir)) != NULL) {
if (entry->d_type == DT_DIR && strcmp(entry->d_name, ".") != 0 &&
strcmp(entry->d_name, "..") != 0) {
snprintf(ring_path, sizeof(ring_path), "%s/%s/ring",
FCOPY_CHANNELS_PATH, entry->d_name);
if (stat(ring_path, &st) == 0) {
/*
* stat returns size of Tx, Rx rings combined,
* so take half of it for individual ring size.
*/
ring_size = (uint32_t)st.st_size / 2;
syslog(LOG_INFO, "Ring buffer size from %s: %u bytes",
ring_path, ring_size);
break;
}
}
}
if (!ring_size && retry_count == 0) {
retry_count = 1;
rewinddir(dir);
usleep(100 * 1000); /* Wait 100ms and retry once */
goto retry_once;
}
closedir(dir);
if (!ring_size)
syslog(LOG_ERR, "Could not determine ring size");
return ring_size;
}
static unsigned char *desc;
static int target_fd;
static char target_fname[PATH_MAX];
static unsigned long long filesize;
static int hv_fcopy_create_file(char *file_name, char *path_name, __u32 flags)
{
int error = HV_E_FAIL;
char *q, *p;
filesize = 0;
p = path_name;
if (snprintf(target_fname, sizeof(target_fname), "%s/%s",
path_name, file_name) >= sizeof(target_fname)) {
syslog(LOG_ERR, "target file name is too long: %s/%s", path_name, file_name);
goto done;
}
/*
* Check to see if the path is already in place; if not,
* create if required.
*/
while ((q = strchr(p, '/')) != NULL) {
if (q == p) {
p++;
continue;
}
*q = '\0';
if (access(path_name, F_OK)) {
if (flags & CREATE_PATH) {
if (mkdir(path_name, 0755)) {
syslog(LOG_ERR, "Failed to create %s",
path_name);
goto done;
}
} else {
syslog(LOG_ERR, "Invalid path: %s", path_name);
goto done;
}
}
p = q + 1;
*q = '/';
}
if (!access(target_fname, F_OK)) {
syslog(LOG_INFO, "File: %s exists", target_fname);
if (!(flags & OVER_WRITE)) {
error = HV_ERROR_ALREADY_EXISTS;
Annotation
- Immediate include surface: `dirent.h`, `errno.h`, `fcntl.h`, `getopt.h`, `locale.h`, `stdbool.h`, `stddef.h`, `stdint.h`.
- Detected declarations: `function get_ring_buffer_size`, `function hv_fcopy_create_file`, `function hv_copy_data`, `function hv_copy_finished`, `function print_usage`, `function vmbus_prep_negotiate_resp`, `function ICMSG_NEGOTIATE_PKT_SIZE`, `function wcstoutf8`, `function hv_fcopy_start`, `function hv_fcopy_send_data`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.