data fork problem

Posted on 2004-11-02
Last Modified: 2013-12-26

Hi All,
I have an  application that locks a file by puting some informations at the beginning of its data fork.
so it can,t be open by another application.
My question is :
I s there any way to prevent  the application from doing so?


Question by:bachra04
    LVL 23

    Expert Comment

    LVL 2

    Author Comment

    This does not resolve the problem because my purpose is to eliminate the locking mechanism implemented by this application (of course I dispose only with the executable of this application).
    So is it it possible to protect only one part (let's say the first 256 bits) of data fork from writing.
    and make them read only.
    LVL 23

    Expert Comment

    Both lockf() and fcntl() provide for locking regions of files - specified as a range of bytes 256 bits == 64 bytes.

    LVL 2

    Author Comment

    Thank you for your comments ,
    As you've said lockf and fcntl provide locking region but this didn't help me prevent the locking action of the application.
    What I think is that application uses flock () to provide exclusif access.
    My last action :
    Is there a way to prevent or to fail the action of flock() programmatically ?
    At the documentation I see that flock may be failed  by signals
    "Processes blocked awaiting a lock may be awakened by signals."
    So is it possible to do that by programming.

    In conclusion:
    The first application open a data file and locks it for its exclusif use.
    I want my application to open the same file at this moment and remove the locking so I can write on it Is this possible?

    Thank you again


    LVL 23

    Accepted Solution

    I you lock the file yourself (before the other application does so), using the same locking mechanism,
    you will prevent the other app from locking the file.  However that will probably adversely affect
    the application in question ( it will probably either wait for the lock to be released, or generate
    and error, or simply exit).   Your posts indicate that your goal is to "fool" the application into thinking
    it locked the file without actually doing so.  Keep in mind that the application likely uses file locking to
    coordinate activity and/or prevent data corruption.

    You have apparently asked us how to do something that seems unwise.  Perhaps we need to understand
    what the greater goal is.   Why do you wish to disable application file locking?  What are you trying
    to accomplish?
    LVL 2

    Author Comment

    #Your posts indicate that your goal is to "fool" the application into thinking
    #it locked the file without actually doing so.  

    yes this is exactely what I want to do.

    #Keep in mind that the application likely uses file locking to
    #coordinate activity and/or prevent data corruption.

    I agree with you but I planned to take care of that from my application.

    My Goal is to convert a standalone application to pseudo centralized application.
    But it seems impossible

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    Need to retreive data from .TFS file exported by DVR 8 149
    Host to IP 7 58
    bigDiff challenge 17 47
    haveThree challenge 22 81
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now