linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* chdir command
@ 2002-05-03 19:54 Allan Wooley
  2002-05-03 21:31 ` Brian Raiter
  2002-05-06  6:32 ` Konstantin Boldyshev
  0 siblings, 2 replies; 4+ messages in thread
From: Allan Wooley @ 2002-05-03 19:54 UTC (permalink / raw)
  To: Linux Assembly

I can not get system call #12 to work as advertised.  In Read Hat Linux
7.2 under bash using nasm with elf I write:

section .text
    global _start

path    db '/root',0

_start:

    mov ebx, path
    mov eax,12
    int 80h

    mov eax, 1
    int 80h        ;; int 0x80

Although I have gotten system calls 1, 3-6 & 11 to work fine in assembly
programs, I can not get the change-working-directory call to work.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* chdir command
@ 2002-05-03 19:55 Allan Wooley
  0 siblings, 0 replies; 4+ messages in thread
From: Allan Wooley @ 2002-05-03 19:55 UTC (permalink / raw)
  To: Linux Assembly

I can not get system call #12 to work as advertised.  In Read Hat Linux
7.2 under bash using nasm with elf I write:

section .text
    global _start

path    db '/root',0

_start:

    mov ebx, path
    mov eax,12
    int 80h

    mov eax, 1
    int 80h        ;; int 0x80

Although I have gotten system calls 1, 3-6 & 11 to work fine in assembly
programs, I can not get the change-working-directory call to work.

Thanks, Al (awooley@exeter.edu)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: chdir command
  2002-05-03 19:54 chdir command Allan Wooley
@ 2002-05-03 21:31 ` Brian Raiter
  2002-05-06  6:32 ` Konstantin Boldyshev
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Raiter @ 2002-05-03 21:31 UTC (permalink / raw)
  To: Allan Wooley; +Cc: Linux Assembly

> I can not get system call #12 to work as advertised.  In Read Hat Linux
> 7.2 under bash using nasm with elf I write:
> 
> section .text
>     global _start
> 
> path    db '/root',0
> 
> _start:
> 
>     mov ebx, path
>     mov eax,12
>     int 80h
> 
>     mov eax, 1
>     int 80h        ;; int 0x80
> 
> Although I have gotten system calls 1, 3-6 & 11 to work fine in assembly
> programs, I can not get the change-working-directory call to work.

The chdir call is working just fine. What you're forgetting is that
every process has its own current directory. That's why the cd command
has to be a shell builtin -- a process can't change its parent's
current directory, only its own.
________________

section .bss
cwdbuf:
    resb 1024

%macro printcwd 0			;; call getcwd, then write
		pusha
		mov	ebx, cwdbuf
		mov	ecx, 1024
		mov	eax, 183
		int	0x80
		mov	byte [ebx + eax], 10
		inc	eax
		mov	edx, eax
		mov	ecx, ebx
		mov	ebx, 1
		mov	eax, 4
		int	0x80
		popa
%endmacro


section .text
    global _start

path    db '/root',0

_start:

	printcwd

    mov ebx, path
    mov eax, 12
    int 80h

	printcwd

    xor ebx, ebx
    mov eax, 1
    int 80h        ;; int 0x80
________________

b

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: chdir command
  2002-05-03 19:54 chdir command Allan Wooley
  2002-05-03 21:31 ` Brian Raiter
@ 2002-05-06  6:32 ` Konstantin Boldyshev
  1 sibling, 0 replies; 4+ messages in thread
From: Konstantin Boldyshev @ 2002-05-06  6:32 UTC (permalink / raw)
  To: linux-assembly

On Fri, 3 May 2002, Allan Wooley wrote:

> section .text
>     global _start
>
> path    db '/root',0
>
> _start:
>
>     mov ebx, path
>     mov eax,12
>     int 80h
>
>     mov eax, 1
>     int 80h        ;; int 0x80
>
> Although I have gotten system calls 1, 3-6 & 11 to work fine in
> assembly
> programs, I can not get the change-working-directory call to work.

Make sure you have needed permissions. Which error do you get?

-- 
Regards,
Konstantin


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-06  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-03 19:54 chdir command Allan Wooley
2002-05-03 21:31 ` Brian Raiter
2002-05-06  6:32 ` Konstantin Boldyshev
  -- strict thread matches above, loose matches on Subject: below --
2002-05-03 19:55 Allan Wooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).