// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4ce1
callq 0x44f0
movq 0xb51c(%rip), %rdx      # 0xffb8
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5a28
movq (%r14), %rdi
leaq 0x56a0(%rip), %rsi      # 0xa156
callq 0x42f0
movq 0x20(%rsp), %rdi
leaq 0x5695(%rip), %rsi      # 0xa15c
leaq 0x56b2(%rip), %rdx      # 0xa180
callq 0x45a0
movq 0x20(%rsp), %rdi
callq 0x41b0
movq 0x20(%rsp), %rdi
callq 0x4270
movq %rax, %r15
leaq 0x28(%rbx), %r13
leaq 0x30(%rsp), %rbp
testq %r15, %r15
je 0x4cc5
movq 0x20(%rsp), %rdi
callq 0x4560
movq %rax, %r14
movq %r15, %rdi
callq 0x4120
movq %r14, %rdi
movq %rax, %rsi
callq 0x4240
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq 0xb49d(%rip), %rdx      # 0xffc8
callq 0x5946
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x4cab
callq 0x5278
testb %al, %al
je 0x4cab
movq 0x10(%rsp), %rsi
callq 0x5476
movl %eax, %r14d
testl %eax, %eax
js 0x4cab
leaq 0xb7f9(%rip), %rax      # 0x10360
cmpl $0x0, (%rax)
jne 0x4b78
leaq 0xb7f1(%rip), %rax      # 0x10364
cmpl $0x2, (%rax)
jl 0x4bcc
movq 0xb431(%rip), %rdi      # 0xffb0
leaq 0x558e(%rip), %rsi      # 0xa114
callq 0x42d0
movq %rax, %r12
movq 0x10(%rsp), %rdi
callq 0x4510
movq %r12, %rdi
movq %rax, %rsi
callq 0x42d0
movq %rax, %rdi
leaq 0x5571(%rip), %rsi      # 0xa11e
callq 0x42d0
movq %rax, %rdi
movl %r14d, %esi
callq 0x4540
movq %rax, %rdi
leaq 0x5b2c(%rip), %rsi      # 0xa6f3
callq 0x42d0
movslq 0x20(%rbx), %rax
movl %r14d, 0x174(%rbx,%rax,4)
movq 0x10(%rsp), %rdi
callq 0x4510
movq %rbp, %rdi
movq %rax, %rsi
leaq 0xf(%rsp), %rdx
callq 0x5694
movslq 0x20(%rbx), %rdi
shlq $0x5, %rdi
addq %r13, %rdi
movq %rbp, %rsi
callq 0x43b0
movq %rbp, %rdi
callq 0x4150
movslq 0x20(%rbx), %rdi
shlq $0x5, %rdi
addq %r13, %rdi
leaq 0x5544(%rip), %rsi      # 0xa163
callq 0x45e0
movq %rbp, %rdi
callq 0x4350
movslq 0x20(%rbx), %rax
shlq $0x5, %rax
movq (%r13,%rax), %rsi
movq %rbp, %rdi
pushq $0x8
popq %rdx
callq 0x41c0
movq 0x30(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x50(%rsp,%rax)
je 0x4c8b
movq 0xb355(%rip), %rdi      # 0xffb0
leaq 0x5507(%rip), %rsi      # 0xa169
callq 0x42d0
movslq 0x20(%rbx), %rsi
shlq $0x5, %rsi
addq %r13, %rsi
movq %rax, %rdi
callq 0x4290
movq %rax, %rdi
leaq 0x5a6f(%rip), %rsi      # 0xa6f3
callq 0x42d0
jmp 0x4ca3
movq %rbp, %rdi
callq 0x4040
incl 0x20(%rbx)
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x52c8
movq %rbp, %rdi
callq 0x4070
leaq 0x18(%rsp), %rdi
callq 0x5758
movq %r15, %rdi
callq 0x4100
movq %rax, %r15
jmp 0x4af3
leaq 0x28(%rsp), %rdi
callq 0x5758
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x543e(%rip), %rdi      # 0xa126
leaq 0x53ad(%rip), %rsi      # 0xa09c
leaq 0x543d(%rip), %rcx      # 0xa133
movl $0xe9, %edx
callq 0x41d0
jmp 0x4d2c
jmp 0x4d2c
jmp 0x4d1d
jmp 0x4d1d
jmp 0x4d1d
jmp 0x4d1d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4070
jmp 0x4d20
jmp 0x4d2c
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5758
jmp 0x4d2f
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5758
movq %rbx, %rdi
callq 0x4550
nop