Writing to a file
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, I'm working on an IO logging utility for FreeBSD as my GSoC project, and I have some questions about writing a kernel functions that would open an existing or create a new file (with the file name as a parameter, returns a vnode * for the file) and write data to that file (with pointer to data as parameter). I've found some functions in existing code that do similar things and might help me understand how to solve my problem, but as there isn't much documentation out there I still don't understand a lot of things. So, could anyone please give me a detailed explanation of how to open a file in kernel and write to it - best data types to use, functions, what to look out for, maybe a link to tutorial or manual that deals with this (if such a thing exists), etc.? Thanks in advance, Sonja -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGPM4eLfhGYNm8UfsRAiHjAJ4rIhKj2IKpnFj50zSs3IpxymWOzACfcER5 enTeEvaD/syyRQZmtDmlDIU= =xH5D -END PGP SIGNATURE- ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Writing to a file
On May 5, 2007, at 9:34 PM, Sonja Milicic wrote: I'm working on an IO logging utility for FreeBSD as my GSoC project, and I have some questions about writing a kernel functions that would open an existing or create a new file (with the file name as a parameter, returns a vnode * for the file) and write data to that file (with pointer to data as parameter). I've found some functions in existing code that do similar things and might help me understand how to solve my problem, but as there isn't much documentation out there I still don't understand a lot of things. So, could anyone please give me a detailed explanation of how to open a file in kernel and write to it - best data types to use, functions, what to look out for, maybe a link to tutorial or manual that deals with this (if such a thing exists), etc.? A good strategy for dealing with such questions is to look for code that does a task similar to the one you want to implement. Two kernel subsystems that come to my mind is the kernel logging facility, which writes data to a user space process via a socket, and the process accounting facility, which writes data to an already opened file. There are reasons (performance, flexibility) why these two facilities have been designed in this way, and it would be a good idea to see whether some of their design decisions are also applicable to your problem. Diomidis Spinellis - http://www.spinellis.gr ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Samsung DVD writer and FreeBSD kernel.
Hi, Excuse me for a long email. I have a problem with my external USB DVD writer (model SE-S184M/EUBN). I do not succeed in to burn DVD (only CD). The system (FreeBSD eclypse.it 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7 04:32:43 UTC 2006 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC i386) recognizes masterizzatore like: --- umass0: TSST corp USB Mass Storage Device, rev 2.00/0.00, addr 3 cd0 at umass-sim0 bus 0 target 0 lun 0 cd0: TSSTcorp CD/DVDW SH-S182M SB02 device Removable CD-ROM SCSI-0 cd0: 40.000MB/s transfers cd0: Device Attempt to query size failed: NOT READY, Medium not present - tray close If I use the comand whith a dvd+rw : dvd+rw- format /dev/cd0 I obtain * DVD±RW/-RAM format utility by [EMAIL PROTECTED] chalmers.se, version 6.0. :-( (unable to GET CONFIGURATION: Input/output error and on the consul: umass0: Unsupported ATAPI command 0x46. --- 1. I have asked the list questions , they advised me to contact the cdrecord maintainer (Jorg Schilling) for this problem. 2. He advised to me to upgrade of the program. After an upgrade the problem persisted. 3. After He says Can you verify that FreeBSD did not again break the SCSI implementation and does not do an auto-request Sense? Please use scgcheck to verify the correctness of your SCSI implementation. Jörg My verify is: --- Scgcheck 2.01 (i386-unknown-freebsd6.1) SCSI user level transport library ABI checker. Copyright (C) 1998,2001 Jörg Schilling Checking if your implementation supports to scan the SCSI bus. Trying to open device: '(NULL POINTER)'. Using libscg version 'schily-0.9' Using libscg transport code version 'schily-scsi-bsd.c-1.44' Using kernel transport code version 'data unavaiable' Using remote transport code version 'data unavaiable-data unavaiable' Max DMA buffer size: 65536 scsibus1: 1,0,0 100) 'ATAPI ' 'CD-ROM 52X ' '172A' Removable CD-ROM 1,1,0 101) 'HL-DT-ST' 'CD-RW GCE-8481B ' '1.00' Removable CD-ROM 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) * scsibus2: 2,0,0 200) 'TSSTcorp' 'CD/DVDW SH-S182M' 'SB04' Removable CD-ROM 2,1,0 201) * 2,2,0 202) * 2,3,0 203) * 2,4,0 204) * 2,5,0 205) * 2,6,0 206) * 2,7,0 207) * -- SCSI scan bus test PASSED For the next test we need to open a single SCSI device. Best results will be obtained if you specify a modern CD-ROM drive. Trying to open device: '2,0,0'. Using libscg version 'schily-0.9' Using libscg transport code version 'schily-scsi-bsd.c-1.44' Using kernel transport code version 'data unavaiable' Using remote transport code version 'data unavaiable-data unavaiable' Max DMA buffer size: 65536 Device type: Removable CD-ROM Version: 0 Response Format: 2 Capabilities : Vendor_info: 'TSSTcorp' Identifikation : 'CD/DVDW SH-S182M' Revision : 'SB04' First SCSI open OK - device usable Checking for second SCSI open. Second SCSI open for same device succeeded, 1 file descriptor(s) used. Second SCSI open is usable Closing second SCSI. Checking first SCSI. First SCSI open is still usable Second SCSI open test passed. Executing 'inquiry' command on Bus 2 Target 0, Lun 0 timeout 40s CDB: 12 00 00 00 24 00 cmd finished after 0.001s timeout 40s -- SCSI succeeded command test PASSED ** Testing for failed SCSI command. Inquiry did not fail. scgcheck: Input/output error. test unit ready: scsi sendcmd: retryable error CDB: 00 00 00 00 00 00 status: 0x2 (CHECK CONDITION) Sense Bytes: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Sense Key: 0x2 Not Ready, Segment 0 Sense Code: 0x3A Qual 0x01 (medium not present - tray closed) Fru 0x0 Sense flags: Blk 0 (not valid) cmd finished after 0.002s timeout 40s -- SCSI Transport return != SCG_NO_ERROR (1) -- SCSI failed command test FAILED ** Testing for SCSI sense data count. ** Testing if at least CCS_SENSE_LEN (18) is supported... Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 -- Wanted 18 sense bytes, got it. -- Libscg says 32 sense bytes but got (18) ** Testing for 32 bytes of sense data... Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- Wanted 32 sense bytes, got it. -- Got a maximum of
Re: Samsung DVD writer and FreeBSD kernel.
FreeBSD User Giacomo wrote: Hi, Excuse me for a long email. I have a problem with my external USB DVD writer (model SE-S184M/EUBN). I do not succeed in to burn DVD (only CD). The system (FreeBSD eclypse.it 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7 04:32:43 UTC 2006 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC i386) recognizes masterizzatore like: --- umass0: TSST corp USB Mass Storage Device, rev 2.00/0.00, addr 3 cd0 at umass-sim0 bus 0 target 0 lun 0 cd0: TSSTcorp CD/DVDW SH-S182M SB02 device Removable CD-ROM SCSI-0 cd0: 40.000MB/s transfers cd0: Device Attempt to query size failed: NOT READY, Medium not present - tray close If I use the comand whith a dvd+rw : dvd+rw- format /dev/cd0 I obtain * DVD±RW/-RAM format utility by [EMAIL PROTECTED] chalmers.se, version 6.0. :-( (unable to GET CONFIGURATION: Input/output error and on the consul: umass0: Unsupported ATAPI command 0x46. --- 1. I have asked the list questions , they advised me to contact the cdrecord maintainer (Jorg Schilling) for this problem. 2. He advised to me to upgrade of the program. After an upgrade the problem persisted. 3. After He says Can you verify that FreeBSD did not again break the SCSI implementation and does not do an auto-request Sense? Please use scgcheck to verify the correctness of your SCSI implementation. Jörg My verify is: --- Scgcheck 2.01 (i386-unknown-freebsd6.1) SCSI user level transport library ABI checker. Copyright (C) 1998,2001 Jörg Schilling Checking if your implementation supports to scan the SCSI bus. Trying to open device: '(NULL POINTER)'. Using libscg version 'schily-0.9' Using libscg transport code version 'schily-scsi-bsd.c-1.44' Using kernel transport code version 'data unavaiable' Using remote transport code version 'data unavaiable-data unavaiable' Max DMA buffer size: 65536 scsibus1: 1,0,0 100) 'ATAPI ' 'CD-ROM 52X ' '172A' Removable CD-ROM 1,1,0 101) 'HL-DT-ST' 'CD-RW GCE-8481B ' '1.00' Removable CD-ROM 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) * scsibus2: 2,0,0 200) 'TSSTcorp' 'CD/DVDW SH-S182M' 'SB04' Removable CD-ROM 2,1,0 201) * 2,2,0 202) * 2,3,0 203) * 2,4,0 204) * 2,5,0 205) * 2,6,0 206) * 2,7,0 207) * -- SCSI scan bus test PASSED For the next test we need to open a single SCSI device. Best results will be obtained if you specify a modern CD-ROM drive. Trying to open device: '2,0,0'. Using libscg version 'schily-0.9' Using libscg transport code version 'schily-scsi-bsd.c-1.44' Using kernel transport code version 'data unavaiable' Using remote transport code version 'data unavaiable-data unavaiable' Max DMA buffer size: 65536 Device type: Removable CD-ROM Version: 0 Response Format: 2 Capabilities : Vendor_info: 'TSSTcorp' Identifikation : 'CD/DVDW SH-S182M' Revision : 'SB04' First SCSI open OK - device usable Checking for second SCSI open. Second SCSI open for same device succeeded, 1 file descriptor(s) used. Second SCSI open is usable Closing second SCSI. Checking first SCSI. First SCSI open is still usable Second SCSI open test passed. Executing 'inquiry' command on Bus 2 Target 0, Lun 0 timeout 40s CDB: 12 00 00 00 24 00 cmd finished after 0.001s timeout 40s -- SCSI succeeded command test PASSED ** Testing for failed SCSI command. Inquiry did not fail. scgcheck: Input/output error. test unit ready: scsi sendcmd: retryable error CDB: 00 00 00 00 00 00 status: 0x2 (CHECK CONDITION) Sense Bytes: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Sense Key: 0x2 Not Ready, Segment 0 Sense Code: 0x3A Qual 0x01 (medium not present - tray closed) Fru 0x0 Sense flags: Blk 0 (not valid) cmd finished after 0.002s timeout 40s -- SCSI Transport return != SCG_NO_ERROR (1) -- SCSI failed command test FAILED ** Testing for SCSI sense data count. ** Testing if at least CCS_SENSE_LEN (18) is supported... Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 -- Wanted 18 sense bytes, got it. -- Libscg says 32 sense bytes but got (18) ** Testing for 32 bytes of sense data... Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Sense Data: 70 00 02 00 00 00 00 0A 00 00 00 00 3A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -- Wanted 32 sense bytes, got it.