PROBLEM: Removing cwd of some process(if it's empty)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[1.] Removing cwd of some process(if it's empty)

[2.] Syscalls rmdir() and rename() can remove directory that is the current
working directory of some process. If the directory isn't empty,
variable errno is set in ENOTEMPTY. If it's root directory of some process
or mountpoint errno is set in EBUSY. But if it's cwd and empty, syscalls
specified above end with success. After removing cwd process still uses it as
cwd. But already the directory hasn't entries (even . and ..),
link's count is 0 and it's size is 0. Thus process can't create files
in this cwd (or uses it for other purposes).

If possible, send short message with opinion about this problem or other notes
to [email protected].

[3.] Syscalls rmdir(), rename().

[4.] Kernel version (from /proc/version):
Linux version 2.4.22-1.2154.nptl.asp ([email protected]) (gcc version 3.3.2 20031022 (ASPLinux 3.3.2-1)) #1 Wed Jan 14 21:21:25 MSK 2004

[5.]

[6.]
/* The first example program */

#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>

#include <stdio.h>
#include <stdlib.h>

/* Program actions:
* creating directory dir in cwd
* changing cwd(new cwd - dir)
* removing dir, if it was failure exit with errno value
* output some information (link's count, dir size) about cwd (it's dir)
* attempt to create some file in cwd
* returning errno value */

int main()
{
    struct stat cwd_stat;
    int fd, ret;
    
    mkdir("dir", 0755);
    chdir("dir");
    
    ret = rmdir("../dir");
    if(ret == -1)
	exit(errno);
    
    stat(".", &cwd_stat);
    printf("\tStat info of the cwd\n");
    printf("link count\t\t\t\t%u\n", cwd_stat.st_nlink);
    printf("cwd's size\t\t\t\t%u\n", (unsigned)cwd_stat.st_size);
    
    fd = creat("file", 0755);

    exit(errno);
}

/* The second example program */

#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>

#include <stdio.h>
#include <stdlib.h>

/*
Program actions:
* creating two directories (dir1, dir2) in cwd
* changing cwd(new cwd - dir2)
* renaming dir1 to dir2, if it was failure exit with errno value
* output some information (link's count, dir size) about cwd (it's dir2)
* attempt to create some file in cwd
* remove tmp dir and return errno value
*/

int main()
{
    struct stat cwd_stat;
    int fd, ret;
    
    mkdir("dir1", 0755);
    mkdir("dir2", 0755);
    chdir("dir2");
    
    ret = rename("../dir1", "../dir2");
    if(ret == -1)
	exit(errno);
    
    stat(".", &cwd_stat);
    printf("\tStat info of the cwd\n");
    printf("link count\t\t\t\t%u\n", cwd_stat.st_nlink);
    printf("cwd's size\t\t\t\t%u\n", (unsigned)cwd_stat.st_size);
    
    fd = creat("file", 0755);

    rmdir("../dir2");
    exit(errno);
}

# Shell script

#!/bin/sh

# Script actions:
# * creating directory DIR in cwd
# * changing cwd(new cwd - DIR)
# * starting new shell as child process asynchronously
#   * sleeping 1 sec
#   * output stat information about cwd (it's DIR)
#   * attempt to create some file in cwd
# * removing DIR that is child shell's cwd
# * sleeping 2 sec that is sufficient for child shell's finish

DIR="dir"

mkdir $DIR
cd $DIR

( sleep 1 ; stat . ; touch file ) &

cd ..
rmdir $DIR
sleep 2


[7.] Environment
[7.1.] Software:
Linux localhost.localdomain 2.4.22-1.2154.nptl.asp #1 Wed Jan 14 21:21:25 MSK 2004 i686 athlon i386 GNU/Linux
 
Gnu C                  3.3.2
Gnu make               3.79.1
util-linux             2.11y
mount                  2.11y
module-init-tools      writing
e2fsprogs              1.34
reiserfsprogs          3.6.8
xfsprogs               2.6.0
quota-tools            3.08.
PPP                    2.4.2b3
nfs-utils              1.0.6
Linux C Library        2.3.2
Dynamic linker (ldd)   2.3.2
Procps                 2.0.17
Net-tools              1.60
Kbd                    1.08
Sh-utils               5.0
Modules Loaded         via82cxxx_audio ac97_codec uart401 sound soundcore parport_pc lp parport autofs rfcomm l2cap bluez floppy sg scsi_mod ntfs nls_koi8-r nls_cp866 vfat fat keybdev mousedev hid input ehci-hcd usb-uhci usbcore ext3 jbd

[7.2.] Processor information (from /proc/cpuinfo):
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 12
model name	: AMD Athlon(tm) 64 Processor 2800+
stepping	: 0
cpu MHz		: 1809.104
cache size	: 512 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow
bogomips	: 3604.48

[7.3.] Module information (from /proc/modules):
via82cxxx_audio        23456   0
ac97_codec             16500   0 [via82cxxx_audio]
uart401                 7972   0 [via82cxxx_audio]
sound                  71400   0 [via82cxxx_audio uart401]
soundcore               6500   4 [via82cxxx_audio sound]
parport_pc             18372   1 (autoclean)
lp                      8324   0 (autoclean)
parport                36744   1 (autoclean) [parport_pc lp]
autofs                 11828   1 (autoclean)
rfcomm                 34912   0 (autoclean)
l2cap                  18512   2 (autoclean) [rfcomm]
bluez                  36548   1 (autoclean) [rfcomm l2cap]
floppy                 55900   0 (autoclean)
sg                     34428   0 (autoclean) (unused)
scsi_mod              106676   1 (autoclean) [sg]
ntfs                   81708   1 (autoclean)
nls_koi8-r              4636   3 (autoclean)
nls_cp866               4636   2 (autoclean)
vfat                   12268   2 (autoclean)
fat                    37400   0 (autoclean) [vfat]
keybdev                 2628   0 (unused)
mousedev                5140   1
hid                    23268   0 (unused)
input                   5792   0 [keybdev mousedev hid]
ehci-hcd               19500   0 (unused)
usb-uhci               25744   0 (unused)
usbcore                77644   1 [hid ehci-hcd usb-uhci]
ext3                   65040   3
jbd                    41248   3 [ext3]

[7.4.] Loaded driver and hardware information (/proc/ioports, /proc/iomem)
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc
0080-008f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : ide1
01f0-01f7 : ide0
02f8-02ff : serial(auto)
0376-0376 : ide1
0378-037a : parport0
03c0-03df : vga+
03f6-03f6 : ide0
03f8-03ff : serial(auto)
0cf8-0cff : PCI conf1
d000-d00f : VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE
  d000-d007 : ide0
  d008-d00f : ide1
d400-d41f : VIA Technologies, Inc. USB
  d400-d41f : usb-uhci
d800-d81f : VIA Technologies, Inc. USB (#2)
  d800-d81f : usb-uhci
dc00-dc1f : VIA Technologies, Inc. USB (#3)
  dc00-dc1f : usb-uhci
e000-e01f : VIA Technologies, Inc. USB (#4)
  e000-e01f : usb-uhci
e400-e4ff : VIA Technologies, Inc. VT8233/A/8235 AC97 Audio Controller
  e400-e4ff : via82cxxx_audio

00000000-0009f7ff : System RAM
0009f800-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-1ffeffff : System RAM
  00100000-00267193 : Kernel code
  00267194-003798a3 : Kernel data
1fff0000-1fff2fff : ACPI Non-volatile Storage
1fff3000-1fffffff : ACPI Tables
d0000000-d7ffffff : PCI device 1106:3188 (VIA Technologies, Inc.)
d8000000-dfffffff : PCI Bus #01
  d8000000-dfffffff : PCI device 10de:0321 (nVidia Corporation)
e0000000-e1ffffff : PCI Bus #01
  e0000000-e0ffffff : PCI device 10de:0321 (nVidia Corporation)
e2000000-e20000ff : VIA Technologies, Inc. USB 2.0
  e2000000-e20000ff : ehci_hcd
fec00000-fec00fff : reserved
fee00000-fee00fff : reserved
ffff0000-ffffffff : reserved

[7.5.] PCI information ('lspci -vvv' as root)
00:00.0 Host bridge: VIA Technologies, Inc.: Unknown device 3188 (rev 01)
	Subsystem: VIA Technologies, Inc.: Unknown device 3188
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ >SERR- <PERR-
	Latency: 8
	Region 0: Memory at d0000000 (32-bit, prefetchable) [size=128M]
	Capabilities: [80] AGP version 3.0
		Status: RQ=31 SBA+ 64bit- FW+ Rate=x1,x2
		Command: RQ=0 SBA- AGP- 64bit- FW- Rate=<none>
	Capabilities: [c0] #08 [0060]
	Capabilities: [68] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [58] #08 [8001]

00:01.0 PCI bridge: VIA Technologies, Inc.: Unknown device b188 (prog-if 00 [Normal decode])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-
	Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 0
	Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
	I/O behind bridge: 0000f000-00000fff
	Memory behind bridge: e0000000-e1ffffff
	Prefetchable memory behind bridge: d8000000-dfffffff
	BridgeCtl: Parity- SERR+ NoISA+ VGA+ MAbort- >Reset- FastB2B-
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:0f.0 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT8233/A/C/VT8235 PIPC Bus Master IDE (rev 06) (prog-if 8a [Master SecP PriP])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32
	Interrupt: pin A routed to IRQ 0
	Region 4: I/O ports at d000 [size=16]
	Capabilities: [c0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:10.0 USB Controller: VIA Technologies, Inc. USB (rev 81) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32, cache line size 08
	Interrupt: pin A routed to IRQ 11
	Region 4: I/O ports at d400 [size=32]
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:10.1 USB Controller: VIA Technologies, Inc. USB (rev 81) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32, cache line size 08
	Interrupt: pin A routed to IRQ 11
	Region 4: I/O ports at d800 [size=32]
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:10.2 USB Controller: VIA Technologies, Inc. USB (rev 81) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32, cache line size 08
	Interrupt: pin B routed to IRQ 5
	Region 4: I/O ports at dc00 [size=32]
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:10.3 USB Controller: VIA Technologies, Inc. USB (rev 81) (prog-if 00 [UHCI])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32, cache line size 08
	Interrupt: pin B routed to IRQ 5
	Region 4: I/O ports at e000 [size=32]
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86) (prog-if 20 [EHCI])
	Subsystem: Giga-byte Technology GA-7VAX Mainboard
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32, cache line size 10
	Interrupt: pin C routed to IRQ 10
	Region 0: Memory at e2000000 (32-bit, non-prefetchable) [size=256]
	Capabilities: [80] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:11.0 ISA bridge: VIA Technologies, Inc.: Unknown device 3227
	Subsystem: Giga-byte Technology: Unknown device 5001
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping+ SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 0
	Capabilities: [c0] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235 AC97 Audio Controller (rev 60)
	Subsystem: Giga-byte Technology GA-7VAX Onboard Audio (Realtek ALC650)
	Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Interrupt: pin C routed to IRQ 10
	Region 0: I/O ports at e400 [size=256]
	Capabilities: [c0] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-

00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 NorthBridge
	Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Capabilities: [80] #08 [2101]

00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 NorthBridge
	Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR-

00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 NorthBridge
	Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR-

00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 NorthBridge
	Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR-

01:00.0 VGA compatible controller: nVidia Corporation NV34 [GeForce FX 5200 Ultra] (rev a1) (prog-if 00 [VGA])
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap+ 66Mhz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 32 (1250ns min, 250ns max)
	Interrupt: pin A routed to IRQ 11
	Region 0: Memory at e0000000 (32-bit, non-prefetchable) [size=16M]
	Region 1: Memory at d8000000 (32-bit, prefetchable) [size=128M]
	Expansion ROM at <unassigned> [disabled] [size=128K]
	Capabilities: [60] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [44] AGP version 3.0
		Status: RQ=31 SBA+ 64bit- FW+ Rate=x1,x2
		Command: RQ=0 SBA- AGP- 64bit- FW- Rate=<none>


[7.6.] SCSI information (from /proc/scsi/scsi)
Attached devices: none

[7.7.]
Proc information of shell process:
total 0
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 binfmt
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 cmdline
lrwxrwxrwx    1 feanor   users           0 íÁÒ 31 22:41 cwd -> /tmp/dir (deleted)
-r--------    1 feanor   users           0 íÁÒ 31 22:41 environ
lrwxrwxrwx    1 feanor   users           0 íÁÒ 31 22:41 exe -> /bin/bash
dr-x------    2 feanor   users           0 íÁÒ 31 22:41 fd
-r--------    1 feanor   users           0 íÁÒ 31 22:41 maps
-rw-------    1 feanor   users           0 íÁÒ 31 22:41 mem
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 mounts
lrwxrwxrwx    1 feanor   users           0 íÁÒ 31 22:41 root -> /
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 stat
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 statm
-r--r--r--    1 feanor   users           0 íÁÒ 31 22:41 status

cwd was deleted by following commands: cd /tmp/dir; rmdir ../dir

[X.]
    The first program output(from [6.] point - rmdir):
        Stat info of the cwd
link count                              0
cwd's size                              0

	strace output:
execve("./rmdir", ["./rmdir"], [/* 21 vars */]) = 0
uname({sys="Linux", node="localhost.localdomain", ...}) = 0
brk(0)                                  = 0x9deb000
fcntl64(0, F_GETFD)                     = 0
fcntl64(1, F_GETFD)                     = 0
fcntl64(2, F_GETFD)                     = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xbf542000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 6
fstat64(6, {st_mode=S_IFREG|0644, st_size=63522, ...}) = 0
old_mmap(NULL, 63522, PROT_READ, MAP_PRIVATE, 6, 0) = 0xbf532000
close(6)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 6
read(6, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0D]\1\000"..., 512) = 512
fstat64(6, {st_mode=S_IFREG|0755, st_size=1466212, ...}) = 0
old_mmap(NULL, 1194276, PROT_READ|PROT_EXEC, MAP_PRIVATE, 6, 0) = 0xc45000
old_mmap(0xd63000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 6, 0x11e000) = 0xd63000
old_mmap(0xd66000, 10532, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xd66000
close(6)                                = 0
munmap(0xbf532000, 63522)               = 0
mkdir("dir", 0755)                      = 0
chdir("dir")                            = 0
rmdir("../dir")                         = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xbf541000
write(1, "\tStat info of the cwd\n", 22) = 22
write(1, "link count\t\t\t\t0\n", 16)   = 16
write(1, "cwd\'s size\t\t\t\t0\n", 16)  = 16
creat("file", 0755)                     = -1 ENOENT (No such file or directory)
munmap(0xbf541000, 4096)                = 0
exit_group(2)                           = ?

    The second program output(from [6.] point - rename):
        Stat info of the cwd
link count                              0
cwd's size                              1024

	strace output:
execve("./rename", ["./rename"], [/* 21 vars */]) = 0
uname({sys="Linux", node="localhost.localdomain", ...}) = 0
brk(0)                                  = 0x9833000
fcntl64(0, F_GETFD)                     = 0
fcntl64(1, F_GETFD)                     = 0
fcntl64(2, F_GETFD)                     = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xbf55b000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 6
fstat64(6, {st_mode=S_IFREG|0644, st_size=63522, ...}) = 0
old_mmap(NULL, 63522, PROT_READ, MAP_PRIVATE, 6, 0) = 0xbf54b000
close(6)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 6
read(6, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0D]\1\000"..., 512) = 512
fstat64(6, {st_mode=S_IFREG|0755, st_size=1466212, ...}) = 0
old_mmap(NULL, 1194276, PROT_READ|PROT_EXEC, MAP_PRIVATE, 6, 0) = 0x298000
old_mmap(0x3b6000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 6, 0x11e000) = 0x3b6000
old_mmap(0x3b9000, 10532, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b9000
close(6)                                = 0
munmap(0xbf54b000, 63522)               = 0
mkdir("dir1", 0755)                     = 0
mkdir("dir2", 0755)                     = 0
chdir("dir2")                           = 0
rename("../dir1", "../dir2")            = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xbf55a000
write(1, "\tStat info of the cwd\n", 22) = 22
write(1, "link count\t\t\t\t0\n", 16)   = 16
write(1, "cwd\'s size\t\t\t\t1024\n", 19) = 19
creat("file", 0755)                     = -1 ENOENT (No such file or directory)
rmdir("../dir2")                        = 0
munmap(0xbf55a000, 4096)                = 0
exit_group(2)                           = ?

	Script output (from [6.] point):
  File: `.'
  Size: 0               Blocks: 2          IO Block: 4096   directory
Device: 306h/774d       Inode: 32709       Links: 0
Access: (0755/drwxr-xr-x)  Uid: (  502/  feanor)   Gid: (  501/   users)
Access: 2005-03-31 22:37:08.000000000 +0500
Modify: 2005-03-31 22:37:08.000000000 +0500
Change: 2005-03-31 22:37:08.000000000 +0500

touch: cannot touch `file': No such file or directory


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux