Comments (7)
- Unmached code and comment
Lines 44 to 56 in 637e707
"\015\012"
is\v\b
rather than CRLF\r\n
.
from lkmpg.
Hi @minghu6 ,
Sorry for the late to reply.
Move the confusing note about
struct proc_ops
replacing withstruct file_operations
on linux >=5.6:
Lines 957 to 990 in 637e707
The
struct proc_ops
would replace thestruct file-operations
only when create proc releated defined on <linux/proc_fs.h>
In other word, regist device doesn't be affected, still usingstruct file_operations
. It's confusing write this note above the regist device code (FOE ME, I HAVE SPENT PLENTY OF TIME ON SEARCHING HOW TO REGIST DEVICE USING STRUCT PROC_OPS)
I highly recommend to move this note down to next code example which replacing takes place truely!
Yes, it won't affect the registering of the device, but the paragraph here actually talks about the file operation. And, it seems like the file operation will be related to the proc_ops
. So, I think the description of proc_ops
replacing the file_ops
is still needed in the section here.
But still, it might confuse others. So, I will add more sentences to hint that this description talks about the file_ops
and proc_ops
rather than registering the device.
Lines 25 to 39 in 637e707
The msg char array should be declared with length of
BUF_LEN + 1
sinceBUF_LEN
is max length of message.
The macro, BUF_LEN
, is the length of the buffer, not the message length.
So, I think there doesn't need to change.
Line 152 in 637e707
On
device_write
, It's prefered to useEOPNOTSUPP
instead ofEINVAL
since the former raises unsupported error, the latter raises invalid argument.
Yes, it should uses the EOPNOTSUPP
.
Thanks.
Improve read/write fucntion code among
fsproc{1-3}.c
:
Lines 23 to 40 in 637e707
Lines 41 to 53 in 637e707
These code are a little wired and far from decent, the parameter
loff_t *
is ignored incorrectly and so the behavior is quite different from normal read/write.I've reimplemented read/write code, here is full code:It need more modern c standard config than C90, for example
ccflags-y += -std=gnu17
.
The read/write functions are a little weird. I will modify them.
For using modern C standards, we need to consider more.
Since kernel version v5.18, especially after this commit "Kbuild: move to -std=gnu11", kernel supports C11 features. We have the option to move to it.
But considering LKMPG is supporting the v5.x version, we must stick to the C89 still a while.
However, for C17, it might be the wrong standard to use.
from lkmpg.
Unmached code and comment
Lines 44 to 56 in 637e707
"\015\012"
is\v\b
rather than CRLF\r\n
.
The "\015\012"
seems correct.
According to the ASCII table, CR
is 015
and LF
is 012
.
And, \v\b
is \013\010
.
I might be wrong, please provide more information about this.
Thanks
from lkmpg.
Line 152 in 637e707
On
device_write
, It's prefered to useEOPNOTSUPP
instead ofEINVAL
since the former raises unsupported error, the latter raises invalid argument.Yes, it should uses the
EOPNOTSUPP
. Thanks.
Sorry, I recheck the write man page to make sure that the change here is suitable to the definition.
In the man page, it doesn't have any error value that is EOPNOTSUPP
, ENOTSUP
, or even ENOTSUPP
(kernel defined).
And from the description of EINVAL
in the manual:
EINVAL fd is attached to an object which is unsuitable for
writing; or the file was opened with the O_DIRECT flag,
and either the address specified in buf, the value
specified in count, or the file offset is not suitably
aligned.
fd is attached to an object which is unsuitable for writing
The EINVAL
is correct. We don't have to change to EOPNOTSUPP
.
from lkmpg.
Lines 25 to 39 in 637e707
The msg char array should be declared with length of
BUF_LEN + 1
sinceBUF_LEN
is max length of message.The macro,
BUF_LEN
, is the length of the buffer, not the message length. So, I think there doesn't need to change.
Oops, I saw the comments.
Sorry again.
from lkmpg.
Ready to close?
from lkmpg.
Sure, I think.
If there are any other opinions we can just reopen it.
from lkmpg.
Related Issues (20)
- procfs3.ko used by -1 HOT 2
- procfs2.c vs. procfs3.c HOT 1
- 11.1 Sleep chapter. API module_interruptible_sleep_on HOT 1
- Reason to reset the offset HOT 2
- Smatch repository is unavailable HOT 1
- Build kernel module for Rpi3MB HOT 1
- Building kernel modules in RpiOS32bit/Rpi3MB platform HOT 2
- lkmpg on RpiOsLite/rpi3MB HOT 1
- Consistent usage of __init and __exit HOT 1
- About 16.2 Symmetric key encryption sample code HOT 2
- examples/kbleds.c:64:55: error: ‘struct tty_driver’ has no member named ‘magic’
- Building kbleds.ko on RpiOSLite64bit (Linux 6.1.21-v8+) HOT 4
- examples/sched.ko HOT 4
- Module parameters callback : be notified when a parameter is updated
- Little introduction to debugfs
- About /proc, try_module_get and python3 HOT 3
- If you want to build device drivers for an cross target (yocto build) ... HOT 1
- typo
- Linux HOT 1
- Talking to other subsystems
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lkmpg.