// File: merelin[P]mediasmartserverd/src/device_monitor.cpp
// Function: DeviceMonitor::Init(std::tr1::shared_ptr<LedControlBase> const&)
void DeviceMonitor::Init( const LedControlPtr& leds ) {
	leds_ = leds;
	
	// get udev library context
	dev_context_ = udev_new();
	if ( !dev_context_ ) throw ErrnoException( "udev_new" );
	
	// set up udev monitor
	dev_monitor_ = udev_monitor_new_from_netlink( dev_context_, "udev" );
	if ( !dev_monitor_ ) throw ErrnoException( "udev_monitor_new_from_netlink" );
	
	// only interested in scsi devices
	if ( udev_monitor_filter_add_match_subsystem_devtype( dev_monitor_, "scsi", "scsi_device" ) ) {
		throw ErrnoException( "udev_monitor_filter_add_match_subsystem_devtype" );
	}
	
	// enumerate existing devices
	enumDevices_( );
	
	// then start monitoring
	if ( udev_monitor_enable_receiving( dev_monitor_ ) ) {
		throw ErrnoException( "udev_monitor_enable_receiving" );
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x10, %rdi
callq 0x75d0
callq 0x54e0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, (%rax)
jne 0x5bb6
movb $0x1, -0x45(%rbp)
movl $0x10, %edi
callq 0x51b0
movq %rax, -0xd8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x56c0
movq -0xd0(%rbp), %rdx
leaq 0xc4da(%rip), %rsi      # 0x12004
leaq -0x30(%rbp), %rdi
callq 0x7600
jmp 0x5b35
callq 0x5030
movq -0xd8(%rbp), %rdi
movl (%rax), %edx
leaq -0x30(%rbp), %rsi
callq 0x76b0
jmp 0x5b4e
movq -0xd8(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x11aa0(%rip), %rsi     # 0x17600
leaq 0x1c19(%rip), %rdx      # 0x7780
callq 0x5680
jmp 0x5eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5b94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5230
leaq -0x31(%rbp), %rdi
callq 0x53f0
testb $0x1, -0x45(%rbp)
jne 0x5ba5
jmp 0x5bb1
movq -0xd8(%rbp), %rdi
callq 0x52a0
jmp 0x5ea1
movq -0xc8(%rbp), %rax
movq (%rax), %rdi
leaq 0xc446(%rip), %rsi      # 0x1200d
callq 0x50c0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x8(%rax)
jne 0x5ca4
movb $0x1, -0x6a(%rbp)
movl $0x10, %edi
callq 0x51b0
movq %rax, -0xe8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x56c0
movq -0xe0(%rbp), %rdx
leaq 0xc3fa(%rip), %rsi      # 0x12012
leaq -0x68(%rbp), %rdi
callq 0x7600
jmp 0x5c23
callq 0x5030
movq -0xe8(%rbp), %rdi
movl (%rax), %edx
leaq -0x68(%rbp), %rsi
callq 0x76b0
jmp 0x5c3c
movq -0xe8(%rbp), %rdi
movb $0x0, -0x6a(%rbp)
leaq 0x119b2(%rip), %rsi     # 0x17600
leaq 0x1b2b(%rip), %rdx      # 0x7780
callq 0x5680
jmp 0x5eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5c82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5230
leaq -0x69(%rbp), %rdi
callq 0x53f0
testb $0x1, -0x6a(%rbp)
jne 0x5c93
jmp 0x5c9f
movq -0xe8(%rbp), %rdi
callq 0x52a0
jmp 0x5ea1
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xc37a(%rip), %rsi      # 0x12030
leaq 0xc378(%rip), %rdx      # 0x12035
callq 0x5600
cmpl $0x0, %eax
je 0x5da2
movb $0x1, -0x92(%rbp)
movl $0x10, %edi
callq 0x51b0
movq %rax, -0xf8(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x56c0
movq -0xf0(%rbp), %rdx
leaq 0xc33d(%rip), %rsi      # 0x12041
leaq -0x90(%rbp), %rdi
callq 0x7600
jmp 0x5d12
callq 0x5030
movq -0xf8(%rbp), %rdi
movl (%rax), %edx
leaq -0x90(%rbp), %rsi
callq 0x76b0
jmp 0x5d2e
movq -0xf8(%rbp), %rdi
movb $0x0, -0x92(%rbp)
leaq 0x118bd(%rip), %rsi     # 0x17600
leaq 0x1a36(%rip), %rdx      # 0x7780
callq 0x5680
jmp 0x5eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5d7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5230
leaq -0x91(%rbp), %rdi
callq 0x53f0
testb $0x1, -0x92(%rbp)
jne 0x5d91
jmp 0x5d9d
movq -0xf8(%rbp), %rdi
callq 0x52a0
jmp 0x5ea1
movq -0xc8(%rbp), %rdi
callq 0x5eb0
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5270
cmpl $0x0, %eax
je 0x5e98
movb $0x1, -0xba(%rbp)
movl $0x10, %edi
callq 0x51b0
movq %rax, -0x108(%rbp)
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x56c0
movq -0x100(%rbp), %rdx
leaq 0xc271(%rip), %rsi      # 0x12071
leaq -0xb8(%rbp), %rdi
callq 0x7600
jmp 0x5e0e
callq 0x5030
movq -0x108(%rbp), %rdi
movl (%rax), %edx
leaq -0xb8(%rbp), %rsi
callq 0x76b0
jmp 0x5e2a
movq -0x108(%rbp), %rdi
movb $0x0, -0xba(%rbp)
leaq 0x117c1(%rip), %rsi     # 0x17600
leaq 0x193a(%rip), %rdx      # 0x7780
callq 0x5680
jmp 0x5eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5e73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x5230
leaq -0xb9(%rbp), %rdi
callq 0x53f0
testb $0x1, -0xba(%rbp)
jne 0x5e8a
jmp 0x5e96
movq -0x108(%rbp), %rdi
callq 0x52a0
jmp 0x5ea1
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x56b0
nopw (%rax,%rax)