Skip to content

implemented mkswap #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open

implemented mkswap #292

wants to merge 41 commits into from

Conversation

silverbaum
Copy link

@silverbaum silverbaum commented Apr 18, 2025

A minimal implementation of mkswap
features lacking from the original:

  • device wiping
  • selinux support
  • adjustments for endianness

tested on an archiso with an 8GB swap partition

@sylvestre
Copy link
Contributor

i guess you saw that a bunch of jobs are failing

@silverbaum
Copy link
Author

It is proving more difficult than expected to make it successfully not work on non-linux platforms :D

@sylvestre sylvestre requested a review from Copilot April 22, 2025 08:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a minimal version of the mkswap utility for Linux, including a basic swap signature initialization and several tests to cover error and success scenarios. Key changes include:

  • Addition of new tests for mkswap in tests/by-util/test_mkswap.rs and tests/tests.rs.
  • Implementation of the mkswap functionality in src/uu/mkswap/src/mkswap.rs.
  • Updates to Cargo.toml files and documentation to integrate the new utility into the workspace.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/tests.rs Added mkswap test module to conditionally compile tests.
tests/by-util/test_mkswap.rs Introduced tests covering various mkswap error and success cases.
src/uu/mkswap/src/mkswap.rs Implemented the core mkswap functionality and swap signature logic.
src/uu/mkswap/src/main.rs Defined the main entry point for the new mkswap utility.
src/uu/mkswap/mkswap.md Added basic documentation for mkswap usage.
src/uu/mkswap/Cargo.toml Provided package configuration for mkswap.
Cargo.toml Updated workspace dependencies to include the mkswap package.
Comments suppressed due to low confidence (1)

src/uu/mkswap/src/mkswap.rs:97

  • Consider checking that the label length does not exceed the 16-byte buffer size before copying to avoid a potential buffer overflow. For example, truncate the label if its length is greater than 16.
(*swap_hdr).volume_name.as_mut_ptr().copy_from(label.as_ptr(), label.len());

silverbaum and others added 8 commits May 9, 2025 12:54
- switch ioctl call to BLKGETSIZE64
- better UUID error handling
- added test for invalid UUID
- cleaner output message code
- reduced amount of unsafe blocks
-added truncation notification in verbose mode
- added swapfile creation flag and respective test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants