tools/hv/hv_vss_daemon.c
Source file repositories/reference/linux-study-clean/tools/hv/hv_vss_daemon.c
File Facts
- System
- Linux kernel
- Corpus path
tools/hv/hv_vss_daemon.c- Extension
.c- Size
- 7917 bytes
- Lines
- 356
- 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
sys/types.hsys/poll.hsys/ioctl.hsys/stat.hsys/sysmacros.hfcntl.hstdio.hmntent.hstdlib.hunistd.hstring.hctype.herrno.hlinux/fs.hlinux/major.hlinux/hyperv.hsyslog.hgetopt.hstdbool.hdirent.h
Detected Declarations
function vss_do_freezefunction is_dev_loopfunction vss_operatefunction print_usagefunction main
Annotated Snippet
if (is_dev_loop(buffer)) {
ret = true;
break;
}
}
closedir(dir);
free_buffer:
free(buffer);
return ret;
}
static int vss_operate(int operation)
{
char match[] = "/dev/";
FILE *mounts;
struct mntent *ent;
struct stat sb;
char errdir[1024] = {0};
char blkdir[23]; /* /sys/dev/block/XXX:XXX */
unsigned int cmd;
int error = 0, root_seen = 0, save_errno = 0;
switch (operation) {
case VSS_OP_FREEZE:
cmd = FIFREEZE;
break;
case VSS_OP_THAW:
cmd = FITHAW;
break;
default:
return -1;
}
mounts = setmntent("/proc/mounts", "r");
if (mounts == NULL)
return -1;
while ((ent = getmntent(mounts))) {
if (strncmp(ent->mnt_fsname, match, strlen(match)))
continue;
if (stat(ent->mnt_fsname, &sb)) {
syslog(LOG_ERR, "Can't stat: %s; error:%d %s!",
ent->mnt_fsname, errno, strerror(errno));
} else {
sprintf(blkdir, "/sys/dev/block/%d:%d",
major(sb.st_rdev), minor(sb.st_rdev));
if (is_dev_loop(blkdir))
continue;
}
if (hasmntopt(ent, MNTOPT_RO) != NULL)
continue;
if (strcmp(ent->mnt_type, "vfat") == 0)
continue;
if (strcmp(ent->mnt_dir, "/") == 0) {
root_seen = 1;
continue;
}
error |= vss_do_freeze(ent->mnt_dir, cmd);
if (operation == VSS_OP_FREEZE) {
if (error)
goto err;
fs_frozen = true;
}
}
endmntent(mounts);
if (root_seen) {
error |= vss_do_freeze("/", cmd);
if (operation == VSS_OP_FREEZE) {
if (error)
goto err;
fs_frozen = true;
}
}
if (operation == VSS_OP_THAW && !error)
fs_frozen = false;
goto out;
err:
save_errno = errno;
if (ent) {
strncpy(errdir, ent->mnt_dir, sizeof(errdir)-1);
endmntent(mounts);
}
vss_operate(VSS_OP_THAW);
fs_frozen = false;
/* Call syslog after we thaw all filesystems */
if (ent)
Annotation
- Immediate include surface: `sys/types.h`, `sys/poll.h`, `sys/ioctl.h`, `sys/stat.h`, `sys/sysmacros.h`, `fcntl.h`, `stdio.h`, `mntent.h`.
- Detected declarations: `function vss_do_freeze`, `function is_dev_loop`, `function vss_operate`, `function print_usage`, `function main`.
- 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.