| 1 | /* Compare two open file descriptors to see if they refer to the same file.
|
|---|
| 2 | Copyright (C) 1991 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of the libiberty library.
|
|---|
| 5 | Libiberty is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Library General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | Libiberty is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Library General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Library General Public
|
|---|
| 16 | License along with libiberty; see the file COPYING.LIB. If
|
|---|
| 17 | not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|---|
| 18 | Boston, MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | /*
|
|---|
| 22 |
|
|---|
| 23 | @deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})
|
|---|
| 24 |
|
|---|
| 25 | Check to see if two open file descriptors refer to the same file.
|
|---|
| 26 | This is useful, for example, when we have an open file descriptor for
|
|---|
| 27 | an unnamed file, and the name of a file that we believe to correspond
|
|---|
| 28 | to that fd. This can happen when we are exec'd with an already open
|
|---|
| 29 | file (@code{stdout} for example) or from the SVR4 @file{/proc} calls
|
|---|
| 30 | that return open file descriptors for mapped address spaces. All we
|
|---|
| 31 | have to do is open the file by name and check the two file descriptors
|
|---|
| 32 | for a match, which is done by comparing major and minor device numbers
|
|---|
| 33 | and inode numbers.
|
|---|
| 34 |
|
|---|
| 35 | @end deftypefn
|
|---|
|
|---|