// Copyright 2020 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34use crate::descriptor::SafeDescriptor;56const KCMP_FILE: u32 = 0;78impl PartialEq for SafeDescriptor {9fn eq(&self, other: &Self) -> bool {10// If RawFd numbers match then we can return early without calling kcmp11if self.descriptor == other.descriptor {12return true;13}1415// SAFETY:16// safe because we only use the return value and libc says it's always successful17let pid = unsafe { libc::getpid() };18// SAFETY:19// safe because we are passing everything by value and checking the return value20let ret = unsafe {21libc::syscall(22libc::SYS_kcmp,23pid,24pid,25KCMP_FILE,26self.descriptor,27other.descriptor,28)29};3031ret == 032}33}343536