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
explain_mmap_or_die(3)					     Library Functions Manual					    explain_mmap_or_die(3)

NAME
explain_mmap_or_die - map file or device into memory and report errors SYNOPSIS
#include <libexplain/mmap.h> void *explain_mmap_or_die(void *data, size_t data_size, int prot, int flags, int fildes, off_t offset); void *explain_mmap_on_error(void *data, size_t data_size, int prot, int flags, int fildes, off_t offset); DESCRIPTION
The explain_mmap_or_die function is used to call the mmap(2) system call. On failure an explanation will be printed to stderr, obtained from the explain_mmap(3) function, and then the process terminates by calling exit(EXIT_FAILURE). The explain_mmap_on_error function is used to call the mmap(2) system call. On failure an explanation will be printed to stderr, obtained from the explain_mmap(3) function, but still returns to the caller. data The data, exactly as to be passed to the mmap(2) system call. data_size The data_size, exactly as to be passed to the mmap(2) system call. prot The prot, exactly as to be passed to the mmap(2) system call. flags The flags, exactly as to be passed to the mmap(2) system call. fildes The fildes, exactly as to be passed to the mmap(2) system call. offset The offset, exactly as to be passed to the mmap(2) system call. RETURN VALUE
The explain_mmap_or_die function only returns on success, see mmap(2) for more information. On failure, prints an explanation and exits, it does not return. The explain_mmap_on_error function always returns the value return by the wrapped mmap(2) system call. EXAMPLE
The explain_mmap_or_die function is intended to be used in a fashion similar to the following example: explain_mmap_or_die(data, data_size, prot, flags, fildes, offset); SEE ALSO
mmap(2) map file or device into memory explain_mmap(3) explain mmap(2) errors exit(2) terminate the calling process COPYRIGHT
libexplain version 0.52 Copyright (C) 2010 Peter Miller explain_mmap_or_die(3)
All times are GMT -4. The time now is 02:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy