Improve st(4) to make Bacula happier, 'modern' tapes faster

2013-05-12 Thread Kenneth R Westerback
The diff below brings a bunch of improvements, mostly from Net/FreeBSD,
to the scsi tape driver st(4). In particular, running btape now
reports (for me) no errors no matter which combination of

Hardware End of Medium =
Fast Forward Space File = 

settings are used. I'm told this should significantly improve the
speed of modern drives like LTO-3 for Bacula by allowing 'yes' for
both.

Tests sought to confirm/refute this, and of course spot any regressions
in other tape uses! Fixes/further improvements and comments always
welcome.

 Ken

Index: scsi_all.h
===
RCS file: /cvs/src/sys/scsi/scsi_all.h,v
retrieving revision 1.53
diff -u -p -u -p -r1.53 scsi_all.h
--- scsi_all.h  8 Jul 2011 08:13:19 -   1.53
+++ scsi_all.h  11 May 2013 10:53:00 -
@@ -378,6 +378,11 @@ struct scsi_sense_data {
 /* Additional sense code info */
 #define ASC_ASCQ(ssd)  ((ssd-add_sense_code  8) | ssd-add_sense_code_qual)
 
+#define SENSE_FILEMARK_DETECTED0x0001
+#define SENSE_END_OF_MEDIUM_DETECTED   0x0002
+#define SENSE_SETMARK_DETECTED 0x0003
+#define SENSE_BEGINNING_OF_MEDIUM_DETECTED 0x0004
+#define SENSE_END_OF_DATA_DETECTED 0x0005
 #define SENSE_NOT_READY_BECOMING_READY 0x0401
 #define SENSE_NOT_READY_INIT_REQUIRED  0x0402
 #define SENSE_NOT_READY_FORMAT 0x0404
Index: st.c
===
RCS file: /cvs/src/sys/scsi/st.c,v
retrieving revision 1.121
diff -u -p -u -p -r1.121 st.c
--- st.c3 Jul 2011 15:47:18 -   1.121
+++ st.c12 May 2013 02:24:16 -
@@ -208,6 +208,7 @@ struct st_softc {
u_int32_t media_density;/* this is what it said when asked*/
int media_fileno;   /* relative to BOT. -1 means unknown. */
int media_blkno;/* relative to BOF. -1 means unknown. */
+   int media_eom;  /* relative to BOT. -1 means unknown. */
 
u_int drive_quirks; /* quirks of this drive   */
 
@@ -265,19 +266,23 @@ struct cfdriver st_cd = {
 #defineST_FIXEDBLOCKS  0x0008
 #defineST_AT_FILEMARK  0x0010
 #defineST_EIO_PENDING  0x0020  /* we couldn't report it then (had 
data) */
+#defineST_EOM_PENDING  0x0040  /* we couldn't report it then (had 
data) */
+#define ST_EOD_DETECTED0x0080
 #defineST_FM_WRITTEN   0x0100  /*
 * EOF file mark written  -- used with
 * ~ST_WRITTEN to indicate that multiple file
 * marks have been written
 */
-#defineST_DYING0x40/* dying, when deactivated */
 #defineST_BLANK_READ   0x0200  /* BLANK CHECK encountered already */
 #defineST_2FM_AT_EOD   0x0400  /* write 2 file marks at EOD */
 #defineST_MOUNTED  0x0800  /* Device is presently mounted */
 #defineST_DONTBUFFER   0x1000  /* Disable buffering/caching */
 #define ST_WAITING 0x2000
+#defineST_DYING0x4000  /* dying, when deactivated */
+#define ST_BOD_DETECTED0x8000
 
-#defineST_PER_ACTION   (ST_AT_FILEMARK | ST_EIO_PENDING | 
ST_BLANK_READ)
+#defineST_PER_ACTION   (ST_AT_FILEMARK | ST_EIO_PENDING | 
ST_EOM_PENDING | \
+ST_BLANK_READ)
 
 #define stlookup(unit) (struct st_softc *)device_lookup(st_cd, (unit))
 
@@ -335,6 +340,7 @@ stattach(struct device *parent, struct d
/* Start up with media position unknown. */
st-media_fileno = -1;
st-media_blkno = -1;
+   st-media_eom = -1;
 
/*
 * Reset the media loaded flag, sometimes the data
@@ -660,6 +666,9 @@ st_mount_tape(dev_t dev, int flags)
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY);
st-flags |= ST_MOUNTED;
sc_link-flags |= SDEV_MEDIA_LOADED;/* move earlier? */
+   st-media_fileno = 0;
+   st-media_blkno = 0;
+   st-media_eom = -1;
 
 done:
device_unref(st-sc_dev);
@@ -927,7 +936,8 @@ ststart(struct scsi_xfer *xs)
}
 
/*
-* only FIXEDBLOCK devices have pending operations
+* Only FIXEDBLOCK devices have pending I/O or space
+* operations.
 */
if (st-flags  ST_FIXEDBLOCKS) {
/*
@@ -962,26 +972,27 @@ ststart(struct scsi_xfer *xs)
continue;   /* seek more work */
}
}
-   /*
-* If we are at EIO (e.g. EOM) but have not reported it
-* yet then we should report it now
-*/
+   }
+
+   /*
+* If we are at EIO or EOM but 

Re: off by one in vi(1)

2013-05-12 Thread Arto Jonsson
On Sat, May 11, 2013 at 05:33:20PM -0600, Todd C. Miller wrote:
 Good catch, I know folks who have hit this bug but I was never able
 to reproduce it.  Moving the isblank() check should be safe since
 trailing blanks are trimmed earlier on so we won't exit the loop
 prematurely.  I see you didn't change the TXT_ALTWERASE case, though.
 It looks like that also needs a fix but the break there will break
 out of the switch statement, not a loop.  However, since trailing
 blanks have already been trimmed I think that check is effectively
 a no-op and could simply be removed.

Thanks for the review. Here's an updated diff. If anyone's curious this
bug is about one month short of being 20 years old.

Index: vi/v_txt.c
===
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.22
diff -u -p -r1.22 v_txt.c
--- vi/v_txt.c  27 Oct 2009 23:59:48 -  1.22
+++ vi/v_txt.c  12 May 2013 17:24:25 -
@@ -1120,12 +1120,12 @@ leftmargin: tp-lb[tp-cno - 1] = ' ';
 */
if (LF_ISSET(TXT_TTYWERASE))
while (tp-cno  max) {
+   if (isblank(tp-lb[tp-cno - 1]))
+   break;
--tp-cno;
++tp-owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp-lb[tp-cno] = ' ';
-   if (isblank(tp-lb[tp-cno - 1]))
-   break;
}
else {
if (LF_ISSET(TXT_ALTWERASE)) {
@@ -1133,19 +1133,17 @@ leftmargin: tp-lb[tp-cno - 1] = ' ';
++tp-owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp-lb[tp-cno] = ' ';
-   if (isblank(tp-lb[tp-cno - 1]))
-   break;
}
if (tp-cno  max)
tmp = inword(tp-lb[tp-cno - 1]);
while (tp-cno  max) {
+   if (tmp != inword(tp-lb[tp-cno - 1])
+   || isblank(tp-lb[tp-cno - 1]))
+   break;
--tp-cno;
++tp-owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp-lb[tp-cno] = ' ';
-   if (tmp != inword(tp-lb[tp-cno - 1])
-   || isblank(tp-lb[tp-cno - 1]))
-   break;
}
}
 



[NEW] ugold(4) driver for Microdia's USB TEMPer variant (take 2)

2013-05-12 Thread SASANO Takayoshi
Hello,

Here is the driver for Microdia's USB TEMPer with some fixes.

http://www.uaa.org.uk/gomitext/2013/20130513/20130513.diff

- removed intermediate buffer (sc_ibuf), all USB interrupt responses
  will be processed in ugold_intr().
- use uhidev_set_report() to issue HID command.
- add ugold* at uhidev? into GENERIC for alpha, amd64, armish, hppa, i386,
  landisk, loongson, macppc, sgi (IP27, IP30, IP32), socppc and sparc64.

Regards,

SASANO Takayoshi u...@mx5.nisiq.net



Re: LC_CTYPE for spanish speaking countries

2013-05-12 Thread Vladimir Támara Patiño


After private conversation with Stefan I'm sending patch that uses links
in /usr/share/locale for LC_CTYPE instead of copying (by the way there was a 
commentary in /usr/src/share/locale/ctype/Makefile suggesting using

symlinks!).
Besides this patch adds locales for spanish speaking countries.

This method reduces the size of /usr/shar/locale from 2.1M to 556K (even 
with new locales for all spanish speaking countries).


The same can be done with LC_COLLATE (after having collation support). 


Best regards.
--
Dios, gracias por tu amor infinito.
--  
 Vladimir Támara Patiño.  http://vtamara.pasosdeJesus.org/

 http://www.pasosdejesus.org/dominio_publico_colombia.html

? m
? obj
Index: Makefile
===
RCS file: /cvs/src/share/locale/ctype/Makefile,v
retrieving revision 1.6
diff -r1.6 Makefile
83,90c83,91
 LOCALES += es_ES.ISO8859-1
  LOCALESRC_es_ES.ISO8859-1 = en_US.ISO_8859-1
 
 LOCALES += es_ES.ISO8859-15
  LOCALESRC_es_ES.ISO8859-15 = en_US.DIS_8859-15
 
 LOCALES += es_ES.UTF-8
  LOCALESRC_es_ES.UTF-8 = en_US.UTF-8
---
 LOCALES_ES = es_AR es_BO es_CH es_CO es_CR es_CU es_DO es_EC es_ES es_GQ 
 es_GT es_HN es_MX es_NI es_PA es_PE es_PR es_PY es_SV es_US es_UY es_VE
 .for c in ${LOCALES_ES}
 LOCALES += ${c}.ISO8859-1
  LOCALESRC_${c}.ISO8859-1 = en_US.ISO_8859-1
 LOCALES += ${c}.ISO8859-15
  LOCALESRC_${c}.ISO8859-15 = en_US.DIS_8859-15
 LOCALES += ${c}.UTF-8
  LOCALESRC_${c}.UTF-8 = en_US.UTF-8
 .endfor
296d296
 # TODO: more use of symlinks?
307,308c307,313
   install -o ${LOCALEOWN} -g ${LOCALEGRP} -m ${LOCALEMODE} \
   ${locale}.out ${DESTDIR}${LOCALEDIR}/${locale}/LC_CTYPE
---
   if (test ${LOCALESRC_${locale}:S/ISO_/ISO/g:S/DIS_/ISO/g} != 
 ${locale}) then { \
   ln -fs 
 ../${LOCALESRC_${locale}:S/ISO_/ISO/g:S/DIS_/ISO/g}/LC_CTYPE 
 ${DESTDIR}${LOCALEDIR}/${locale}/LC_CTYPE; \
   } else { \
   install -o ${LOCALEOWN} -g ${LOCALEGRP} -m ${LOCALEMODE} \
   ${locale}.out ${DESTDIR}${LOCALEDIR}/${locale}/LC_CTYPE; \
   } fi;
 
313,314c318,321
   ${CPP} -I${.CURDIR}  ${.CURDIR}/${LOCALESRC_${locale}}.src | \
   sed -e '/^#/d' | mklocale -o ${.TARGET}
---
   if (test ${LOCALESRC_${locale}:S/ISO_/ISO/g:S/DIS_/ISO/g} = 
 ${locale}) then { \
   ${CPP} -I${.CURDIR}  
 ${.CURDIR}/${LOCALESRC_${locale}:S/ISO_/ISO/g:S/DIS_/ISO/g}.src | \
   sed -e '/^#/d' | mklocale -o ${.TARGET}; \
   } fi;