Linking to an opened inode w/o links left: how?

Discussion in 'C Programming' started by Jan Stap, Nov 10, 2003.

  1. Jan Stap

    Jan Stap Guest

    Hi,

    I am writing a wrapper in C for an existing program. The wrapper
    maintains a run file that is created for one invocation of the program
    and is removed for another. My idea of making the last action
    fool-proof is like this:

    - save the run file status via stat()
    - open the run file for reading
    - unlink() it
    - do an execv() on the program to be started
    - if the execv() fails, restore the link to the inode saved by stat()
    and close the run file
    - otherwise, the run file is deleted upon completion of the program
    started

    However, link() only allows adding a link by referring to another link
    to a given inode, not to the inode itself. Is there another way, or
    should I forget about this scheme and just use a fork() to start the
    program?

    Thanks,

    Jan Stap
     
    Jan Stap, Nov 10, 2003
    #1
    1. Advertising

  2. Jan Stap <> scribbled the following:
    > Hi,


    > I am writing a wrapper in C for an existing program. The wrapper
    > maintains a run file that is created for one invocation of the program
    > and is removed for another. My idea of making the last action
    > fool-proof is like this:


    > - save the run file status via stat()


    Not a standard C function.

    > - open the run file for reading
    > - unlink() it


    Not a standard C function.

    > - do an execv() on the program to be started
    > - if the execv() fails, restore the link to the inode saved by stat()


    Neither of these is a standard C function.

    > and close the run file
    > - otherwise, the run file is deleted upon completion of the program
    > started


    > However, link() only allows adding a link by referring to another link
    > to a given inode, not to the inode itself. Is there another way, or
    > should I forget about this scheme and just use a fork() to start the
    > program?


    link() and fork() are not standard C functions.

    Just to be clear and all, comp.unix.programmer is a better place to ask
    about this.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "It's not survival of the fattest, it's survival of the fittest."
    - Ludvig von Drake
     
    Joona I Palaste, Nov 10, 2003
    #2
    1. Advertising

  3. I guess this is both wrong, and not my business, but wasn't *nix written in
    C and therefore all that stuff is a subset of C?

    ML

    "Joona I Palaste"
    > > Hi,

    >
    > > I am writing a wrapper in C for an existing program. The wrapper
    > > maintains a run file that is created for one invocation of the program
    > > and is removed for another. My idea of making the last action
    > > fool-proof is like this:

    >
    > > - save the run file status via stat()

    >
    > Not a standard C function.
    >
    > > - open the run file for reading
    > > - unlink() it

    >
    > Not a standard C function.
    >
    > > - do an execv() on the program to be started
    > > - if the execv() fails, restore the link to the inode saved by stat()

    >
    > Neither of these is a standard C function.
    >
    > > and close the run file
    > > - otherwise, the run file is deleted upon completion of the program
    > > started

    >
    > > However, link() only allows adding a link by referring to another link
    > > to a given inode, not to the inode itself. Is there another way, or
    > > should I forget about this scheme and just use a fork() to start the
    > > program?

    >
    > link() and fork() are not standard C functions.
    >
    > Just to be clear and all, comp.unix.programmer is a better place to ask
    > about this.
    >
    > --
    > /-- Joona Palaste () ------------- Finland --------\
    > \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    > "It's not survival of the fattest, it's survival of the fittest."
    > - Ludvig von Drake
     
    Marcus Lessard, Nov 10, 2003
    #3
  4. Marcus Lessard <> scribbled the following:
    > I guess this is both wrong, and not my business, but wasn't *nix written in
    > C and therefore all that stuff is a subset of C?


    Unix *was* written in C, yes. But this doesn't magically make all this
    a subset of C. The web browser I use, Mozilla, was also written in C,
    but you don't see me asking questions how to configure the HTTP headers
    that Mozilla is sending here, do you?
    If you are meaning that the C API that Unix defines is a subset of C,
    that is also wrong. For it to be a subset of C it would have to work on
    all platforms that have a C implementation. This is provably false.

    PS. Please don't top-post. Thanks.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "When a man talks dirty to a woman, that's sexual harassment. When a woman talks
    dirty to a man, that's 14.99 per minute + local telephone charges!"
    - Ruben Stiller
     
    Joona I Palaste, Nov 10, 2003
    #4
  5. Jan Stap

    Mark Gordon Guest

    On Mon, 10 Nov 2003 12:46:39 -0500
    "Marcus Lessard" <> wrote:

    Please don't top post. I've fixed it and if you want to know why do a
    google search. We've already been through all the arguments.

    > "Joona I Palaste"


    <snip stuff about *nix specific code>

    > I guess this is both wrong, and not my business, but wasn't *nix
    > written in C and therefore all that stuff is a subset of C?


    No. The various Unix derivative are written in C + lots of extensions +
    assembler. It is not possible to write a complete operating system
    entirely in C.

    The C language and standard library are defined by K&R1 (for
    pre-standard) and the ANSI & ISO standards (ANSI predates ISO slightly)
    for anything since 1989.

    Here we only discuss C, not the *nix API or any other API or extensions.
    --
    Mark Gordon
    Paid to be a Geek & a Senior Software Developer
    Although my email address says spamtrap, it is real and I read it.
     
    Mark Gordon, Nov 10, 2003
    #5
  6. Marcus Lessard wrote:

    > I guess this is both wrong, and not my business, but wasn't *nix written in
    > C and therefore all that stuff is a subset of C?
    >
    > ML


    By your logic, any program written in C is a subset of the C language.
    If I write a program to drive a vending machine using the C language,
    then the vending machine must be a subset of the C language.
    Nope, wrong.

    If I use a tool to build a house, then the house is a subset of
    the tool. {Replace tool with hammer, drill, ruler, etc.}
    Hmm, doesn't make sense either.

    The _standard_ C language is all that is described by the ANSI/ISO
    standard. Nothing more. Languages are tools used to create
    programs.

    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.raos.demon.uk/acllc-c /faq.html
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
     
    Thomas Matthews, Nov 10, 2003
    #6
  7. Fair enough.

    "Thomas Matthews" > The _standard_ C language is all that is described by
    the ANSI/ISO
    > standard. Nothing more.
     
    Marcus Lessard, Nov 11, 2003
    #7
  8. [OT]: Linking to an opened inode w/o links left: how?

    Not a C question but since you said it would you mind explaining it?

    ejd

    "Joona I Palaste"

    PS. Please don't top-post. Thanks.
     
    Marcus Lessard, Nov 11, 2003
    #8
  9. Re: [OT]: Linking to an opened inode w/o links left: how?

    Marcus Lessard <> scribbled the following:
    > Not a C question but since you said it would you mind explaining it?


    You mean the bit about not top-posting? Sure.
    It has to do with how you write your reply to the post you are quoting.
    In bottom-posting, the quoted article goes first, the reply goes next.
    In top-posting, the reply goes first, the quoted article goes next.

    Example of bottom-posting:
    -----------------------------------------------------------------------
    Foo Bar wrote:
    > Is this true?

    Yes.
    -----------------------------------------------------------------------


    Example of top-posting:
    -----------------------------------------------------------------------
    Yes.
    Foo Bar wrote:
    > Is this true?

    -----------------------------------------------------------------------

    The reasons why top-posting is bad have been explained here several
    times in the last couple of days. Read the newsgroup a little more to
    find them.

    > "Joona I Palaste"


    > PS. Please don't top-post. Thanks.


    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Insanity is to be shared."
    - Tailgunner
     
    Joona I Palaste, Nov 11, 2003
    #9
  10. Re: [OT]: Linking to an opened inode w/o links left: how?

    "Joona I Palaste" <> wrote in message
    news:boqnov$422$...
    > Marcus Lessard <> scribbled the following:
    > > Not a C question but since you said it would you mind explaining it?

    >
    > You mean the bit about not top-posting? Sure.
    > It has to do with how you write your reply to the post you are quoting.
    > In bottom-posting, the quoted article goes first, the reply goes next.
    > In top-posting, the reply goes first, the quoted article goes next.
    >


    Ahh. I wondered if there was a preference on that. Thanks.

    ML
     
    Marcus Lessard, Nov 11, 2003
    #10
  11. Jan Stap

    Chris Torek Guest

    Re: [OT]: Linking to an opened inode w/o links left: how?

    In article <boqnov$422$>
    Joona I Palaste <> writes:
    >The reasons why top-posting is bad have been explained here several
    >times in the last couple of days. Read the newsgroup a little more to
    >find them.


    I have an example I came up with, but I like this one (apparently
    written by Clifton Sharp; see
    <http://groups.google.com/groups?selm=MPG.1989acc3b7d63f2498973a%40news.cis.dfn.de>)
    even better:

    "I'll see you at Linda's wedding."
    "Well, see ya soon."
    "Congratulations!"
    "Ten thousand a year."
    "How much?"
    "Got a really big raise this time."
    "Sorry to hear it. How's the job?"
    "She's not feeling well. Flu, I think."
    "Same as ever. How's yours?"
    "How's your wife?"
    "They painted her purple. They should call her the Prune Fart now."
    "Good. Did you hear what Martin and Sheila did to the Sea Breeze?"
    "Good, and you?"
    "Bill! How the heck are you?"

    One's goal in writing in a newsgroup is -- or at least should be,
    I believe -- communicating with others, and carefully-edited quotes
    interspersed with replies should help one achieve that.
    --
    In-Real-Life: Chris Torek, Wind River Systems
    Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
    email: forget about it http://67.40.109.61/torek/index.html (for the moment)
    Reading email is like searching for food in the garbage, thanks to spammers.
     
    Chris Torek, Nov 11, 2003
    #11
  12. Re: [OT]: Linking to an opened inode w/o links left: how?

    Chris Torek <> scribbled the following:
    > In article <boqnov$422$>
    > Joona I Palaste <> writes:
    >>The reasons why top-posting is bad have been explained here several
    >>times in the last couple of days. Read the newsgroup a little more to
    >>find them.


    > I have an example I came up with, but I like this one (apparently
    > written by Clifton Sharp; see
    > <http://groups.google.com/groups?selm=MPG.1989acc3b7d63f2498973a%40news.cis.dfn.de>)
    > even better:


    > "Got a really big raise this time."
    > "Sorry to hear it. How's the job?"


    Sorry to hear someone's got a big raise? Isn't that carrying envy a
    bit too far?

    > "How's your wife?"
    > "They painted her purple. They should call her the Prune Fart

    now."

    Painted his wife purple? Why? For her to pass as a Cataxxan?

    (Yes, I know what it really means. I was just having fun.)

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "This is a personnel commuter."
    - Train driver in Scientific American
     
    Joona I Palaste, Nov 11, 2003
    #12
  13. Re: [OT]: Linking to an opened inode w/o links left: how?

    "Chris Torek"
    >
    > One's goal in writing in a newsgroup is -- or at least should be,
    > I believe -- communicating with others, and carefully-edited quotes
    > interspersed with replies should help one achieve that.
    > --


    Us "top-posters" are not insane or stupid...we think that we are saving you
    the trouble of scrolling down to the new material. I honestly wouldn't have
    imagined that it was a big deal, but when in Rome post as the Romans do.

    ML
     
    Marcus Lessard, Nov 12, 2003
    #13
  14. Re: [OT]: Linking to an opened inode w/o links left: how?

    Marcus Lessard <> scribbled the following:
    > "Chris Torek"
    >> One's goal in writing in a newsgroup is -- or at least should be,
    >> I believe -- communicating with others, and carefully-edited quotes
    >> interspersed with replies should help one achieve that.


    > Us "top-posters" are not insane or stupid...we think that we are saving you
    > the trouble of scrolling down to the new material. I honestly wouldn't have
    > imagined that it was a big deal, but when in Rome post as the Romans do.


    If you find it tiresome to scroll though the quoted material, there is
    too much quoted material. Bottom-posting goes hand-in-hand with
    selective snipping.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "My absolute aspect is probably..."
    - Mato Valtonen
     
    Joona I Palaste, Nov 12, 2003
    #14
  15. Jan Stap

    Alan Balmer Guest

    Re: [OT]: Linking to an opened inode w/o links left: how?

    On Wed, 12 Nov 2003 11:41:33 -0500, "Marcus Lessard" <>
    wrote:

    >
    >"Chris Torek"
    >>
    >> One's goal in writing in a newsgroup is -- or at least should be,
    >> I believe -- communicating with others, and carefully-edited quotes
    >> interspersed with replies should help one achieve that.
    >> --

    >
    >Us "top-posters" are not insane or stupid...we think that we are saving you
    >the trouble of scrolling down to the new material. I honestly wouldn't have
    >imagined that it was a big deal, but when in Rome post as the Romans do.
    >
    >ML
    >

    Scrolling down to try to figure out what you're replying to is not an
    improvement.

    --
    Al Balmer
    Balmer Consulting
     
    Alan Balmer, Nov 12, 2003
    #15
  16. Re: [OT]: Linking to an opened inode w/o links left: how?

    Alan Balmer <> scribbled the following:
    > On Wed, 12 Nov 2003 11:41:33 -0500, "Marcus Lessard" <>
    > wrote:
    >>"Chris Torek"
    >>> One's goal in writing in a newsgroup is -- or at least should be,
    >>> I believe -- communicating with others, and carefully-edited quotes
    >>> interspersed with replies should help one achieve that.

    >>
    >>Us "top-posters" are not insane or stupid...we think that we are saving you
    >>the trouble of scrolling down to the new material. I honestly wouldn't have
    >>imagined that it was a big deal, but when in Rome post as the Romans do.
    >>

    > Scrolling down to try to figure out what you're replying to is not an
    > improvement.


    Indeed, I have seen top-posted articles where the reply starts with
    something like "But in that case..." while there are several points in
    the original article, not related to each other. "In *which* case?" I
    have to ask myself. Of course it was obvious to the responder when he
    read the original article but I can't read the responder's mind.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Hasta la Vista, Abie!"
    - Bart Simpson
     
    Joona I Palaste, Nov 12, 2003
    #16
  17. Re: [OT]: Linking to an opened inode w/o links left: how?

    Marcus Lessard wrote:

    > Chris Torek wrote:
    >
    >>One's goal in writing in a newsgroup is -- or at least should be,
    >>I believe -- communicating with others, and carefully-edited quotes
    >>interspersed with replies should help one achieve that.

    >
    > Us "top-posters" are not insane or stupid.
    > We think that
    > we are saving you the trouble of scrolling down to the new material.
    > I honestly wouldn't have imagined that it was a big deal,
    > but when in Rome post as the Romans do.


    The point is that
    we don't want you to quote the article to which you are responding.
    Instead, snip out everything that is irrelevant to your response.
    Don't complain about misspelled words, poor grammar, punctuation
    or capitalization. Quietly fix it if it bothers you.
    Paraphrase as necessary to best represent *your* understanding
    of what was said in the article to which you are responding.
    Subscribers can consult the archives of previous messages
    if they feel that you have misrepresented what was actually said.
    If the article to which you are responding makes multiple points,
    try to isolate each point and insert your response immediately
    after each point.
     
    E. Robert Tisdale, Nov 12, 2003
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. removing file by inode

    , Mar 23, 2006, in forum: Python
    Replies:
    5
    Views:
    609
    Arne Ludwig
    Mar 23, 2006
  2. kerb
    Replies:
    4
    Views:
    357
  3. asit

    inode number in windows XP

    asit, Jan 25, 2008, in forum: Python
    Replies:
    2
    Views:
    1,363
    Gabriel Genellina
    Jan 25, 2008
  4. open file by inode?

    , May 28, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    345
  5. Replies:
    4
    Views:
    279
    Nobody
    Jan 31, 2013
Loading...

Share This Page