// File: /workspace/github_cpp_makefile_star2_O3/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 0x4dd3
callq 0x44c0
leaq 0x28(%rsp), %rbx
movq %rax, -0x8(%rbx)
movq 0xb4cb(%rip), %rdx      # 0xffb8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5ff2
movq -0x8(%rbx), %rdi
leaq 0x6653(%rip), %rsi      # 0xb156
callq 0x42b0
movq 0x20(%rsp), %rdi
leaq 0x6648(%rip), %rsi      # 0xb15c
leaq 0x6665(%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 0xb47c(%rip), %r13      # 0xffc8
testq %r12, %r12
je 0x4db7
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 0x5f26
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x4d9f
callq 0x553a
testb %al, %al
je 0x4d9f
movq %r13, %rbx
movq 0x10(%rsp), %rsi
callq 0x588c
movl %eax, %ebp
testl %eax, %eax
movq %rbx, %r13
js 0x4d9f
leaq 0xb78c(%rip), %rax      # 0x10350
cmpl $0x0, (%rax)
jne 0x4bd9
leaq 0xb784(%rip), %rax      # 0x10354
cmpl $0x2, (%rax)
jl 0x4c77
movl $0x9, %edx
movq 0xb3cb(%rip), %rdi      # 0xffb0
leaq 0x6528(%rip), %rsi      # 0xb114
callq 0x4310
movq 0x10(%rsp), %rdi
callq 0x44e0
movq %rax, %r13
testq %rax, %rax
je 0x4c1f
movq %r13, %rdi
callq 0x4130
movq 0xb39e(%rip), %rdi      # 0xffb0
movq %r13, %rsi
movq %rax, %rdx
callq 0x4310
jmp 0x4c3d
movq 0xb38a(%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 0xb367(%rip), %rdi      # 0xffb0
leaq 0x64ce(%rip), %rsi      # 0xb11e
callq 0x4310
movq 0xb354(%rip), %rdi      # 0xffb0
movl %ebp, %esi
callq 0x4530
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6a99(%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 0x5ba8
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 0x4cd3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42c0
movslq 0x20(%r14), %rdi
shlq $0x5, %rdi
addq 0x8(%rsp), %rdi
leaq 0x647c(%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 0x4d7a
movl $0x15, %edx
movq 0xb27a(%rip), %rdi      # 0xffb0
leaq 0x642c(%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 0xb251(%rip), %rdi      # 0xffb0
callq 0x4310
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6998(%rip), %rsi      # 0xb70b
callq 0x4310
jmp 0x4d95
leaq 0x30(%rsp), %rdi
callq 0x4040
incl 0x20(%r14)
movq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x558a
leaq 0x30(%rsp), %rdi
callq 0x4060
movq %r15, %rdi
callq 0x5d10
movq %r12, %rdi
callq 0x40f0
movq %rax, %r12
jmp 0x4b4c
leaq 0x28(%rsp), %rdi
callq 0x5d10
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x634c(%rip), %rdi      # 0xb126
leaq 0x62bb(%rip), %rsi      # 0xb09c
leaq 0x634b(%rip), %rcx      # 0xb133
movl $0xe9, %edx
callq 0x4190
jmp 0x4e1c
jmp 0x4e1c
jmp 0x4e0f
jmp 0x4e0f
jmp 0x4e0f
jmp 0x4e0f
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x4060
jmp 0x4e12
jmp 0x4e1c
movq %rax, %rbx
movq %r15, %rdi
callq 0x5d10
jmp 0x4e1f
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5d10
movq %rbx, %rdi
callq 0x4550
nop