Skip to content
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

Add /proc/[pid]/cmdline support #877

Merged
merged 1 commit into from
Jun 18, 2024
Merged

Conversation

StanPlatinum
Copy link
Contributor

No description provided.

kernel/aster-nix/src/fs/procfs/pid/cmdline.rs Outdated Show resolved Hide resolved
kernel/aster-nix/src/fs/procfs/pid/cmdline.rs Outdated Show resolved Hide resolved
kernel/aster-nix/src/fs/procfs/pid/cmdline.rs Outdated Show resolved Hide resolved
@StanPlatinum StanPlatinum marked this pull request as draft May 31, 2024 07:32
@StanPlatinum StanPlatinum marked this pull request as ready for review June 1, 2024 14:04
@liqinggd
Copy link
Contributor

liqinggd commented Jun 4, 2024

Please see this commit 09deddb to implement the proc/pid/cmdline

@StanPlatinum StanPlatinum marked this pull request as draft June 4, 2024 11:05
@StanPlatinum
Copy link
Contributor Author

StanPlatinum commented Jun 5, 2024

Please see this commit 09deddb to implement the proc/pid/cmdline

Thanks @liqinggd ! I adopted your code and made a minor modification, which is more suitable and accurate using argv() to get the cmdline.

        let cmdline_output = if self.0.is_zombie() {
            // Returns 0 characters for zombie process.
            Vec::new()
        } else {
            let Ok(argv_cstrs) = self.0.vm().init_stack_reader().argv() else {
                return Ok(Vec::new());
            };
            argv_cstrs
                .into_iter()
                .flat_map(|c_str| c_str.into_bytes_with_nul().into_iter())
                .collect()
        };
        Ok(cmdline_output)

@StanPlatinum StanPlatinum marked this pull request as ready for review June 5, 2024 09:04
@liqinggd
Copy link
Contributor

LGTM

Copy link
Contributor

@tatetian tatetian left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the contribution!

@tatetian tatetian merged commit 3b66b06 into asterinas:main Jun 18, 2024
5 checks passed
@StanPlatinum StanPlatinum deleted the dev-procfs branch June 18, 2024 08:46
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.

None yet

4 participants