Re: Reading from file in module fails

From: Libor Vanek (libor_at_conet.cz)
Date: 05/03/04

  • Next message: Sau Dan Lee: "[PATCH] modused: mark some modules as in use (Re: [PATCH] (fix:oops with rmmod i8042))"
    Date:	Mon, 3 May 2004 13:43:16 +0200
    To: Erik Mouw <erik@harddisk-recovery.com>
    
    

    > > I need to copy files (yes - I know that kernel shouldn't do this but
    > > I REALLY need).
    >
    > This is ugly, but it should do the trick:
    >
    > int rv;
    > char *argv[4] = {"/bin/cp", "/tmp/foo", "/tmp/bar", NULL};
    > char *envp[3] = {"HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL};
    >
    > rv = call_usermodehelper(argv[0], argv, envp, 1);
    >
    > if(rv < 0) {
    > /* error handling */
    > }
    >
    > Called from kernel, done in userspace. And if you want to access an SQL
    > database from kernel tomorrow, it's just a matter of changing the
    > usermode helper.
    >
    > (BTW, if you need to copy files from kernel, it's usually a sign of bad
    > design)

    Geez - that's REALLY ugly :-) But for testing I can use it.

    It's not bad design - what I'm doing is writing snapshots for VFS as my diploma thesis. And I need to create copy of file before it's changed (copy-on-write). There is no other way how to do it in kernel-space (and user-space solutions like using LUFS are really slow)

    Thx,
    Libor

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


  • Next message: Sau Dan Lee: "[PATCH] modused: mark some modules as in use (Re: [PATCH] (fix:oops with rmmod i8042))"

    Relevant Pages

    • Re: Heads up for distro folks: PCMCIA hotplug differences (Re: -rc4: arm broken?)
      ... PCMCIA can work without userspace on 2.6.13 if you compile all necessary ... a Manufactor/Device or Product ID match is known for the device. ... that's currently done by waiting for userspace telling the kernel that it ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH 1/3] Audit: break up execve argument lists into multiple records
      ... The limit is currently around 7.5k of arguments as userspace ... memory leak on a malloc failure code path. ... making it harder on the kernel to have the memory it needs. ... int audit_n_rules; ...
      (Linux-Kernel)
    • Re: connector.c
      ... If the kernel expects a reply from userspace ... connector user, if reply will not be received just nothing happens. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [linux-usb-devel] Re: Fw: ati-remote strangeness from 2.6.12 onwards
      ... Pavel: I would think that 'more useful' is not really the same as ... It should not be KEY_ENTER in the kernel ... this is not possible in userspace. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH 0/3] Transition /proc/cpuinfo -> sysfs
      ... runs on any kernel would now have to support an extra method of obtaining ... Then people wonder why userspace apps are bloating ... Then people wonder why installers ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)