I'm having trouble with changing permissions of a file using syscal call function number 15 (that is sys_chmod). Here is my code snippet:
我使用syscal调用函数15(即sys_chmod)更改文件的权限时遇到问题。这是我的代码片段:
mov eax, 15
mov ebx, fileName
mov ecx, 00400 | 00200 | 00040
int 80h
where 00400 & 00200=read and write by owner and 00040 read my group obviously.
其中00400&00200 =由所有者读取和写入,00040明显地读了我的小组。
The thing is that the file is not set properly. It sets correct for owner, but for group it doesn't set read, but write instead. Then I tried to use only 00400 | 00200, and strange thing happened, the owner was set OK, but the group was set to write also.
问题是文件设置不正确。它为所有者设置正确,但对于组,它不设置读取,而是写入。然后我试着只使用00400 | 00200,奇怪的事情发生了,主人设置好了,但是小组也写了也写了。
1 个解决方案
#1
You forgot to mention what assembler you are using. Make sure it interprets those numbers in octal. nasm, for example, doesn't and will produce the result you see.
你忘了提到你正在使用的汇编程序。确保它以八进制解释这些数字。例如,nasm不会并且会产生您看到的结果。
A small quote from the linked manual:
来自链接手册的小报价:
mov ax,200 ; decimal
mov ax,0200 ; still decimal
mov ax,0200d ; explicitly decimal
mov ax,0d200 ; also decimal
mov ax,0c8h ; hex
mov ax,$0c8 ; hex again: the 0 is required
mov ax,0xc8 ; hex yet again
mov ax,0hc8 ; still hex
mov ax,310q ; octal
mov ax,310o ; octal again
mov ax,0o310 ; octal yet again
mov ax,0q310 ; octal yet again
#1
You forgot to mention what assembler you are using. Make sure it interprets those numbers in octal. nasm, for example, doesn't and will produce the result you see.
你忘了提到你正在使用的汇编程序。确保它以八进制解释这些数字。例如,nasm不会并且会产生您看到的结果。
A small quote from the linked manual:
来自链接手册的小报价:
mov ax,200 ; decimal
mov ax,0200 ; still decimal
mov ax,0200d ; explicitly decimal
mov ax,0d200 ; also decimal
mov ax,0c8h ; hex
mov ax,$0c8 ; hex again: the 0 is required
mov ax,0xc8 ; hex yet again
mov ax,0hc8 ; still hex
mov ax,310q ; octal
mov ax,310o ; octal again
mov ax,0o310 ; octal yet again
mov ax,0q310 ; octal yet again