diff options
author | Jason Stubbs <jstubbs@gentoo.org> | 2005-08-28 08:37:44 +0000 |
---|---|---|
committer | Jason Stubbs <jstubbs@gentoo.org> | 2005-08-28 08:37:44 +0000 |
commit | d9fc4acc572c6647a4f27b838d35d27d805d190e (patch) | |
tree | 262a8de35d8c7567312757da5f1f66efdc8cece5 /src/sandbox/problems/sandbox_dev_fd_foo.c | |
download | portage-d9fc4acc572c6647a4f27b838d35d27d805d190e.tar.gz portage-d9fc4acc572c6647a4f27b838d35d27d805d190e.tar.bz2 portage-d9fc4acc572c6647a4f27b838d35d27d805d190e.zip |
Migration (without history) of the current stable line to subversion.
svn path=/main/branches/2.0/; revision=1941
Diffstat (limited to 'src/sandbox/problems/sandbox_dev_fd_foo.c')
-rw-r--r-- | src/sandbox/problems/sandbox_dev_fd_foo.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sandbox/problems/sandbox_dev_fd_foo.c b/src/sandbox/problems/sandbox_dev_fd_foo.c new file mode 100644 index 000000000..c36a095c2 --- /dev/null +++ b/src/sandbox/problems/sandbox_dev_fd_foo.c @@ -0,0 +1,42 @@ +/* $Header: /var/cvsroot/gentoo-src/portage/src/sandbox/problems/Attic/sandbox_dev_fd_foo.c,v 1.2 2003/03/22 14:24:38 carpaski Exp $ */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +void cleanup_1(void) +{ + puts("Unlinking file..."); + unlink("/tmp/_sandbox_test.file"); +} + +int main(void) +{ + struct stat s1, s2; + FILE *fp1, *fp2; + char *file = "/tmp/_sandbox_test.file"; + char devfd[32]; + + printf("Opening file...\n"); + if (!(fp1 = fopen(file, "w"))) + exit(1); + atexit(cleanup_1); + printf("fstat'ing file...\n"); + if (fstat(fileno(fp1), &s1) < 0) + exit(2); + sprintf(devfd, "/dev/fd/%d", fileno(fp1)); + printf("fopening %s...\n", devfd); + if (!(fp2 = fopen(devfd, "w"))) + exit(3); + printf("fstat'ing %s...\n", devfd); + if (fstat(fileno(fp2), &s2) < 0) + exit(4); + printf("Checking %ld == %ld and %ld == %ld...\n", + (long int) s1.st_dev, (long int) s2.st_dev, s1.st_ino, s2.st_ino); + if (s1.st_dev != s2.st_dev || s1.st_ino != s2.st_ino) + exit(5); + printf("Success!\n"); + return(0); +} |