summaryrefslogtreecommitdiff
path: root/lib/mkdir-p.c
AgeCommit message (Collapse)Author
2006-07-17Don't include alloca.h, stdio.h, sys/types.h,Paul Eggert
unistd.h, string.h, chdir-safer.h, dirname.h, lchmod.h, lchown.h, save-cwd.h. Instead, include dirchownmod.h and mkancesdirs.h. (make_dir_parents): New args MAKE_ANCESTOR, OPTIONS, ANNOUNCE, MODE_BITS. Remove options VERBOSE_FMT_STRING, CWD_ERRNO. All callers changed. Revamp internals significantly, by not attempting to create directories that are temporarily more permissive than the final results. Do not attempt to use save_cwd/restore_cwd; it isn't worth it for mkdir and install. This removes some race conditions, fixes some bugs, and simplifies things. Use new dirchownmod function to do owner and mode changes.
2006-01-02Include lchmod.h, lchmod.c.Paul Eggert
(make_dir_parents): Use lchown rather than chown, and lchmod rather than chmod.
2005-12-23(make_dir_parents): Use chdir_no_follow onlyJim Meyering
if we've just created the directory.
2005-12-20(RW_USR): Remove definition.Jim Meyering
(make_dir_parents): Use S_IRWXU, now that read access is also required. Avoid a race condition, on systems where open honors O_NOFOLLOW. (make_dir_parents): Include chdir-safer.h. Use chdir_no_follow in place of chdir.
2005-12-20(make_dir_parents): Remove unnecessary casts of alloca,Jim Meyering
since now it's guaranteed to be (void *).
2005-10-24(make_dir_parents): Like the code above it, don't relyJim Meyering
on mkdir failing with a particular errno value (EEXIST). Based on a patch by Dmitry V. Levin.
2005-10-24(make_dir_parents): Make the preceding fix a littleJim Meyering
more robust, e.g., when the final component is created as a non- directory by another process just before `mkdir -p's final mkdir.
2005-10-24A command like `mkdir -p nonexistent/.' would create theJim Meyering
directory but exit nonzero with a diagnostic. This could also be triggered with a non-`.' component, e.g., in a race with another process running the same `mkdir -p nonexistent/sub' command. (make_dir_parents): Handle the case of an existing final component. Reported by Matthias Andree here: http://savannah.gnu.org/bugs/?func=detailitem&item_id=14848
2005-10-13(make_dir_parents): Don't report an error if anPaul Eggert
intermediate directory is in a read-only file system.
2005-09-22(ENOSYS): Define to EEXIST if not defined.Paul Eggert
(make_dir_parents): Treat ENOSYS like EEXIST.
2005-07-02Assume HAVE_UNISTD_H, i.e., include <unistd.h> unconditionally.Jim Meyering
2005-06-29(make_dir_parents): Don't apply sizeof to a hard-coded type name.Jim Meyering
Use the variable name instead.
2005-06-15(make_dir_parents): Don't let a failed chdir($PWD)Jim Meyering
stop us from restricting permissions of just-created absolute-named directories.
2005-06-14(make_dir): Remove. All uses replaced by mkdir.Paul Eggert
(make_dir_parents): Last arg is now int * (for errno), not bool *. Rewrite "mkdir -p" algorithm to avoid the need for "stat" each time through the loop. Do not diagnose restore_cwd failure; that is the caller's job (and perhaps the caller does not care).
2005-06-14(CLEANUP_CWD, CLEANUP): Remove.Paul Eggert
(make_dir_parents): Revamp to avoid need for CLEANUP_CWD, CLEANUP. If the file already exists but is not a directory, don't bother to try to make its parents. Close potential file descriptor leak if we can't chdir("/") (!). Don't always return true if chdir($PWD) fails; return true only if the requested action was done successfully (except for the chdir($PWD)). Don't log final directory unless we actually made it. Refactor to avoid duplicate code to fix up permissions. Don't attempt to fix up parent permissions if chdir($PWD) fails.
2005-06-14clarify commentJim Meyering
2005-06-14(CLEANUP_CWD): Return *true*, not false when failingJim Meyering
to restore initial working directory.
2005-06-13(make_dir_parents): New parameter: different_working_dir,Jim Meyering
to tell caller if/when we change the working directory and are unable to return to the initial one.
2005-06-12(CLEANUP_CWD): Change one more `return 1' to `return false'.Jim Meyering
This fixes a bug introduced on 2004-07-30.
2005-06-02Renamed from makepath.c.Paul Eggert
(make_dir_parents): Renamed from make_path. All callers changed.