system call to map memory to a file descriptor (inverse mmap)?

后端 未结 3 1905
醉酒成梦
醉酒成梦 2021-01-18 09:06

I want to be able to map memory to a file descriptor so I can use some existing functions that need a file descriptor. Here\'s essentially what I\'m looking for:

         


        
相关标签:
3条回答
  • 2021-01-18 09:39

    Sure, just open(argv[0], ...), scan through the file to find where your binary data starts, lseek() there and done. That file won't have the length of your binary data of course.

    0 讨论(0)
  • 2021-01-18 09:41

    Some implementations have fmemopen(). (Then of course you have to call fileno()).

    If yours doesn't, you can build it yourself with fork() and pipe().

    0 讨论(0)
  • 2021-01-18 09:52

    You should Check out shm_open().

    0 讨论(0)
提交回复
热议问题