Date: Thu, 25 Oct 2012 21:17:39 +0200 From: Marcin Mazur <willyvmm@gmail.com> To: freebsd-emulation@freebsd.org Subject: TCSBRK implementation for linux compat Message-ID: <CALK1EdxGdR92hqiVP3wFZJdmzL8iS06Gz2iZtoJcUJVNxNU5GA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--14dae93411b3c3349204cce70fdb Content-Type: text/plain; charset=ISO-8859-1 Hi. I needed suport for this feature in FreeBSD linux emulation, because I have to use precompiled linux library/binary that uses it. There was a lot of errors in logs like: "... ioctl fd=52, cmd=0x5409 ('T',9) is not implemented" I could not find any help so I had to do that by myself I found implementation in NetBSD sources, and just 'translated' it to the FreeBSD There is my work: ------------------------- --- linux_ioctl.orig 2012-08-06 01:54:33.000000000 +0200 +++ linux_ioctl.c 2012-10-25 13:59:12.000000000 +0200 @@ -778,8 +778,26 @@ td)); break; - /* LINUX_TCSBRK */ - + case LINUX_TCSBRK: + if (args->arg) + { + args->cmd = TIOCDRAIN; + error = (sys_ioctl(td, (struct ioctl_args *)args)); + break; + } + else + { + if ((error = fo_ioctl(fp, TIOCSBRK, NULL, td->td_ucred,td)) != 0) + break; + error = tsleep(&args->arg, PZERO | PCATCH, "linux_tcsbrk", hz / 4); + if (error == EINTR || error == ERESTART) { + fo_ioctl(fp, TIOCCBRK, NULL, td->td_ucred, td); + error = EINTR; + } else + error = fo_ioctl (fp, TIOCCBRK, NULL, td->td_ucred, td); + break; + } + case LINUX_TCXONC: { switch (args->arg) { case LINUX_TCOOFF: -------------------- Could someone have a look at this if the code is correct? Sorry but I do not have kernel developing experience and this is my first patch I'm testing this patch for over 20 hours now and it seems to work well. No errors, load average dropped from 2.5 to 0.5 Please CC me, I'am not on the list. And sorry for my bad english... --14dae93411b3c3349204cce70fdb Content-Type: application/octet-stream; name="TCSBRK.patch" Content-Disposition: attachment; filename="TCSBRK.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h8q95mg10 LS0tIGxpbnV4X2lvY3RsLm9yaWcgICAgMjAxMi0wOC0wNiAwMTo1NDozMy4wMDAwMDAwMDAgKzAy MDANCisrKyBsaW51eF9pb2N0bC5jICAgICAgIDIwMTItMTAtMjUgMTM6NTk6MTIuMDAwMDAwMDAw ICswMjAwDQpAQCAtNzc4LDggKzc3OCwyNiBAQA0KICAgICAgICAgICAgICAgICAgICB0ZCkpOw0K ICAgICAgICAgICAgICAgIGJyZWFrOw0KDQotICAgICAgIC8qIExJTlVYX1RDU0JSSyAqLw0KLQ0K KyAgICAgICBjYXNlIExJTlVYX1RDU0JSSzoNCisgICAgICAgICAgICAgICBpZiAoYXJncy0+YXJn KQ0KKyAgICAgICAgICAgICAgICAgICB7DQorICAgICAgICAgICAgICAgICAgICAgICBhcmdzLT5j bWQgPSBUSU9DRFJBSU47DQorICAgICAgICAgICAgICAgICAgICAgICBlcnJvciA9IChzeXNfaW9j dGwodGQsIChzdHJ1Y3QgaW9jdGxfYXJncyAqKWFyZ3MpKTsNCisgICAgICAgICAgICAgICAgICAg ICAgIGJyZWFrOw0KKyAgICAgICAgICAgICAgICAgICB9DQorICAgICAgICAgICAgICAgZWxzZQ0K KyAgICAgICAgICAgICAgICAgICB7DQorICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGVycm9y ID0gZm9faW9jdGwoZnAsIFRJT0NTQlJLLCBOVUxMLCB0ZC0+dGRfdWNyZWQsIHRkKSkgIT0gMCkN CisgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCisgICAgICAgICAgICAgICAgICAg ICAgIGVycm9yID0gdHNsZWVwKCZhcmdzLT5hcmcsIFBaRVJPIHwgUENBVENILCAibGludXhfdGNz YnJrIiwgaHogLyA0KTsNCisgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciA9PSBFSU5U UiB8fCBlcnJvciA9PSBFUkVTVEFSVCkgew0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgIGZv X2lvY3RsKGZwLCBUSU9DQ0JSSywgTlVMTCwgdGQtPnRkX3VjcmVkLCB0ZCk7DQorICAgICAgICAg ICAgICAgICAgICAgICAgICAgZXJyb3IgPSBFSU5UUjsNCisgICAgICAgICAgICAgICAgICAgICAg IH0gZWxzZQ0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gZm9faW9jdGwgKGZw LCBUSU9DQ0JSSywgTlVMTCwgdGQtPnRkX3VjcmVkLCB0ZCk7DQorICAgICAgICAgICAgICAgICAg ICAgICBicmVhazsNCisgICAgICAgICAgICAgICAgICAgfQ0KKw0KICAgICAgICBjYXNlIExJTlVY X1RDWE9OQzogew0KICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJncy0+YXJnKSB7DQogICAgICAg ICAgICAgICAgY2FzZSBMSU5VWF9UQ09PRkY6DQo= --14dae93411b3c3349204cce70fdb--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALK1EdxGdR92hqiVP3wFZJdmzL8iS06Gz2iZtoJcUJVNxNU5GA>