// File: merelin[P]mediasmartserverd/src/device_monitor.cpp
// Function: DeviceMonitor::enumDevices_()
void DeviceMonitor::enumDevices_( ) {
	assert( dev_context_ );
	
	// create udev enumeration interface
	std::tr1::shared_ptr< udev_enumerate > dev_enum( udev_enumerate_new( dev_context_ ), &udev_enumerate_unref );
	
	// only interested in scsi_device's
	udev_enumerate_add_match_subsystem( dev_enum.get(), "block" );
	udev_enumerate_add_match_property( dev_enum.get(), "ID_BUS", "ata" );
	udev_enumerate_scan_devices( dev_enum.get() ); // start
	
	//- enumerate list
	udev_list_entry* list_entry = udev_enumerate_get_list_entry( dev_enum.get() );
	for ( ; list_entry; list_entry = udev_list_entry_get_next( list_entry ) ) {
		// retrieve device
		std::tr1::shared_ptr< udev_device > device(
			udev_device_new_from_syspath(
				udev_enumerate_get_udev( dev_enum.get() ),
				udev_list_entry_get_name( list_entry )
			), &udev_device_unref
		);
                if ( !device ) continue;

		if (!acceptDevice_(device.get())) continue;

		int led_idx = scsiHostIndex_(device.get());
		if (led_idx < 0) continue;
		if (debug || verbose > 1) std::cout << " device: " << udev_device_get_syspath(device.get()) << "\n led: " << led_idx << "\n";

		leds_idx_[num_disks_] = led_idx;

                stats_files_[num_disks_] = std::string( udev_device_get_syspath(device.get()) );
                stats_files_[num_disks_].append( "/stat" );

                // make sure it's there and we can open it
                std::ifstream stats;
                stats.open( stats_files_[num_disks_].c_str() );
                if( !stats )
                {
                    std::cout << " Couldn't open stats " << stats_files_[num_disks_] << "\n";
                    continue;
                }
                else
                    stats.close();

                ++num_disks_;

		deviceAdded_( device.get() );
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x370, %rsp            # imm = 0x370
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x280(%rbp)
cmpq $0x0, (%rax)
je 0x5ed2
jmp 0x5ef1
leaq 0xc24d(%rip), %rdi      # 0x12126
leaq 0xc1bc(%rip), %rsi      # 0x1209c
movl $0xe9, %edx
leaq 0xc247(%rip), %rcx      # 0x12133
callq 0x5250
movq -0x280(%rbp), %rax
movq (%rax), %rdi
callq 0x5630
movq %rax, %rsi
movq 0x120ae(%rip), %rdx     # 0x17fb8
leaq -0x18(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x78a0
movq -0x290(%rbp), %rdi
callq 0x78d0
movq %rax, -0x288(%rbp)
jmp 0x5f2f
movq -0x288(%rbp), %rdi
leaq 0xc219(%rip), %rsi      # 0x12156
callq 0x53a0
jmp 0x5f44
leaq -0x18(%rbp), %rdi
callq 0x78d0
movq %rax, -0x298(%rbp)
jmp 0x5f56
movq -0x298(%rbp), %rdi
leaq 0xc1f8(%rip), %rsi      # 0x1215c
leaq 0xc215(%rip), %rdx      # 0x12180
callq 0x5710
jmp 0x5f72
leaq -0x18(%rbp), %rdi
callq 0x78d0
movq %rax, -0x2a0(%rbp)
jmp 0x5f84
movq -0x2a0(%rbp), %rdi
callq 0x5220
jmp 0x5f92
leaq -0x18(%rbp), %rdi
callq 0x78d0
movq %rax, -0x2a8(%rbp)
jmp 0x5fa4
movq -0x2a8(%rbp), %rdi
callq 0x5320
movq %rax, -0x2b0(%rbp)
jmp 0x5fb9
movq -0x2b0(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x6442
leaq -0x18(%rbp), %rdi
callq 0x78d0
movq %rax, -0x2b8(%rbp)
jmp 0x5fe1
movq -0x2b8(%rbp), %rdi
callq 0x56d0
movq %rax, -0x2c0(%rbp)
jmp 0x5ff6
movq -0x30(%rbp), %rdi
callq 0x5150
movq %rax, -0x2c8(%rbp)
jmp 0x6008
movq -0x2c8(%rbp), %rsi
movq -0x2c0(%rbp), %rdi
callq 0x52c0
movq %rax, -0x2d0(%rbp)
jmp 0x6024
movq -0x2d0(%rbp), %rsi
movq 0x11f96(%rip), %rdx     # 0x17fc8
leaq -0x40(%rbp), %rdi
callq 0x77a0
jmp 0x603d
leaq -0x40(%rbp), %rdi
callq 0x78f0
movq %rax, -0x2d8(%rbp)
jmp 0x604f
movq -0x2d8(%rbp), %rax
cmpq $-0x1, %rax
jne 0x608a
movl $0x4, -0x44(%rbp)
jmp 0x63ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x6437
leaq -0x40(%rbp), %rdi
callq 0x77d0
movq %rax, -0x2e0(%rbp)
jmp 0x609c
movq -0x2e0(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x6ed0
movb %al, -0x2e1(%rbp)
jmp 0x60b7
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x60cf
jmp 0x60c3
movl $0x4, -0x44(%rbp)
jmp 0x63ff
leaq -0x40(%rbp), %rdi
callq 0x77d0
movq %rax, -0x2f0(%rbp)
jmp 0x60e1
movq -0x2f0(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x7180
movl %eax, -0x2f4(%rbp)
jmp 0x60fc
movl -0x2f4(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jge 0x6117
movl $0x4, -0x44(%rbp)
jmp 0x63ff
leaq 0x122fa(%rip), %rax     # 0x18418
cmpl $0x0, (%rax)
jne 0x6133
leaq 0x122f2(%rip), %rax     # 0x1841c
cmpl $0x1, (%rax)
jle 0x61dd
movq 0x11e76(%rip), %rdi     # 0x17fb0
leaq 0xbfd3(%rip), %rsi      # 0x12114
callq 0x5380
movq %rax, -0x300(%rbp)
jmp 0x614f
leaq -0x40(%rbp), %rdi
callq 0x77d0
movq %rax, -0x308(%rbp)
jmp 0x6161
movq -0x308(%rbp), %rdi
callq 0x5650
movq %rax, -0x310(%rbp)
jmp 0x6176
movq -0x310(%rbp), %rsi
movq -0x300(%rbp), %rdi
callq 0x5380
movq %rax, -0x318(%rbp)
jmp 0x6192
movq -0x318(%rbp), %rdi
leaq 0xbf7e(%rip), %rsi      # 0x1211e
callq 0x5380
movq %rax, -0x320(%rbp)
jmp 0x61ae
movq -0x320(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x5690
movq %rax, -0x328(%rbp)
jmp 0x61c6
movq -0x328(%rbp), %rdi
leaq 0xc5fb(%rip), %rsi      # 0x127cf
callq 0x5380
jmp 0x61db
jmp 0x61dd
movq -0x280(%rbp), %rax
movl -0x48(%rbp), %edx
movslq 0x20(%rax), %rcx
movl %edx, 0x174(%rax,%rcx,4)
leaq -0x40(%rbp), %rdi
callq 0x77d0
movq %rax, -0x330(%rbp)
jmp 0x6204
movq -0x330(%rbp), %rdi
callq 0x5650
movq %rax, -0x338(%rbp)
jmp 0x6219
leaq -0x69(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x56c0
movq -0x338(%rbp), %rsi
movq -0x340(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x7600
jmp 0x6242
movq -0x280(%rbp), %rax
movslq 0x20(%rax), %rcx
shlq $0x5, %rcx
leaq 0x28(%rax,%rcx), %rdi
leaq -0x68(%rbp), %rsi
movq %rsi, -0x348(%rbp)
callq 0x54c0
movq -0x348(%rbp), %rdi
callq 0x5230
leaq -0x69(%rbp), %rdi
callq 0x53f0
movq -0x280(%rbp), %rax
movslq 0x20(%rax), %rcx
shlq $0x5, %rcx
leaq 0x28(%rax,%rcx), %rdi
leaq 0xbecd(%rip), %rsi      # 0x12163
callq 0x5750
jmp 0x629d
leaq -0x278(%rbp), %rdi
callq 0x5450
jmp 0x62ab
movq -0x280(%rbp), %rax
movslq 0x20(%rax), %rcx
shlq $0x5, %rcx
leaq 0x28(%rax,%rcx), %rdi
callq 0x5170
movq %rax, %rsi
leaq -0x278(%rbp), %rdi
movl $0x8, %edx
callq 0x5240
jmp 0x62da
movq -0x278(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x278(%rbp,%rax), %rdi
callq 0x51a0
movb %al, -0x349(%rbp)
jmp 0x62fa
movb -0x349(%rbp), %al
testb $0x1, %al
jne 0x6309
jmp 0x63a6
movq 0x11ca0(%rip), %rdi     # 0x17fb0
leaq 0xbe52(%rip), %rsi      # 0x12169
callq 0x5380
movq %rax, -0x358(%rbp)
jmp 0x6325
movq -0x358(%rbp), %rdi
movq -0x280(%rbp), %rax
movslq 0x20(%rax), %rcx
shlq $0x5, %rcx
leaq 0x28(%rax,%rcx), %rsi
callq 0x5340
movq %rax, -0x360(%rbp)
jmp 0x634e
movq -0x360(%rbp), %rdi
leaq 0xc473(%rip), %rsi      # 0x127cf
callq 0x5380
jmp 0x6363
movl $0x4, -0x44(%rbp)
jmp 0x63f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x53f0
jmp 0x6437
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x5090
jmp 0x6437
leaq -0x278(%rbp), %rdi
callq 0x5050
jmp 0x63b4
jmp 0x63b6
movq -0x280(%rbp), %rax
movl 0x20(%rax), %ecx
incl %ecx
movl %ecx, 0x20(%rax)
leaq -0x40(%rbp), %rdi
callq 0x77d0
movq %rax, -0x368(%rbp)
jmp 0x63d7
movq -0x368(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x6f40
jmp 0x63ec
movl $0x0, -0x44(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x5090
leaq -0x40(%rbp), %rdi
callq 0x77f0
movl -0x44(%rbp), %eax
testl %eax, %eax
je 0x6413
jmp 0x6411
jmp 0x6415
jmp 0x6415
movq -0x30(%rbp), %rdi
callq 0x5130
movq %rax, -0x370(%rbp)
jmp 0x6427
movq -0x370(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x5fc4
leaq -0x40(%rbp), %rdi
callq 0x77f0
jmp 0x6454
leaq -0x18(%rbp), %rdi
callq 0x7920
addq $0x370, %rsp            # imm = 0x370
popq %rbp
retq
leaq -0x18(%rbp), %rdi
callq 0x7920
movq -0x20(%rbp), %rdi
callq 0x56b0
nopw %cs:(%rax,%rax)