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
MMAP2(2)						     Linux Programmer's Manual							  MMAP2(2)

NAME
mmap2 - map files or devices into memory SYNOPSIS
#include <sys/mman.h> void *mmap2(void *addr, size_t length, int prot, int flags, int fd, off_t pgoffset); DESCRIPTION
This is probably not the system call that you are interested in; instead, see mmap(2), which describes the glibc wrapper function that invokes this system call. The mmap2() system call provides the same interface as mmap(2), except that the final argument specifies the offset into the file in 4096-byte units (instead of bytes, as is done by mmap(2)). This enables applications that use a 32-bit off_t to map large files (up to 2^44 bytes). RETURN VALUE
On success, mmap2() returns a pointer to the mapped area. On error, -1 is returned and errno is set appropriately. ERRORS
EFAULT Problem with getting the data from user space. EINVAL (Various platforms where the page size is not 4096 bytes.) offset * 4096 is not a multiple of the system page size. mmap2() can also return any of the errors described in mmap(2). VERSIONS
mmap2() is available since Linux 2.3.31. CONFORMING TO
This system call is Linux-specific. NOTES
On architectures where this system call is present, the glibc mmap() wrapper function invokes this system call rather than the mmap(2) sys- tem call. This system call does not exist on x86-64. On ia64, the unit for offset is actually the system page size, rather than 4096 bytes. SEE ALSO
getpagesize(2), mmap(2), mremap(2), msync(2), shm_open(3) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 MMAP2(2)
All times are GMT -4. The time now is 07:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy