linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Raiter <breadbox@muppetlabs.com>
To: Allan Wooley <awooley@exeter.edu>
Cc: Linux Assembly <linux-assembly@vger.kernel.org>
Subject: Re: chdir command
Date: Fri, 3 May 2002 14:31:03 -0700 (PDT)	[thread overview]
Message-ID: <15571.407.735989.579814@shub.muppetlabs.com> (raw)
In-Reply-To: <3CD2EAF6.5A27E998@exeter.edu>

> 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

  reply	other threads:[~2002-05-03 21:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-03 19:54 chdir command Allan Wooley
2002-05-03 21:31 ` Brian Raiter [this message]
2002-05-06  6:32 ` Konstantin Boldyshev
  -- strict thread matches above, loose matches on Subject: below --
2002-05-03 19:55 Allan Wooley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15571.407.735989.579814@shub.muppetlabs.com \
    --to=breadbox@muppetlabs.com \
    --cc=awooley@exeter.edu \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).