If so a reply message already has been sent by handleevents and there is

If so a reply message already has been sent by

This preview shows page 38 - 40 out of 140 pages.

was done (lines 14058 to 14060). If so, a reply message already has been sent by handle_events and there is nothing left to do. If not, a reply message is generated. with the message parameters depending upon whether or not the original write call was called in nonblocking mode. The next function, do_ioctl (line 14079), is a long one, but not difficult to understand. The body of do_ioctl is two switch statements. The first determines the size of the parameter pointed to by the pointer in the request message (lines 14094 to 14125). If the size is not zero, the parameter's validity is tested. The contents cannot be tested here, but what can be tested is whether a structure of the required size beginning at the specified address fits within the segment it is specified to be in. The rest of the function is another switch on the type of ioctl operation requested (lines 14128 to 14225). Unfortunately, supporting the POSIX-required operations with the ioctl call meant that names for ioctl operations had to be invented that suggest, but do not duplicate, names required by POSIX. Figure 3-39 shows the relationship between the POSIX request names and the names used by the MINIX 3 ioctl call.A TCGETS operation services a tcgetattr call by the user and simply returns a copy of the terminal device's tp- >tty_termios structure. The next four request types share code. The TCSETSW, TCSETSF, and TCSETS request types correspond to user calls to the POSIX-defined function tcsetattr, and all have the basic action of copying a new termios structure into a terminal's tty structure. The copying is done immediately for TCSETS calls and may be done for TCSETSW and TCSETSF calls if output is complete, by a sys_vircopy kernel
Image of page 38
call to get the data from the user, followed by a call to setattr, on lines 14153 to 14156. If tcsetattr was called with a modifier requesting postponement of the action until completion of current output, the parameters for the request are placed in the terminal's tty structure for later processing if the test of tp->tty_outleft on line 14139 reveals output is not complete. Tcdrain suspends a program until output is complete and is translated into an ioct l call of type TCDRAIN. If output is already complete, it has nothing more to do. If output is not complete, it also must leave information in the tty structure. [Page 339] Figure 3-39. POSIX calls and IOCTL operations. POSIX function POSIX operation IOCTL type IOCTL parameter tcdrain (none) TCDRAIN (none) tcflow TCOOFF TCFLOW int=TCOOFF tcflow TCOON TCFLOW int=TCOON tcflow TCIOFF TCFLOW int=TCIOFF tcflow TCION TCFLOW int=TCION tcflush TCIFLUSH TCFLSH int=TCIFLUSH tcflush TCOFLUSH TCFLSH int=TCOFLUSH tcflush TCIOFLUSH TCFLSH int=TCIOFLUSH tcgetattr (none) TCGETS termios tcsetattr TCSANOW TCSETS termios tcsetattr TCSADRAIN TCSETSW termios tcsetattr TCSAFLUSH TCSETSF termios tcsendbreak (none) TCSBRK int=duration The POSIX tcflush function discards unread input and/or unsent output data, according to its argument, and the ioctl translation is straightforward, consisting of a call to the
Image of page 39
Image of page 40

You've reached the end of your free preview.

Want to read all 140 pages?

  • One '20

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes