Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7999561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:32:27+00:00 2026-06-04T15:32:27+00:00

android is a kind of linux,and it must support the posix.But,when it seems not

  • 0

android is a kind of linux,and it must support the posix.But,when it seems not support the syscall,open().
Here is the code for testing,and i compile it via NDK:

#include <unistd.h>
#include <stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

void main(){
    int fd;
    char pathname[128] = "/data/pwrite.txt";
    fd = open(pathname, O_WRONLY);
    if(fd==-1){
        printf("open fail.\n");

    }
    perror("/data/pwrite.txt");
}

and the following is the prompt that comes from android:

kaiwii@ubuntu:~$ adb shell /data/pwrite/test1
open fail.
/data/pwrite.txt: No such file or directory
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:32:29+00:00Added an answer on June 4, 2026 at 3:32 pm

    I think that the problem is in the flags – you only use O_WRONLY. But if a file does not exist you should also create it using O_CREAT flag. So if a file does not exist you should call:

    fd = open(pathname, O_WRONLY | O_CREAT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am kind of new in Android and SQL (not completely newbie, but not
Possible Duplicate: Android Layout and positioning issue Design layout which support for all kind
Environment: Android 2.3.3 with Google API I know this is kind of long, but
first of all, I'm not involved in any kind of Android development. I'm only
I'm planing some kind of information app for android and I'm not sure what
I know this kind of question has been asked before, for example here: Android:
Will this kind of code cause memory leak in Android? class MyActivity extends Activity
Hello I'm creating application for android no mater what kind but I need to
develop android apps that should support iphone,ipad,android.is there any way for developing this kind
I am not quite sure what kind of layout Gmail is using in Android.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.