October 2017
Intermediate to advanced
586 pages
14h 8m
English
switch( whence ){
case SEEK_SET:/* relative from the beginning of file */
newpos = offset; /* offset become the new position */
break;
case SEEK_CUR: /* relative to current file position */
newpos = file->f_pos + offset; /* just add offset to the current position */
break;
case SEEK_END: /* relative to end of file */
newpos = filesize + offset;
break;
default:
return -EINVAL;
}
if ( newpos < 0 )
return -EINVAL;
filp->f_pos = newpos;
return newpos;
The following is an example of a user program ...