public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman•id.au>
To: thefirst ECS <ecs_dn@yahoo•com>, linuxppc-dev@lists•ozlabs.org
Subject: Re: How would I code a Write to a proc file from within the kernel without reading anything from user space?
Date: Thu, 06 Aug 2020 11:30:20 +1000	[thread overview]
Message-ID: <87tuxgy30z.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <32112832.26959.1596664366002.JavaMail.Dan@DanHP>

thefirst ECS <ecs_dn@yahoo•com> writes:
> In order to help debug a certain discrepancy, I need to "simulate" an "echo 1 > /proc/file" but doing it from kernel even when root file system is unavailable. 
>
> I have simulated it just fine via call_usermodehelper (with argv etc of "echo 1 > /proc/file") from inside the kernel which triggers:
> [ee897ec0] [c0122704] proc_reg_write+0x80/0xb4
> [ee897ef0] [c00d3b7c] vfs_write+0xb4/0x184
>
> just as I had wanted. But now I need to trigger the "vfs_write" and "proc_reg_write" but without using call_usermodehelper since I will be doing it when root "/" is unavailable and so I can no longer access /bin/echo and call the usermodehelper etc. So my question is how can I do that in kernel?
>
> Not sure if I'm supposed to look in fs read_write.c and fs.h and write a method based on those or if there's some other way etc.

You don't say which proc file, which would be useful information.

I'll assume it's /proc/sysrq-trigger based on your previous mail.

Rather than trying to invoke the write path from inside the kernel, the
simplest option is to just call __handle_sysrq() directly.

cheers

      reply	other threads:[~2020-08-06  1:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3103222.25048.1596318084416.JavaMail.Dan.ref@DanHP>
     [not found] ` <11049609.25021.1596315320093.JavaMail.Dan@DanHP>
2020-08-01 21:41   ` Scott Wood fix for SysRQ Crash over Serial Console on Linux PowerPC 2.6.32 kernel? thefirst ECS
2020-08-05 21:52     ` How would I code a Write to a proc file from within the kernel without reading anything from user space? thefirst ECS
2020-08-06  1:30       ` Michael Ellerman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuxgy30z.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman$(echo .)id.au \
    --cc=ecs_dn@yahoo$(echo .)com \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox