![]() ![]() ![]() ![]() You think, if S_IRUSR works when file create, then the file is always empty and read only, it has no sense. Even S_ISUSR is read only, but in fact still return read/write permission, the final permission depends on the flags, if the flag is O_WRONLY, it can only write when create, if the flag is O_RDONLY, it can only read when create.įd = open("xxx", O_CREAT|O_WRONLY, S_IRUSR) Īnd result is expected, at first time, when file create, if has write permission and has no read permission, after first time, it open failed:Īnd I can understand why they design the mode parameter only work after first time. It means S_ISUSR only works after first time. Note that this mode applies only to future accesses of the newly created file the open() call that creates a read-only file may well return a read/write file descriptor. Then let us face the more important question, why S_ISUSR doens't work at first time. In fact, if use your code, ran after first time, it is not couldn't be written to, it is not be open. Of cource, when I ran executable after first time, it worked like I expect when it could't be written to. Then execute the program whenever, it will always says "write failed", and "xxx" is empty. Codes are following: #include įd = open("xxx", O_CREAT|O_RDONLY, S_IRUSR) you can just remove O_WRONLY and O_APPEND flag, and add O_RDONLY flag or not. I will explain why it doesn't work at first time.Īt first let us resolve your question. Printf("The File %s\t is not an Executable\n",fileName) Īnd the output says: The File test.sh Found Printf("The File %s\t is an Executable\n",fileName) Printf("The File %s\t it cannot be Edited\n",fileName) Printf("The File %s\t it can be Edited\n",fileName) Printf("The File %s\t cannot be read\n",fileName) Printf("The File %s\t can be read\n",fileName) ![]() Printf("The File %s\t not Found\n",fileName) writeable yes (beware not writable ) windows7 can modify existing files and create new files. I had: read only no already in the smb.conf by adding. Printf("The File %s\t Found\n",fileName) from xp i had complete access while W7 showed read and write permission, but could not actually create new files or edit existings. I have however tried a lot of different setup, ready made configs, and solutions to similar problems for the smb.conf file, so I suspect that the real problem is somewhere else.Fd=open("test.sh",O_CREAT|O_APPEND,S_IRUSR) Īnd if you try to write that file, you will get: Īnyway, on my Linux machine if I wanna check that file, I will do it like this: #include What can I try to be able to write to the shares?ĮDIT: The replies I got so far are mostly concerned with the smb.conf. I've tried a lot to get this to work: the disk are chmodded to 777, I've tried turning off selinux, I've added the samba_share_t label to the disks and as can be seen in the above output I tried to make the smb config as permissive as I could, but still I cannot write to the share (tried from Windows 7 and another Fedora installation). The root folders of these harddisks are owned by superman:superman, and testparm outputs the following: 2 of these use the ext4 filesystem, the third one is ntfs. I have a local fileserver with 3 harddisks mounted at /mnt/share/disk. I try to setup a samba file server, but whatever I do I can't get write access to work (reading works fine). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |