You are not logged in.

#1 2018-07-08 16:11:45

destou
Member
Registered: 2018-03-31
Posts: 59

Unable to make changes to a folder despite being root

I want to create a new file in /sys/module/hid_apple/parameters/ but I am unable to do so! I've done the following:

su
(logged in)
cd /sys/module/hid_apple
chown 777 /parameters
chmod -rwx /parameters
chmod g+w /parameters
chmod ugo+rwx /parameters
chown root:root /parameters
chgrp root /parameters
cd /parameters
chown root *
cd ../
chown -R root:root /parameters
cd parameters
chmod 777 *

but nothing seems to work. I get "touch: cannot touch 'temp': Permission denied". I can't create or edit any file as su or with sudo or as a regular user! Also after every command I tried to create a new file and edit it inside parameters but it never worked.

Offline

#2 2018-07-08 16:23:18

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Unable to make changes to a folder despite being root

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

It is a pseudo filesystem you can not treat is like a regular filesystem.  What are you actually trying to achieve?

Last edited by loqs (2018-07-08 16:23:37)

Offline

#3 2018-07-08 17:55:53

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

I want to create the file 'swap_fn_leftctrl' and have only '1' inside it to swap ctrl with fn on the keyboard since no other method works. I don't want any tips on how to swap fn leftctrl but a way to create this file inside that path

Offline

#4 2018-07-08 18:01:46

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Unable to make changes to a folder despite being root

Have you patched the kernel to support that?

Offline

#5 2018-07-08 18:06:33

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

I've tried installing hid-apple-patched-git-dkms if that is what you mean. I've configured my kernel and re-generated mkinitcpio to support swaping the fn and ctrl key. If you're asking if I've patched my kernel to support editing /sys/, no and I don't know of a way to do that. If that is the case then please elaborate on how one would do that smile

Offline

#6 2018-07-08 18:14:29

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Unable to make changes to a folder despite being root

What was the result of "installing hid-apple-patched-git-dkms"?  How did you determine that the module you loaded was the patched one not the original one?
Why did you not supply this information in the first post?
Edit:
Given you have https://bbs.archlinux.org/viewtopic.php?id=238469 why did you create this thread?

Last edited by loqs (2018-07-08 18:23:56)

Offline

#7 2018-07-08 18:23:44

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

Because it did everything it said it would BESIDES creating this file that I want to create right now. The result of the package was as promised up until the swap of fn and ctrl. I don't see it as relevant since that patch didn't create this file that I believe creating the swap_fn_leftctrl file and pass '1' into it will fix my problem but that package doesn't do that which means I threw the idea of it ever fixing my issue out the window. The package itself won't change so I never mentioned it since it will never fix my issue. What will fix my issue is a way to create this file and pass '1' into it, hopefully.

Offline

#8 2018-07-08 18:41:46

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Unable to make changes to a folder despite being root

You regenerated the initrd is the module included in the initrd if so is the modconf hook specified?  What is your source that /sys/module/hid_apple/parameters/swap_fn_leftctrl should exist / be creatable?
Edit:
If you have loaded the patched module /sys/module/hid_apple/parameters/swap_fn_leftctrl should exist are you stating you have loaded the patched module and it does not exist?

Last edited by loqs (2018-07-08 18:49:46)

Offline

#9 2018-07-08 18:49:08

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

https://github.com/free5lot/hid-apple-p … figuration it's a temporary fix but creating this file will tell me if this is a fix or not. I fixed this like a week ago on the fly so I don't remember the specific things I did with my mkinitcpio but I included the module and I even added something to files=(). I am not interested in installing more packages and will only resort to that if nothing else works. What I want right now is to create that file.

Offline

#10 2018-07-08 18:52:27

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Unable to make changes to a folder despite being root

See my edit to post #8 and https://github.com/free5lot/hid-apple-p … pple.c#L56 you can not create a file that does not exist in that directory the kernel will not allow it.

Offline

#11 2018-07-08 18:55:27

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,720

Re: Unable to make changes to a folder despite being root

You are not understanding something very basic here.  As mentioned earlier, the sys file system contains file like objects whose contents are generated dynamically by the kernel when you read them to give you the ability to read certain states internal to the kernel.  In addition, some times they allow you to 'write' to these 'files' to change the kernel state.  You cannot create these files. You cannot write to arbitrary things to these 'files'.  The kernel will present what it wants, and will accept certain inputs.

https://en.wikipedia.org/wiki/Synthetic_file_system

Changing the kernel configuration and enabling things that are not in the stock kernel may cause the kernel to instantiate files that do not exist in the stock kernel. 
What is the name of the 'file' you are trying to create?

Last edited by ewaller (2018-07-08 18:57:31)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#12 2018-07-09 06:17:52

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

I want to create 'swap_fn_leftctrl' and pass '1' into it. I've tried hid-apple-patched but it also swaps CMD with ALT no matter what I put in '/etc/modprobe.d/hid_apple.conf'. I'd rather have fn as fn and not ctrl than have my CMD swaped with ALT. Is there a way to stop CMD and ALT from swapping when installing hid-apple-patched? I installed hid-apple-patched from aur if that makes any difference. Also I can't use the build.sh included on github since it can't find /usr/src/linux-headers-4.17.4-1-ARCH even when it's installed which I can see when I run mkinitcpio -p linux

Last edited by destou (2018-07-09 06:34:51)

Offline

#13 2018-07-09 07:22:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,843

Re: Unable to make changes to a folder despite being root

So now we're from "I installed this but it didn't work" to "i installed it but don't like the side effect"?
I suggest you post "no matter what I put in '/etc/modprobe.d/hid_apple.conf'" as "what you actually put there"

nB.
1. you need to reload the module after editing the file, in doubt reboot. "systool -vm apple_hid" likely also prints the actually used parameter vallues.
2. Apple uses "ctrl" and "cmd" and "alt" and "opt" as synonyms… really read the doc, https://github.com/free5lot/hid-apple-patched

Offline

#14 2018-07-09 08:08:12

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

We walked away from the main question because posters wanted information about things that I specified I never wanted to go towards: ' I don't want any tips on how to swap fn leftctrl but a way to create this file inside that path'. Anyways since it apparently isn't apparent that I've read the docs nor that the only things to put in hid_apple.conf is what's on the github docs of hid-apple-patched, here's my hid_apple.conf:

options hid_apple fnmode=2
options hid_apple swap_fn_leftctrl=1
options hid_apple swap_opt_cmd=0
options hid_apple rightalt_as_rightctrl=0

I get that people want as much information as possible but I never intended on going towards some github patch I've already tried, I intended this post to be about creating files in '/sys/' or more specifically '/sys/module/hid_apple/parameters/ '. Sometimes you can give and get too much information and the problem just steers away from the road so to say. I'm sorry I gave away information about the problem which I never should have since I knew it would go off road. Right now I'm ok with an answer on how to customize the changes that the patch from github makes OR a way to create a file in '/sys/'. Either way is fine and I would appreciate any effort towards either of the solutions! Thanks.

Offline

#15 2018-07-09 08:22:06

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,843

Re: Unable to make changes to a folder despite being root

You've been told several times now THAT YOU CANNOT CREATE FILES IN SYSFS!
sysfs is a kernel interface. The kernel and various modules expose variables there. Whenever you read such file, you read directly from a internal kernel state. Whenever you write into a file, you directly update a kernel variable.

The ONLY way to get a file in there is through a kernel module that exposes one of it's variables there.
Just forget about your desire to "add this file to solve my problem" - that's just complete nonsense.

On topic: did you actually inspect the apple_hid module parameters? Maybe also modinfo? And your initramfs?
The patched module from https://github.com/free5lot/hid-apple-patched adds this parameter and the "file" to sysfs unconditionally (and I mean "according to the source code), so the absence of the file is just a clear indicator that you do not actually load that module.

Offline

#16 2018-07-09 09:28:08

destou
Member
Registered: 2018-03-31
Posts: 59

Re: Unable to make changes to a folder despite being root

I created '/sys/module/hid_apple/parameters/swap_fn_leftctrl' and passed '1' into it which solved my problem. Executing systools to check the values of hid_apple gave me an error saying it couldn't load the module. Thanks for all the help!

Offline

#17 2018-07-09 13:14:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,843

Re: Unable to make changes to a folder despite being root

And how did you create the file…?

Offline

#18 2018-07-09 13:36:12

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: Unable to make changes to a folder despite being root

Creating that file manually (e.g., with `touch`) even if possible would be like breaking the plexiglass over the spedometer in your car and pushing the needle to point to a higher number: it doesn't actually make the car accelerate.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#19 2018-07-09 15:36:15

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,720

Re: Unable to make changes to a folder despite being root

Based on what I have read on Google, if you rebuild the module, make the changes to the hid configuration and restart the module, that file should magically appear.  If it does not, you need to find out why.  For example, have you looked in the kernel module directory for your kernel and verified that the module being loaded is the one you just built?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB