-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a demo/prototype for starting to add new Rust code only for `OstreeSysroot`. #2427 (comment)
- Loading branch information
Showing
6 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Makefile for Rust lib | ||
# | ||
# SPDX-License-Identifier: LGPL-2.0+ | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
|
||
target/release/libostreesysrs.so: src/sysroot-rs/src/lib.rs | ||
cargo build --release --workspace | ||
|
||
libostreesysrs_DATA = target/release/libostreesysrs.so | ||
libostreesysrsdir = $(pkglibexecdir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
description = "Internal Rust sysroot code" | ||
edition = "2021" | ||
keywords = ["ostree", "libostree"] | ||
license = "MIT" | ||
name = "ostreesysrs" | ||
readme = "rust-bindings/README.md" | ||
repository = "https://github.com/ostreedev/ostree" | ||
rust-version = "1.70.0" | ||
version = "0.0.0" | ||
publish = false | ||
|
||
[lib] | ||
name = "ostreesysrs" | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
ostree = { package = "ostree", path = "../..", version = "0.19", features = ["v2022_6"] } | ||
libc = "0.2" | ||
rustix = { version = "0.38", features = ["fs"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#[no_mangle] | ||
pub extern "C" fn _ostreesys_bump_mtime(fd: libc::c_int) -> libc::c_int { | ||
let fd = unsafe { std::os::fd::BorrowedFd::borrow_raw(fd) }; | ||
let now = rustix::fs::Timespec { | ||
tv_sec: 0, | ||
tv_nsec: rustix::fs::UTIME_NOW, | ||
}; | ||
let ts = rustix::fs::Timestamps { | ||
last_access: now.clone(), | ||
last_modification: now.clone(), | ||
}; | ||
if let Err(e) = rustix::fs::utimensat(fd, "ostree/deploy", &ts, rustix::fs::AtFlags::empty()) { | ||
e.raw_os_error().into() | ||
} else { | ||
0 | ||
} | ||
} |