-
Notifications
You must be signed in to change notification settings - Fork 26
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
Task5: Hello module with proc_fs #101
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
…rning during compilation Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
Signed-off-by: EugeneKolesnyk <[email protected]>
task5-proc_fs/hello.c
Outdated
|
||
static int __init hello_init(void) | ||
{ | ||
procfs_buffer_size = sprintf(procfs_buffer, "%d + %d = %d\n", num1, num2, num1 + num2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style issues are here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed code style issues
task5-proc_fs/hello.c
Outdated
proc_file = proc_create(PROC_FILE_NAME, 0666, proc_folder, &fops); | ||
if (!proc_file) { | ||
pr_err("HELLO: Error: Could not initialize /proc/%s/%s\n", PROC_DIR_NAME, PROC_FILE_NAME); | ||
proc_remove(proc_file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sense to call proc_remove(proc_file);
here because proc_file
is not valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
task5-proc_fs/hello.c
Outdated
|
||
static void __exit hello_exit(void) | ||
{ | ||
pr_info("HELLO: Goodbye Kernel!\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style issues are here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed code style issues
task5-proc_fs/hello.c
Outdated
|
||
to_copy = min(count, procfs_buffer_size); | ||
|
||
not_copied = copy_to_user(buffer, procfs_buffer, to_copy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per my understanding, if procfs_buffer_size
variable is maintained and updated in the code below it is assumed that procfs_buffer
contents can be read by the user space app by multiple reads.
For example 100 bytes buffer can be read by 2 hello_read
calls with count
set to 25 and 75.
But, data is copied to the user provided buffer from the beginning of the procfs_buffer
, so the same data will be copied twice, what, per my understanding, is not expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments in the task5-proc_fs/hello.c file.
Signed-off-by: EugeneKolesnyk <[email protected]>
No description provided.