Sponsored Content
Full Discussion: mmap() on 64 bit m/c
Operating Systems Solaris mmap() on 64 bit m/c Post 302319767 by vin_pll on Tuesday 26th of May 2009 07:13:11 AM
Old 05-26-2009
Sigbus with mmap.

sorry for the delayed reply,
please help me i am trying like this, though this is one sample test,
iam opening the two files one for reading and one for writing, and i am checking like this
Code:
if((input = open(argv[1], O_RDONLY)) == -1)
  fprintf(stderr, "%s: Error: opening file: %s\n", PACKAGE, argv[1]), exit(1);

 if((output = open(argv[2], O_RDWR|O_CREAT|O_TRUNC, 0666)) == -1)
  fprintf(stderr, "%s: Error: opening file: %s\n", PACKAGE, argv[2]), exit(1);

   source = (char *)mmap((char *)0, filesize, PROT_READ, MAP_SHARED,   input, 0);
printf("\n address of source==%p",source);
 if(source[0] ==-1)
  fprintf(stderr, "Error mapping input file: %s\n", argv[1]), exit(1);

target =(char *) mmap((char  *)0, filesize, PROT_WRITE, MAP_SHARED, output, 0);

printf("\n address of target==%d",target);
 if(target[0]==-1) //problem here
  fprintf(stderr, "Error mapping ouput file: %s\n", argv[2]), exit(1);

as i am opening both of them and checking instead of MAP_FAILED for the failure to target[0]==-1 ,
my question is what exactly is the data structure that mmap returns when i test for read it is successfull and for write it is not and also
if i change that to
if(target==(void*)-1 ) it returns successfull,
because in my code they have used
target[0]==-1 which is failing and results in sigbus if i replace it with
if(target==MAP_FAILED)
it is not even going for failure nor the sucess,
and fails some where in the reading. so what is the reason of sigbus
please solve my problem
 

4 More Discussions You Might Find Interesting

1. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies

2. UNIX for Advanced & Expert Users

migrating unix mp-ras 32 bit to linux suse 64 bit

Hi. I need to migrate the whole unix environment from a Unix mp-ras 32 bit to a Linux Suse 64 bit. 1) can i use cpio to copy the data? 2) can i just copy the users from unix to linux or do i have to create them by hand 3) are there any other concerns i should worry about? thanx (1 Reply)
Discussion started by: mrodrig
1 Replies

3. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

4. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies
funopen(3)                                                      SAORD Documentation                                                     funopen(3)

NAME
FunOpen - open a Funtools data file SYNOPSIS
#include <funtools.h> Fun FunOpen(char *name, char *mode, Fun ref); DESCRIPTION
The FunOpen() routine opens a Funtools data file for reading or appending, or creates a new FITS file for writing. The name argument speci- fies the name of the Funtools data file to open. You can use IRAF-style bracket notation to specify Funtools Files, Extensions, and Fil- ters. A separate call should be made each time a different FITS extension is accessed: Fun fun; char *iname; ... if( !(fun = FunOpen(iname, "r", NULL)) ){ fprintf(stderr, "could not FunOpen input file: %s ", iname); exit(1); } If mode is "r", the file is opened for reading, and processing is set up to begin at the specified extension. For reading, name can be stdin, in which case the standard input is read. If mode is "w", the file is created if it does not exist, or opened and truncated for writing if it does exist. Processing starts at the beginning of the file. The name can be stdout, in which case the standard output is readied for processing. If mode is "a", the file is created if it does not exist, or opened if it does exist. Processing starts at the end of the file. The name can be stdout, in which case the standard output is readied for processing. When a Funtools file is opened for writing or appending, a previously opened Funtools reference handle can be specified as the third argu- ment. This handle typically is associated with the input Funtools file that will be used to generate the data for the output data. When a reference file is specified in this way, the output file will inherit the (extension) header parameters from the input file: Fun fun, fun2; ... /* open input file */ if( !(fun = FunOpen(argv[1], "r", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); /* open the output FITS image, inheriting params from input */ if( !(fun2 = FunOpen(argv[2], "w", fun)) ) gerror(stderr, "could not FunOpen output file: %s ", argv[2]); Thus, in the above example, the output FITS binary table file will inherit all of the parameters associated with the input binary table extension. A file opened for writing with a Funtools reference handle also inherits the selected columns (i.e. those columns chosen for processing using the FunColumnSelect() routine) from the reference file as its default columns. This makes it easy to open an output file in such a way that the columns written to the output file are the same as the columns read in the input file. Of course, column selection can easily be tailored using the FunColumnSelect() routine. In particular, it is easy to merge user-defined columns with the input columns to gener- ate a new file. See the evmerge for a complete example. In addition, when a Funtools reference handle is supplied in a FunOpen() call, it is possible also to specify that all other extensions from the reference file (other than the input extension being processed) should be copied from the reference file to the output file. This is useful, for example, in a case where you are processing a FITS binary table or image and you want to copy all of the other extensions to the output file as well. Copy of other extensions is controlled by adding a "C" or "c" to the mode string of the FunOpen() call of the input reference file. If "C" is specified, then other extensions are always copied (i.e., copy is forced by the application). If "c" is used, then other extensions are copied if the user requests copying by adding a plus sign "+" to the extension name in the bracket specifi- cation. For example, the funtable program utilizes "c" mode, giving users the option of copying all other extensions: /* open input file -- allow user copy of other extensions */ if( !(fun = FunOpen(argv[1], "rc", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); /* open the output FITS image, inheriting params from input */ if( !(fun2 = FunOpen(argv[2], "w", fun)) ) gerror(stderr, "could not FunOpen output file: %s ", argv[2]); Thus, funtable supports either of these command lines: # copy only the EVENTS extension csh> funtable "test.ev[EVENTS,circle(512,512,10)]" foo.ev # copy ALL extensions csh> funtable "test.ev[EVENTS+,circle(512,512,10)]" foo.ev Use of a Funtools reference handle implies that the input file is opened before the output file. However, it is important to note that if copy mode ("c" or "C") is specified for the input file, the actual input file open is delayed until just after the output file is opened, since the copy of prior extensions to the output file takes place while Funtools is seeking to the specified input extension. This implies that the output file should be opened before any I/O is done on the input file or else the copy will fail. Note also that the copy of sub- sequent extension will be handled automatically by FunClose() if the output file is closed before the input file. Alternatively, it can be done explicitly by FunFlush(), but again, this assumes that the input file still is open. Upon success FunOpen() returns a Fun handle that is used in subsequent Funtools calls. On error, NULL is returned. SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funopen(3)
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy