Add flink

This commit is contained in:
Jeremy Soller
2025-05-03 12:25:46 -06:00
parent 4a1cd73da4
commit d712ff5158
7 changed files with 77 additions and 19 deletions
Generated
+25 -18
View File
@@ -58,9 +58,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.2.19"
version = "1.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0"
dependencies = [
"shlex",
]
@@ -103,9 +103,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.15.2"
version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
[[package]]
name = "indexmap"
@@ -114,12 +114,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
"hashbrown 0.15.3",
]
[[package]]
name = "kernel"
version = "0.4.1"
version = "0.5.12"
dependencies = [
"arrayvec",
"bitfield",
@@ -234,8 +234,8 @@ checksum = "64072665120942deff5fd5425d6c1811b854f4939e7f1c01ce755f64432bbea7"
[[package]]
name = "redox_syscall"
version = "0.5.11"
source = "git+https://gitlab.redox-os.org/redox-os/syscall.git?branch=master#8f646a63ac9c3aa532a37ddfdc136ec19878f0d6"
version = "0.5.12"
source = "git+https://gitlab.redox-os.org/redox-os/syscall.git?branch=master#fe32c6b89dae51e609d5c53880dec1834ec9bde0"
dependencies = [
"bitflags 2.9.0",
]
@@ -379,9 +379,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.100"
version = "2.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
dependencies = [
"proc-macro2",
"quote",
@@ -410,9 +410,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.8.20"
version = "0.8.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae"
dependencies = [
"serde",
"serde_spanned",
@@ -422,26 +422,33 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.6.8"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.22.24"
version = "0.22.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"toml_write",
"winnow",
]
[[package]]
name = "toml_write"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076"
[[package]]
name = "unicode-ident"
version = "1.0.18"
@@ -456,9 +463,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "winnow"
version = "0.7.6"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10"
checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3"
dependencies = [
"memchr",
]
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "kernel"
version = "0.4.1"
version = "0.5.12"
build = "build.rs"
edition = "2021"
+3
View File
@@ -466,6 +466,9 @@ pub trait KernelScheme: Send + Sync + 'static {
fn fevent(&self, id: usize, flags: EventFlags) -> Result<EventFlags> {
Ok(EventFlags::empty())
}
fn flink(&self, id: usize, new_path: &str, caller_ctx: CallerCtx) -> Result<()> {
Err(Error::new(EBADF))
}
fn frename(&self, id: usize, new_path: &str, caller_ctx: CallerCtx) -> Result<()> {
Err(Error::new(EBADF))
}
+12
View File
@@ -762,6 +762,7 @@ impl UserInner {
Opcode::Fcntl => SYS_FCNTL,
Opcode::Fevent => SYS_FEVENT,
Opcode::Sendfd => SYS_SENDFD,
Opcode::Flink => SYS_FLINK,
Opcode::Fpath => SYS_FPATH,
Opcode::Frename => SYS_FRENAME,
Opcode::Fstat => SYS_FSTAT,
@@ -1459,6 +1460,17 @@ impl KernelScheme for UserScheme {
.map(EventFlags::from_bits_truncate)
}
fn flink(&self, file: usize, path: &str, _ctx: CallerCtx) -> Result<()> {
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
let mut address = inner.copy_and_capture_tail(path.as_bytes())?;
inner.call(
Opcode::Flink,
[file, address.base(), address.len()],
address.span(),
)?;
Ok(())
}
fn frename(&self, file: usize, path: &str, _ctx: CallerCtx) -> Result<()> {
let inner = self.inner.upgrade().ok_or(Error::new(ENODEV))?;
let mut address = inner.copy_and_capture_tail(path.as_bytes())?;
+1
View File
@@ -122,6 +122,7 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
UserSlice::ro(c, d).and_then(|buf| unsafe { buf.read_exact::<Map>() }),
),
SYS_FUNMAP => format!("funmap({:#X}, {:#X})", b, c,),
SYS_FLINK => format!("flink({}, {:?})", b, debug_path(c, d),),
SYS_FPATH => format!("fpath({}, {:#X}, {})", b, c, d),
SYS_FRENAME => format!("frename({}, {:?})", b, debug_path(c, d),),
SYS_FSTAT => format!(
+34
View File
@@ -394,6 +394,40 @@ pub fn fcntl(fd: FileHandle, cmd: usize, arg: usize) -> Result<usize> {
}
}
pub fn flink(fd: FileHandle, raw_path: UserSliceRo) -> Result<()> {
let (caller_ctx, scheme_ns) = match context::current().read() {
ref cx => (cx.caller_ctx(), cx.ens),
};
let file = context::current()
.read()
.get_file(fd)
.ok_or(Error::new(EBADF))?;
/*
let mut path_buf = BorrowedHtBuf::head()?;
let path = path_buf.use_for_string(raw_path)?;
*/
let path_buf = copy_path_to_buf(raw_path, PATH_MAX)?;
let path = RedoxPath::from_absolute(&path_buf).ok_or(Error::new(EINVAL))?;
let (scheme_name, reference) = path.as_parts().ok_or(Error::new(EINVAL))?;
let (scheme_id, scheme) = {
let schemes = scheme::schemes();
let (scheme_id, scheme) = schemes
.get_name(scheme_ns, scheme_name.as_ref())
.ok_or(Error::new(ENODEV))?;
(scheme_id, scheme.clone())
};
let description = file.description.read();
if scheme_id != description.scheme {
return Err(Error::new(EXDEV));
}
scheme.flink(description.number, reference.as_ref(), caller_ctx)
}
pub fn frename(fd: FileHandle, raw_path: UserSliceRo) -> Result<()> {
let (caller_ctx, scheme_ns) = match context::current().read() {
ref cx => (cx.caller_ctx(), cx.ens),
+1
View File
@@ -159,6 +159,7 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> us
.fevent(number, EventFlags::from_bits_truncate(c))?
.bits())
}),
SYS_FLINK => flink(fd, UserSlice::ro(c, d)?).map(|()| 0),
SYS_FRENAME => frename(fd, UserSlice::ro(c, d)?).map(|()| 0),
SYS_FUNMAP => funmap(b, c),