Skip to contentSkip to conversation

Block driver design issue

DISCUSSION LA Walsh 2 participants 2 messages Feb 12, 2001

lore
Share & tools
lore

LA Walsh

author
#0 lore raw

I have a block driver I inherited that I working on that has a problem and was wondering for cleaner solutions.

The driver can accept written characters from either userspace programs or from the kernel. From userspace it uses sys_write. That in turn calls block_write. There's almost 100 lines of duplicated code in a copy of the block_write
code in the driver "block_writek" as well as duplicate code in audit_write vs. audit_writek. The only difference being down in block_write at the "copy_from_user(p,buf,chars); " which becomes a "memcpy(p,buf,chars)" in the "block_writek" version.

I find this duplication of code to be inefficient. Is there a way to dummy up the the 'buf' address so that the "copy_from_user" will copy the buffer from kernel space? My assumption is that it wouldn't "just work" (which may also be an invalid assumption).

Suggestions? Abuse?

Thanks!
-linda

Signature · 7 lines
L A Walsh                    | Trust Technology, Core Linux, SGI
[email protected]                      | Voice: (650) 933-5338
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://vger.kernel.org/lkml/
#1 lore raw
Quoted 8 lines · LA Walsh

I find this duplication of code to be inefficient. Is there a way to dummy up the the 'buf' address so that the "copy_from_user" will copy the buffer from kernel space? My assumption is that it wouldn't "just work" (which may also be an invalid assumption).

Suggestions? Abuse?

set_fs(KERNEL_DS)?

After that call copy_from_user() will accept kernel space addresses.

--
Manfred
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://vger.kernel.org/lkml/