[lkml]   [2003]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] new syscall: flink
    Followup to:  <>
    By author: Alan Cox <>
    In newsgroup:
    > It is actually rather more complicated. Suppose I give you a pipe
    > pair handle. You can flink what was a private object and has no
    > meaning as a name.
    > Suppose I give you a socket what does the call man ?
    > Suppose I give you a handle to an anonymous mapping ?


    > Suppose I give you a handle to data, how do you know what disk
    > it belongs to ?

    f_ino->i_sb should give you that information.

    > Suppose I give you an O_RDONLY handle to a file which you then
    > flink and gain write access too ?

    This, I believe, is the real issue. However, we already have that

    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <limits.h>

    int main(int argc, char *argv[])
    int rfd, wfd;
    char filebuf[PATH_MAX];

    rfd = open("testfile", O_RDONLY|O_CREAT, 0666);
    /* Now rfd is a read-only file descriptor */

    sprintf(filebuf, "/proc/self/fd/%d", rfd);
    wfd = open(filebuf, O_RDWR);
    /* Now wfd is a read-write file descriptor */

    write(wfd, "Tjo fidelittan hatt!\n", 21);

    return 0;

    <> at work, <> in private!
    "Unix gives you enough rope to shoot yourself in the foot."
    Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:34    [W:0.022 / U:9.048 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site