|
1 | 1 | /*
|
2 |
| - * ch16/2_miscdrv_rdwr_spinlock/miscdrv_rdwr_spinlock.c |
| 2 | + * ch12/2_miscdrv_rdwr_spinlock/miscdrv_rdwr_spinlock.c |
3 | 3 | ***************************************************************
|
4 | 4 | * This program is part of the source code released for the book
|
5 |
| - * "Linux Kernel Development Cookbook" |
| 5 | + * "Linux Kernel Programming" |
6 | 6 | * (c) Author: Kaiwan N Billimoria
|
7 | 7 | * Publisher: Packt
|
8 | 8 | * GitHub repository:
|
9 |
| - * https://github.com/PacktPublishing/Linux-Kernel-Development-Cookbook |
| 9 | + * https://github.com/PacktPublishing/Linux-Kernel-Programming |
10 | 10 | *
|
11 |
| - * From: Ch 16 : Kernel Synchronization - Part 1 |
| 11 | + * From: Ch 12 : Kernel Synchronization - Part 1 |
12 | 12 | ****************************************************************
|
13 | 13 | * Brief Description:
|
14 | 14 | * This driver is built upon our previous ch16/1_miscdrv_rdwr_mutexlock/
|
|
17 | 17 | * the case everywhere in the driver though; we keep the mutex as well for some
|
18 | 18 | * portions of the driver).
|
19 | 19 | *
|
20 |
| - * For details, please refer the book, Ch 16. |
| 20 | + * For details, please refer the book, Ch 12. |
21 | 21 | */
|
22 | 22 | #define pr_fmt(fmt) "%s:%s(): " fmt, KBUILD_MODNAME, __func__
|
23 | 23 |
|
@@ -231,7 +231,7 @@ static ssize_t write_miscdrv_rdwr(struct file *filp, const char __user *ubuf,
|
231 | 231 | * new 'secret' into our driver 'context' structure, and unlock.
|
232 | 232 | */
|
233 | 233 | spin_lock(&ctx->spinlock);
|
234 |
| - strlcpy(ctx->oursecret, kbuf, (count > MAXBYTES ? MAXBYTES : count)); |
| 234 | + strscpy(ctx->oursecret, kbuf, (count > MAXBYTES ? MAXBYTES : count)); |
235 | 235 | #if 0
|
236 | 236 | print_hex_dump_bytes("ctx ", DUMP_PREFIX_OFFSET,
|
237 | 237 | ctx, sizeof(struct drv_ctx));
|
@@ -331,8 +331,8 @@ static int __init miscdrv_init_spinlock(void)
|
331 | 331 | /* Retrieve the device pointer for this device */
|
332 | 332 | ctx->dev = llkd_miscdev.this_device;
|
333 | 333 |
|
334 |
| - strlcpy(ctx->oursecret, "initmsg", 8); |
335 |
| - /* Why don't we protect the above strlcpy() with the mutex / spinlock? |
| 334 | + strscpy(ctx->oursecret, "initmsg", 8); |
| 335 | + /* Why don't we protect the above strscpy() with the mutex / spinlock? |
336 | 336 | * It's working on shared writable data, yes?
|
337 | 337 | * No; this is the init code; it's guaranteed to run in exactly
|
338 | 338 | * one context (typically the insmod(8) process), thus there is
|
|
0 commit comments