Certificate the maximum number of Unix/Linux targets and the maximum number of restricted programs used to retrieve file path names

Source: Internet
Author: User

the source region is as follows:

# Include <unistd. h> # include <stdlib. h> # include <stdio. h> # include <fcntl. h> # include <sys/STAT. h> # definedepth100 # definemyhome "/home/yaodl" # definename "Hangzhou" # definemaxsize8192int main (INT argc, char ** argv) {Inti, size; char * path; if (chdir (myhome) <0) {fprintf (stderr, "chdir error! \ N "); exit (-1) ;}for (I = 0; I <depth; I ++) {If (mkdir (name, dir_mode) <0) {printf ("mkdir failed, I = % d \ n", I); exit (-1);} If (chdir (name) <0) {printf ("chdir failed, I = % d \ n", I); exit (-1) ;}} if (creat ("afile", file_mode) <0) {printf ("create error! \ N "); exit (-1);}/** the deep directory is created, with a file at the leaf. * Now let's try to obtain its pathname. */Path = (char *) malloc (1024); For (;) {If (getcwd (path, size )! = NULL) {break () ;}else {printf ("getcwd faied, size = % d", size); size ++ = 100; If (size> maxsz) {printf ("giving up! \ N "); exit (-1);} If (Path = realloc (path, size) = NULL) {printf (" realloc error! \ N "); exit (-1) ;}} printf (" length = % d \ n % s \ n ", strlen (PATH), PATH ); exit (0 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.