Tuesday, 26 September 2017

Outreachy Internship

Outreachy provides three-month internships for people from groups traditionally underrepresented in tech. Interns are paid a stipend of $5,500 and have a $500 travel stipend available to them. Interns work remotely with mentors from Free and Open Source Software (FOSS) communities on projects ranging from programming, user experience, documentation, illustration and graphical design, to data science. Interns often find employment after their internship with Outreachy sponsors or in jobs that use the FOSS skills they learned during their internship.

Outreachy internships are open internationally to women (cis and trans), trans men, and genderqueer people. Internships are also open to residents and nationals of the United States of any gender who are Black/African American, Hispanic/Latin@, Native American/American Indian, Alaska Native, Native Hawaiian, or Pacific Islander. We are planning to expand the program to more participants from underrepresented backgrounds in the future. https://www.outreachy.org/

OPEN SOURCE SUMMIT NORTH AMERICA 2017



Open Source Summit is an open source technical conference in North America, gathering 2,000+ developers, operators and community leadership professionals to collaborate, share information and learn about the latest in open source technologies, including Linux, containers, cloud computing and more.
At the Open Source Summit, you can expect to collaborate, share information and learn across a wide variety of topics like LinuxCon, ContainerCon, CloudOpen. read more




SPEAKER IN OPEN SOURCE SUMMIT CONFERENCE 


My last week was the best week than any other. Last week it was a great happened in Open Source Summit North America 2017 I was a speaker at the conference.  radix-tree-idr-apis-and-their-test-suite I presented "Implementing IDR in file descriptor allocation code path". My project deals with converting custom file descriptors allocation code to use the IDR resulting in memory saving for processes with relatively few open files and improving the performance of workloads with very large number of open files. It was a very different experience. People loved my subject and internship.They enjoyed so much. I would like to say Special Thanks to my Mentors Matthew Wilcox and Rik Van Riel. I also want to give Thanks to Laura Abbott, Marina Zhurakhinskaya, Sarah Sharp, Helen Koike. I met a lot of people there. They told me about their work, the projects going on in Open Source and a lot of other things.







AS ATTENDEE IN OPEN SOURCE SUMMIT CONFERENCE 


KEYNOTE: JIM ZEMLIN, EXECUTIVE DIRECTOR, THE LINUX FOUNDATION

He has spoken a few minutes about open source in 2017 and it's been a pretty incredible year and open source and you know things just keep getting better and today I thought I would talk to everyone about just how open source isn't growing it's actually accelerating exponentially in terms of its influence in technology and in society and-and these numbers are just amazing there are 23 million open-source developers worldwide I think they're like 22 million Republic accounts on GitHub 64 million repositories 41 million lines of code eleven hundred new projects every single day and then there are 10,000 new versions of different open source projects every single day it's pretty amazing just the growth and the sheer number of developers and projects in open source and even within individual projects speed is accelerating.
I liked Jim's keynote too much. The open source development he explained very beautifully. I met him personally later and he is very nice, he talked to me despite being very great.



KEYNOTE: THE PRESENT AND FUTURE OF TECH - AI - TANMAY BAKSHI


He’s using cognitive and cloud computing to change the world, through his open-source initiatives, for instance, “The Cognitive Story”, meant to augment and amplify human capabilities; and “AskTanmay”, the world’s first Web-Based NLQA System, built using IBM Watson’s Cognitive Capabilities. His learning and sharing experience of 8 years in the fields of software and cognitive development, has taught him how to best utilize and apply AI in fields ranging from banking and finance to healthcare and medicine to music and chatbots.

He is very simple. When I met him, I felt like he is my younger brother and we know each other from a long time. He explained keynote on Present and Future of Tech - AI. It was amazing for me. he likes India so much. Her mother said he always tries to come in India. Tanmay's mom and dad are a very humble person.
-----------------------------------------------------------------------------------------

I have attended the following keynote by,

  • KEYNOTE: OPEN SOURCE SOFTWARE AS ACTIVISM - CHRISTINE CORBETT MORAN

               https://www.youtube.com/watch?v=MwXQezLjku8&list=PLbzoR-pLrL6oNLRbC03ziuX0JWzQFjnth&index=2

  • KEYNOTE: THE DIFFERENCE BETWEEN A CROWD AND A COMMUNITY - JOSEPH                                                                                                       GORDON-LEVITT

                https://www.youtube.com/watch?v=NvcIcDKJ1ws&index=16&list=PLbzoR-pLrL6oNLRbC03ziuX0JWzQFjnth

  • KEYNOTE LIGHTNING TALK: OPENNESS IN A CLOUD CENTRIC WORLD - APARNA                                                                                                                       SINHA

                https://www.youtube.com/watch?v=y2iV1MDDuqQ&list=PLbzoR-pLrL6oNLRbC03ziuX0JWzQFjnth&index=14

  • KEYNOTE LIGHTNING TALK: HUMAN ENABLEMENT - ALAN CLARK

                https://www.youtube.com/watch?v=HfZRv3Kcykc&list=PLbzoR-pLrL6oNLRbC03ziuX0JWzQFjnth&index=3
------------------------------------------------------------------------------------------------------------------------
I also attended some following Talks,


Matthew Wilcox

The new XArray is easier to use than the radix tree. Conceptually, it is an array of 16 quintillion pointers, all of which are initially NULL. Just like an array, its basic operations are 'load' and 'store', unlike a tree's 'lookup', 'insert' and 'delete'. It provides some more advanced operations and enables users to build their own operations. This talk covers general aspects of API design for C programmers, as well as particular considerations for kernel API design due to the constrained environment.

Replacing the Radix Tree - Matthew Wilcox, Microsoft






Paul McKenney

This talk will look at a few representative RCU CPU stall warning messages and show how they can be decoded into real information that can help you find otherwise silent hangs the easy way. 
Decoding Those Inscrutable RCU CPU Stall Warnings - Paul McKenney, IBM


 https://schd.ws/hosted_files/ossna2017/2b/stallwarning.2017.09.08a.pdf

Gabriel Krisman Bertazi 

What influences a program's performance? Some reasons are quite obvious, like the algorithm implemented and the number of execution cycles, but what about the order in which libraries were linked? Or the shell environment size? Or even the sequence and which compiler optimizations were applied? In fact, modern computer systems include such a multitude of features and options, whose interaction with each other can affect the workload's performance, that it is surprisingly hard to write code that fully benefits from the potential of the CPU. In this talk, we will discuss how small changes in the code and in the execution environment can impact the execution time and how you can use Linux performance assessment tools, like perf and valgrind, to detect and mitigate such pitfalls.

Sarah Sharp

Sarah is also a co-coordinator for Outreachy, a paid internship program for increasing diversity in open source projects. Applications are open to women (cis and trans), trans men, and genderqueer people, and United States residents of any gender who are Black/African American, Hispanic/Latin@, American Indian, Alaska Native, Native Hawaiian, or Pacific Islander.
I met her and I really enjoyed talking to Sarah. 


https://schd.ws/hosted_files/ossna2017/bd/sarah-sharp-so-you-have-a-coc-what-now-low-res.pdf

Sarah is a Linux and open source developer and has been running Debian-based Linux systems since 2003. She was a Linux kernel developer from 2006 to 2013 and is the original author of the Linux USB 3.0 xHCI host controller driver.
-----------------------------------------------------------------------------------------

I clicked some pictures with people. I met people I wanted to meet them a lot of days

Greg kroah-hartman

My first kernel patch was accepted by gregkh. It was really beautiful feeling.


Nithya Ruff

I also enjoyed  Nithya's Talk on First 90 Days - Building an OSS Practice. I believe her talk has helped me see successful open source project and community work in very first 90 days.



  Angela Brown



Tameika Reed



Marina Zhurakhinskaya


Hong Phuc Dang , FOSSASIA


Finally my Cospeaker and Outreachy friends,
  • Rehas Sachdeva
  • Amitoj Kour Chawala
  • Jaminy Prabhakaran



I would like to thanks to The Linux Foundation and Outreachy for sponsoring my trip.






Wednesday, 22 February 2017

Test cases of dup3() for radix tree__alloc_fd

I have written dup3() test case.
I am going to run this test case for the close_on_exec patch.
Also, I have written one program (child_process.c) which will run on exec and try to open the file using fdopen().

dup3() test case is given below,

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * This is dup3() functionality testcase. 
 * The dup3() is duplicate a file descriptor to a given number, 
 * with flags.
 */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

extern char **environ;

#define WRONG_FLAG -1

int dup3_basic_tests () {

 int oldfd, newfd;
 int ret;

 oldfd = open("/tmp/file1",O_CREAT | O_RDWR, 0644);
 if (oldfd < 0) {
  printf("open() error \n");
  return -1;
 }
 ret = fcntl(oldfd, F_GETFD);
 if (ret != FD_CLOEXEC)
  printf("test 1 : pass\n");
 else
  printf("test 1 : fail\n");

 ret = dup3(oldfd, newfd, O_CLOEXEC);
 if (ret == -1) {
  printf("dup3() error \n");
  return -1;
 }

 ret = fcntl(newfd, F_GETFD);   /* Read the file descriptor flags */

 if (ret == FD_CLOEXEC)
  printf("test 2 : pass\n");
 else
  printf("test 2 : fail\n");

 close(newfd);

 ret = dup3(oldfd, newfd, 0);
 if (ret == -1) {
  printf("dup3() error \n");
  return -1;
 }

 ret = fcntl(newfd, F_GETFD);

 if (ret != FD_CLOEXEC)
  printf("test 3 : pass\n");
 else
  printf("test 3 : fail\n");

 close(newfd);

 ret = dup3(oldfd, newfd, WRONG_FLAG);
 if (ret == -1)
  printf("test 4 : pass \n");
 else
  printf("test 4 : fail \n");

 close(oldfd);
 unlink("/tmp/file1");
 return 0;
}

int dup3_loop() {
 int i,ret;
 int oldfd, newfd;

 oldfd = open("/tmp/file2",O_CREAT | O_RDWR, 0644);
 if (oldfd < 0) {
  printf("open() error \n");
  return -1;
 }

 for (i = 3; i < 100; i++) {
  ret = dup3(oldfd, i, O_CLOEXEC);
  if (ret < 0) {
   printf("dup3_loop : dup3() error\n");
   return -1;
  }  
 }
 for (i = 3; i < 100; i++) {
  ret = fcntl(i, F_GETFD);
  if (ret < 0) {
   printf("dup3_loop : fcntl() error\n");
   return -1;
  }
  if (ret == FD_CLOEXEC)
   printf("dup3_loop() : pass.%d\n",i);
  else
   printf("dup3_loop() : fail.%d\n",i);

  close(i);
 }

 unlink("/tmp/file2");
}

void fork_exec() {
 int fd,new_fd = 4;
 int pid,ret;
 char fd_buf[10];
 char *argv[3] = {"child_process",fd_buf, NULL};

 fd = open("/tmp/file3",O_CREAT | O_RDWR, 0644);
 if (fd < 0){
  printf("fork_exec : open failed\n");
  exit(-1); 
 }

 ret = dup3(fd, new_fd, O_CLOEXEC);
 printf("parent process new_fd %d\n", new_fd);
 if (ret < 0){
  printf("dup3 : dup3 failed\n");
  exit(-1);
 }

 pid = fork();

 if (pid == 0) {
  sprintf(fd_buf,"%d",new_fd);
  ret = execvp("./child_process", argv);
  if (ret < 0) {
   printf("execv() failed...\n");
   exit(-1);
  }
 }
}

int main() {
 int ret;
 ret = dup3_basic_tests();
 if (ret == -1)
  return -1;
 ret = dup3_loop();
 if (ret == -1)
  return -1;
 fork_exec();
 return 0; 
}



Program for child_process.c which will run on exec,
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char *argv[]) {

 int fd,ret;
 FILE *file;

 if (argc < 2) {
  printf("Usage : %s fd\n",argv[0]);
  return -1;
 }

 fd = atoi(argv[1]);
 printf("child process fd %d\n", fd); 
 file = fdopen(fd, "r+");
 if (file == NULL)
  printf("fork-exec : test pass\n");
 else
  printf("fork-exec : test fail\n");
 
 return 0;
}

Tuesday, 31 January 2017

Test cases of dup2() for radix tree__alloc_fd

I have written a test case of dup2()
This is dup2() functionality test case. The dup2() makes newfd be the copy of oldfd, closing newfd first if necessary.
This test case covers below scenarios
  * Provide invalid file descriptor to dup2()
  * Fill up all file descriptor table and try to duplicate a file descriptor using dup2().
  * Using dup2() duplicate both file descriptor return by the pipe.
  * Check inode number after passing newfd and oldfd to fstat(). inode number should be same.

Upon successful execution this program will return zero value, otherwise, it will return -1.


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int maxfd;

int dup2_misc_tc()
{
 int *fd, i, maxfd;
 int ret, goodfd;

goodfd = open("test/file1", O_CREAT | O_RDWR, 0644);
 
 if(goodfd == -1)
 {
  printf("dup2_misc_tc() : dup2 failed...\n");
  return -1;
  }
 ret = dup2(-1, goodfd);
 if(ret == -1)
 {
  printf("dup2_misc_tc1 : Pass \n");
 }
 else
 {
  printf("dup2_misc_tc1: fail \n");
 }
 ret = dup2(goodfd, -1);
 if(ret == -1)
 {
  printf("dup2_misc_tc1 : Pass \n");
 }
 else
 {
  printf("dup2_misc_tc1: fail \n");
 }

close(goodfd);
 unlink("test/file1");

return 0;
}

int max_fd_dup2()
{
 int *fd, i;
 int ret;
 char buf[15];
 maxfd = getdtablesize();
 
 fd = malloc(maxfd * sizeof(int));
 printf("maxfd = %d\n",maxfd);

for(i = 0; i < (maxfd-3); i++)
 {
  sprintf(buf, "test/myfile%d", i);
  fd[i] = open(buf, O_CREAT | O_RDWR, 0644);
  if (fd[i] == -1)
  {
   printf("max_fd_dup2() :: open() failed...\n");
   return -1;
  }
 }
 printf("here ***************\n");
 ret = dup2(10,24);
 if(ret == -1)
  printf("max_fd_dup2: tc: Fail\n");
 else
  printf("max_fd_dup2: tc: Pass\n");
 
 ret = dup2(10,maxfd);
 if(ret == -1)
  printf("max_fd_dup2: tc: Pass\n");
 else
  printf("max_fd_dup2: tc: Fail\n");

return 0;
 
}

int pipe_dup2_tc()
{
 int fd[2];
 int ret;
 ret = pipe(fd);
 if(ret == -1)
 {
  printf("pipe_dup2_tc : Pipe Failed\n");
  return -1;
 }
 ret = dup2(fd[0],5);
 
 if(ret == -1)
 
  printf("pipe_dup2_tc : fail\n");
 else
  printf("pipe_dup2_tc: pass1\n");

ret = dup2(fd[1],6); 
 if(ret == -1)
 
  printf("pipe_dup2_tc : fail\n");
 else
  printf("pipe_dup2_tc: pass2\n");
 
 close(fd[0]);
 close(fd[1]);
 return 0;
}

int dup2_ino_tc()
{
        struct stat buf1, buf2;
        char buf[20];
        int ret, oldfd, newfd, fd_fd;

oldfd = open("test/file11", O_CREAT | O_RDWR, 0644);
        if(oldfd == -1)
        {
                printf("dup_misc_tc() : open() failed...\n");
                return -1;
        }
 
        newfd = open("test/file12", O_CREAT | O_RDWR, 0644);
        if(newfd == -1)
        {
                printf("dup_misc_tc() : open() failed...\n");
                return -1;
        }

ret = dup2(oldfd,newfd);
        if (ret == -1)
        {
                printf("dup2_ino_tc : fail\n");
        }
        else
        {
                printf("dup2_ino_tc : pass\n");
        }

ret = fstat(oldfd, &buf1); /* get the file status */
        if(ret == -1)
        {
                printf("dup2_ino_tc() : fstat() failed...\n");
                return -1;
        }

ret = fstat(newfd, &buf2);
        if(ret == -1)
        {
                printf("dup2_ino_tc() : fstat() failed...\n");
                return -1;
        }

printf("buf1.st_ino = %lu\n",buf1.st_ino);
        printf("buf2.st_ino = %lu\n",buf2.st_ino);
        if(buf1.st_ino == buf2.st_ino)
                printf("dup2_ino_tc : pass\n");
        else
                printf("dup2_ino_tc : fail\n");
        close(oldfd);
        close(newfd);
        unlink("test/file1");
 
        return 0;
}

int close_fd(int count) 
{
 int i;
 for(i = 3; i < count; i++)
 {
  close(i);
 }
}

void unlink_files(int count)
{
 char buf[15];
 int i;

for(i = 0; i < count; i++)
 {
  sprintf(buf,"test/myfile%d",i);
  unlink(buf);
 }
}

int main(int argc, char **argv)
{
 int err = 0;
 char *name;
 int goodfd;
 if(argc < 2)
 {
  printf("usage: %s <tcNUM> \n", argv[0]);
  printf("Provide oprion to program as tc1, tc2, tc3, tc4\n");
  return -1;
 }
 name = argv[1];
 
 if(strcmp(name, "tc1") == 0)
 {
  err = dup2_misc_tc();
  if(err == -1)
  {
   return -1;
  }
 }
 else if(strcmp(name, "tc2") == 0)
 {
  max_fd_dup2();
  close_fd(maxfd-3);
  unlink_files(maxfd);
 }
 
 else if(strcmp(name, "tc3") == 0)
 {
  pipe_dup2_tc(); 
 }
 
 else if(strcmp(name, "tc4") == 0)
 {
  dup2_ino_tc();
 }

return 0;
}

Test cases of dup() for radix tree__alloc_fd

I have written the test case for dup( ).
This is dup( ) functionality test case. The dup( ) use for duplicate the file descriptor.
This test case covers below different scenarios:
* Duplicate file descriptor five times one by one.
* Fill up all file descriptor table and try to duplicate a file descriptor. dup( ) should not be succeeded.
* Give invalid file descriptor to the dup( ). dup( ) should be failed.
* Check inode number after passing newfd and oldfd to fstat( ). inode number should be same.
 Upon successful execution this program will return zero value, otherwise, it will return -1.



  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int maxfd;

int dup_fd(int count)
{
 int fd[count],i;
 char buf[15];

for(i = 0; i < count; i++)
 {
 sprintf(buf, test/myfile%d, i);
 fd[i] = open(buf, O_CREAT | O_RDWR, 0644); 
 printf(open: %d\n, fd[i]);
 if(fd[i] == -1)
 {
 printf(open() failed\n);
 return -1;
 }
 fd [i+1] = dup(i);
 if (fd [i+1] == -1)
 {
 printf(dup() failed\n);
 return -1;
 }
 printf(dup: %d\n, fd [i+1]);
 }
 
 return 0;
}
void close_fd(int count)
{
 int i;
 for (i = 3; i < count; i++)
 {
 close(i);
 }
}

void unlink_files(int count)
{
 char buf[15];
 int i;

for(i = 0; i < count; i++)
 {
 sprintf(buf,test/myfile%d,i);
 unlink(buf);
 }
}

int max_fd_dup() 
{
 int *fd, i;
 int ret;
 char buf[15];
 maxfd = getdtablesize(); /* get descriptor table size */

 fd = malloc(maxfd * sizeof(int)); /* allocate the memory */

 printf(maxfd = %d\n,maxfd);

 for (i = 0; i < (maxfd-3); i++)
 {
 sprintf(buf, test/myfile%d, i);
 fd[i] = open(buf, O_CREAT | O_RDWR, 0644); 
 if (fd[i] == -1)
 {
 printf(max_fd_dup() :: open() failed\n);
 return -1;
 }
 }
 printf(here *****************\n);
 
 ret = dup(10); /* duplicate the file descriptor */
 
 if(ret == -1)
 printf(max_fd_dup: tc : pass\n);
 else
 printf(max_fd_dup: tc : fail\n);

return 0;
}
int dup_misc_tc()
{
 int *fd, i, maxfd;
 struct stat buf1, buf2;
 char buf[20];
 int ret, oldfd, newfd;

 ret = dup(10);
  if (ret == -1)
  {
  printf(dup_misc_tc1 : pass\n);
  }
  else
  {
  printf(dup_misc_tc1 : fail\n);
  }

 ret = dup(-1);

 if (ret == -1)
  {
  printf(dup_misc_tc2 : pass\n);
  }
 else
  {
  printf(dup_misc_tc2 : fail\n);
  }

 oldfd = open(test/file1, O_CREAT | O_RDWR, 0644);
 if(oldfd == -1)
 {
  printf(dup_misc_tc() : open() failed\n);
  return -1;
 }
 
 newfd = dup(oldfd);
 if(newfd == -1)
 {
  printf(dup_misc_tc() : dup() failed\n);
  return -1;
 }

 ret = fstat(oldfd, &buf1); /* get the file status */
 if(ret == -1)
 {
  printf(dup_misc_tc() : fstat() failed\n);
  return -1;
 }
 ret = fstat(newfd, &buf2);
 if(ret == -1)
 {
  printf(dup_misc_tc() : fstat() failed\n);
  return -1;
 }

 printf(buf1.st_ino = %d\n,buf1.st_ino);
 printf(buf2.st_ino = %d\n,buf2.st_ino);
 if(buf1.st_ino == buf2.st_ino)
  printf(dup_misc_tc3 : pass\n);
 else
  printf(dup_misc_tc3 : fail\n);
 close(oldfd);
 close(newfd);
 unlink(test/file1);
 return 0;
}

int main(int argc, char **argv)
{
 int err = 0;
 char *name;

if(argc < 2)
 {
 printf(usage: %s <tcNum> \n, argv[0]);
 printf(provide options to program as tc1, tc2, tc3 etc\n);
 return -1;
 }
 name = argv[1];

if(strcmp(name, tc1) == 0)
 {

err = dup_fd(5);
 if (err == -1)
 {
 return -1;
 }
 close_fd(10);
 unlink_files(5);
 }
 else if(strcmp(name, tc2) == 0)
 {
  max_fd_dup();
  close_fd(maxfd-3);
  unlink_files(maxfd);
 }
 else if(strcmp(name, tc3) == 0)
 {
  dup_misc_tc();
 }
 else
  printf(Invalid option \n);

return 0;
}