Skip to content

Commit

Permalink
fix build in armv7
Browse files Browse the repository at this point in the history
In armv7-unknown-linux-gnueabihf (ARM 32-bit), FileStat::st_ino is
an u32 instead of an u64, so we cannot directly assign to
JournalStream::inode, which is an u64.

Instead of using u64 in the fields of JournalStream, we use libc::dev_t
and libc::ino_t. The JournalStream::from_metadata function has been removed
since it assumes that the fields are u64 and is no longer used.
  • Loading branch information
daniestevez committed May 1, 2023
1 parent c9d1e90 commit a76ad73
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use nix::sys::stat::{fstat, FileStat};
use once_cell::sync::OnceCell;
use std::collections::HashMap;
use std::ffi::{CStr, CString, OsStr};
use std::fs::{File, Metadata};
use std::fs::File;
use std::io::prelude::*;
use std::os::linux::fs::MetadataExt;
use std::os::unix::io::AsRawFd;
use std::os::unix::net::UnixDatagram;
use std::os::unix::prelude::AsFd;
Expand Down Expand Up @@ -320,9 +319,9 @@ fn send_memfd_payload(sock: &UnixDatagram, data: &[u8]) -> Result<usize, SdError
#[derive(Debug, Eq, PartialEq)]
pub struct JournalStream {
/// The device number of the journal stream.
device: u64,
device: libc::dev_t,
/// The inode number of the journal stream.
inode: u64,
inode: libc::ino_t,
}

impl JournalStream {
Expand All @@ -345,13 +344,13 @@ impl JournalStream {
s
)
})?;
let device = u64::from_str(device_s).with_context(|| {
let device = libc::dev_t::from_str(device_s).with_context(|| {
format!(
"Failed to parse journal stream: Device part is not a number '{}'",
device_s
)
})?;
let inode = u64::from_str(inode_s).with_context(|| {
let inode = libc::ino_t::from_str(inode_s).with_context(|| {
format!(
"Failed to parse journal stream: Inode part is not a number '{}'",
inode_s
Expand All @@ -378,16 +377,6 @@ impl JournalStream {
Self::from_env_impl("JOURNAL_STREAM")
}

/// Get the journal stream that would correspond to the given file metadata.
///
/// Return a journal stream struct containing the device and inode number of the given file metadata.
pub fn from_metadata(metadata: &Metadata) -> Self {
Self {
device: metadata.st_dev(),
inode: metadata.st_ino(),
}
}

/// Get the journal stream that would correspond to the given file descriptor.
///
/// Return a journal stream struct containing the device and inode number of the given file descriptor.
Expand Down

0 comments on commit a76ad73

Please sign in to comment.