Mkdir() permission denied C/linux programming -
when execute code, error couldn't create backup sub-directory: permission denied
can't understand why since give full permisions , i'm using admin account on ubuntu.
umask(0777); int folder_date_status = mkdir(filepath_w, 0777); if(folder_date_status == -1){ perror("couldn't create backup sub-directory"); return -1; }
an admin account doesn't run full privileges default. programs run don't unexpectedly act privileged users (ie. must explicitly give permission).
to give permission program create sub-directory in directory requires privileged access, try using sudo
.
if program name called myprogram
, try running:
sudo ./myprogram
then type password if requested.
note super-user access should required if trying make subdirectory in write-restricted directory (eg. restricted directory owned root, or user). ensure parent directory exists (otherwise throw error).
Comments
Post a Comment