// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4dd7
callq 0x44c0
leaq 0x28(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq 0xb4c7(%rip), %rdx      # 0xffb8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5fe4
movq -0x8(%rbx), %rdi
leaq 0x664f(%rip), %rsi      # 0xb156
callq 0x42b0
movq 0x20(%rsp), %rdi
leaq 0x6644(%rip), %rsi      # 0xb15c
leaq 0x6661(%rip), %rdx      # 0xb180
callq 0x45a0
movq 0x20(%rsp), %rdi
callq 0x4170
movq 0x20(%rsp), %rdi
callq 0x4230
movq %rax, %r12
leaq 0x18(%rsp), %r15
leaq 0x28(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0xb478(%rip), %r13      # 0xffc8
testq %r12, %r12
je 0x4dbb
movq 0x20(%rsp), %rdi
callq 0x4560
movq %rax, %rbp
movq %r12, %rdi
callq 0x4110
movq %rbp, %rdi
movq %rax, %rsi
callq 0x4200
movq %rax, 0x10(%rsp)
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x5f18
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x4da3
callq 0x553c
testb %al, %al
je 0x4da3
movq %r13, %rbx
movq 0x10(%rsp), %rsi
callq 0x588e
movl %eax, %ebp
testl %eax, %eax
movq %rbx, %r13
js 0x4da3
leaq 0xb788(%rip), %rax      # 0x10350
cmpl $0x0, (%rax)
jne 0x4bdd
leaq 0xb780(%rip), %rax      # 0x10354
cmpl $0x2, (%rax)
jl 0x4c7b
movl $0x9, %edx
movq 0xb3c7(%rip), %rdi      # 0xffb0
leaq 0x6524(%rip), %rsi      # 0xb114
callq 0x4310
movq 0x10(%rsp), %rdi
callq 0x44e0
movq %rax, %r13
testq %rax, %rax
je 0x4c23
movq %r13, %rdi
callq 0x4130
movq 0xb39a(%rip), %rdi      # 0xffb0
movq %r13, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x4c41
movq 0xb386(%rip), %rcx      # 0xffb0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x4510
movl $0x7, %edx
movq 0xb363(%rip), %rdi      # 0xffb0
leaq 0x64ca(%rip), %rsi      # 0xb11e
callq 0x4310
movq 0xb350(%rip), %rdi      # 0xffb0
movl %ebp, %esi
callq 0x4530
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6a95(%rip), %rsi      # 0xb70b
callq 0x4310
movslq 0x20(%r14), %rax
movl %ebp, 0x174(%r14,%rax,4)
movq 0x10(%rsp), %rdi
callq 0x44e0
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
leaq 0x7(%rsp), %rdx
callq 0x5baa
movslq 0x20(%r14), %rdi
shlq $0x5, %rdi
addq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x4370
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4cd7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42c0
movslq 0x20(%r14), %rdi
shlq $0x5, %rdi
addq 0x8(%rsp), %rdi
leaq 0x6478(%rip), %rsi      # 0xb163
callq 0x45f0
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x4300
movslq 0x20(%r14), %rax
shlq $0x5, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax), %rsi
movq %r13, %rdi
movl $0x8, %edx
callq 0x4180
movq %rbx, %r13
movq 0x30(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x50(%rsp,%rax)
je 0x4d7e
movl $0x15, %edx
movq 0xb276(%rip), %rdi      # 0xffb0
leaq 0x6428(%rip), %rsi      # 0xb169
callq 0x4310
movslq 0x20(%r14), %rax
shlq $0x5, %rax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0xb24d(%rip), %rdi      # 0xffb0
callq 0x4310
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6994(%rip), %rsi      # 0xb70b
callq 0x4310
jmp 0x4d99
leaq 0x30(%rsp), %rdi
callq 0x4040
incl 0x20(%r14)
movq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x558c
leaq 0x30(%rsp), %rdi
callq 0x4060
movq %r15, %rdi
callq 0x5d12
movq %r12, %rdi
callq 0x40f0
movq %rax, %r12
jmp 0x4b50
leaq 0x28(%rsp), %rdi
callq 0x5d12
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6348(%rip), %rdi      # 0xb126
leaq 0x62b7(%rip), %rsi      # 0xb09c
leaq 0x6347(%rip), %rcx      # 0xb133
movl $0xe9, %edx
callq 0x4190
jmp 0x4e20
jmp 0x4e20
jmp 0x4e13
jmp 0x4e13
jmp 0x4e13
jmp 0x4e13
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4060
jmp 0x4e16
jmp 0x4e20
movq %rax, %rbx
movq %r15, %rdi
callq 0x5d12
jmp 0x4e23
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5d12
movq %rbx, %rdi
callq 0x4550
nop