Skip to content

Commit bb62b24

Browse files
bors[bot]MikailBag
andauthored
Merge #91
91: Make --data-dir optional in jjs-setup r=MikailBag a=MikailBag Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
2 parents 639a463 + 960d05c commit bb62b24

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/minion/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,15 @@ impl InputSpecification {
135135
Self(InputSpecificationData::Pipe)
136136
}
137137

138+
/// # Safety
139+
/// - Handle must not be used since passing to this function
140+
/// - Handle must be valid
138141
pub unsafe fn handle(h: u64) -> Self {
139142
Self(InputSpecificationData::Handle(h))
140143
}
141144

145+
/// # Safety
146+
/// See requirements of `handle`
142147
pub unsafe fn handle_of<T: std::os::unix::io::IntoRawFd>(obj: T) -> Self {
143148
Self::handle(obj.into_raw_fd() as u64)
144149
}
@@ -175,10 +180,15 @@ impl OutputSpecification {
175180
Self(OutputSpecificationData::Buffer(None))
176181
}
177182

183+
/// # Safety
184+
/// - Handle must not be used since passing to this function
185+
/// - Handle must be valid
178186
pub unsafe fn handle(h: u64) -> Self {
179187
Self(OutputSpecificationData::Handle(h))
180188
}
181189

190+
/// # Safety
191+
/// See requirements of `handle`
182192
pub unsafe fn handle_of<T: std::os::unix::io::IntoRawFd>(obj: T) -> Self {
183193
Self::handle(obj.into_raw_fd() as u64)
184194
}

src/minion/src/linux/dominion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl LinuxDominion {
8686
let startup_info = jobserver::start_jobserver(jail_options)?;
8787

8888
Ok(LinuxDominion {
89-
id: jail_id.clone(),
90-
options: options.clone(),
89+
id: jail_id,
90+
options,
9191
jobserver_sock: startup_info.socket,
9292
util_cgroup_path: startup_info.wrapper_cgroup_path,
9393
})

src/minion/src/linux/jobserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ pub(crate) unsafe fn start_jobserver(
528528
write!(logger, "thread C (jobserver main)").unwrap();
529529
mem::drop(sock);
530530
let js_arg = JobServerOptions {
531-
jail_options: jail_options.clone(),
531+
jail_options,
532532
sock: js_sock,
533533
};
534534
let jobserver_ret_code = jobserver_main::jobserver_entry(js_arg);

src/minion/src/linux/jobserver/setup.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ unsafe fn configure_dir(dir_path: &Path, uid: Uid) {
3333
err_exit("chmod");
3434
}
3535

36-
if libc::chown(path.clone().as_ptr(), uid, uid) == -1 {
36+
if libc::chown(path.as_ptr(), uid, uid) == -1 {
3737
err_exit("chown");
3838
}
3939
}
@@ -67,7 +67,7 @@ fn expose_dir(
6767
if let DesiredAccess::Readonly = access {
6868
let rem_ret = libc::mount(
6969
ptr::null(),
70-
bind_target.clone().as_ptr(),
70+
bind_target.as_ptr(),
7171
ptr::null(),
7272
libc::MS_BIND | libc::MS_REMOUNT | libc::MS_RDONLY,
7373
ptr::null(),
@@ -199,13 +199,7 @@ unsafe fn setup_procfs(jail_options: &JailOptions) {
199199
}
200200
let proc = CString::new("proc").unwrap();
201201
let targ = CString::new(procfs_path.as_os_str().as_bytes()).unwrap();
202-
let mret = libc::mount(
203-
proc.clone().as_ptr(),
204-
targ.clone().as_ptr(),
205-
proc.clone().as_ptr(),
206-
0,
207-
ptr::null(),
208-
);
202+
let mret = libc::mount(proc.as_ptr(), targ.as_ptr(), proc.as_ptr(), 0, ptr::null());
209203
if -1 == mret {
210204
err_exit("mount")
211205
}

0 commit comments

Comments
 (0)