Getting the available free space on a directory in linux [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Using a C program how to get the free size available in a directory ?
What are the library functions that i can use to achieve this.

A given directory does not have free space, it is the file system (containing that directory) which has free space.
You can query that using the df(1) command (you might popen(3) "/bin/df .", but I don't recommend doing that) and the statfs(2) (and some other) syscall(s).
See syscalls(2) and read Advanced Linux Programming
Perhaps the limit is quota related, see repquota(8), or resource-limit related, see ulimit builtin of bash and getrlimit(2). Maybe use /proc/ pseudo-files, see proc(5)
BTW, that limit is in fact only indicative: other programs and processes are also able to fill the directory (e.g. between the moment your program is querying it and the moment it is writing data).

Related

How does C access files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
everyone! I'm learning how to access files in C but, I wonder how my program(or C) access files(drive sectors)? I'm searching the Internet for answers but they don't have some proper explanation on how C(or my program), loads drive sectors to memory. Please give me some clarity, and thanks in advance.
C programs use functions of the kernel or a device driver to access hardware. A computing platform (Windows, Linux, OSX, etc) that supports C provides an implementation of the C standard library for programmers. This library contains system specific implementations of functions for accessing files, like fopen. The systems implementation of the standard library is most often just a wrapper around their specific system calls. For example on Windows, the C standard library is going to end up calling these functions: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/

Install a C program to another machine without share code [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
This post was edited and submitted for review 11 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to install a C program UNIX to another UNIX machine, what can I do?
In case the other machine has different architecture how can I share my program in the best way?
The simplest way to share your program is compile it and share the binaries. There are a lot of open question you will have to solve (libraries dependencies, specific distribution configurations, ...). You must to precompile for every targeted hardware architecture (x86-64, ARM, ...) and for every specific SO (BSD, Linux, ... even Windows).
As an example, Gimp is coded in C/C++ and exists binaries for many hardware architectures and operating systems.

How to find the minimum system requirements needed for the program I wrote in the C language? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I wrote a program in the C language. Now I want to make the system documentation for that program. And, I would like to state the minimum system requirements that are needed to run my my program.
How do I find out what they are?
Things you can do:
Try running your app on the oldest machines you can find.
Remove a couple memory sticks from your computer
Do you have a define _WIN32_WINNT in your application? If not, the windows SDK you use will define the minimum OS requirement.
You can also try compiling with -D_WIN32_WINNT=xx for an older version to see how far back you can go, based on the Windows API calls you use. windows.h is pretty good at hiding APIs for versions newer than the one you specify with _WIN32_WINNT. Then keep that setting to compile your app to create test and release binaries.
Here's the MS doc on versioning with _WIN32_WINNT: https://msdn.microsoft.com/library/windows/desktop/aa383745
Silly me! I forgot to add that you MUST test on the oldest version you specify in your specs + the one most used by your target users.

Executable files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What is the basis difference between an executable file and a non-executable file? is it just that the bytes of an executable are arranged in a meaningful order which a CPU can understand as instructions?
An executable file contains an operating system specific header indicating that the file is meant to hold executable instructions, as well as the instructions themselves. Typically though not universally certain file extensions are either common by convention or required to indicate that a file is executable in addition to the file having a valid header.
If the operating system is told to execute a file, it will check the file header and possibly file extension and, if those match the rules for executability (after possibly checking security concerns as well), the operating system will load the file into memory and attempt to execute the instructions therein.
There's a good overview on Wikipedia
http://en.wikipedia.org/wiki/Executable_and_Linkable_Format
http://en.wikipedia.org/wiki/EXE

Licensing c program [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How would i licence my c command line program, e.g limited functionality without a serial number?
Depends what licensing means ...
Write the license text into the source code resp. show the license text when installing or starting the program.
If you want prevent users from copying the program, things get complicated, you might need some hardware dongle.
Or just make it GPL and give the source code away ...
Include a EULA (End User License Agreement) in your program which users will have to accept while installing/using your application. You can get lots of sample EULAs in Internet. Replace the Names appropriately. But remember, you are gonna do things at your own risk. Read the EULA well, modify it to suit your needs.

Resources