mg - save backup files to homedir (diff v3)
If you use mg as the editor with mutt, any backup files mutt creates are kept in /tmp. However, with backup-to-home-directory enabled all backup files are moved to ~/.mg.d. Personally, I'd rather not move these backups but keep them in the /tmp dir. This modified diff allows backup files that are located in the /tmp directory to stay there, while allowing all other backups to go to the ~/.mg.d directory. Arguably, this could just be made the default behaviour (with backup-to-home-directory enabled), however I wrote the diff with an added an option so am sending the diff with it in. Also, since this option is not exactly the same as an emacs command I have chosen a non emacs command name: leave-tmpdir-backups Of course, by default nothing is changed in mg. Backups are still kept in the current directory. Comments/ok? -lum Index: def.h === RCS file: /cvs/src/usr.bin/mg/def.h,v retrieving revision 1.123 diff -u -p -r1.123 def.h --- def.h 7 Jun 2012 15:15:04 - 1.123 +++ def.h 13 Jun 2012 12:33:06 - @@ -446,6 +446,8 @@ struct list *make_file_list(char *); int fisdir(const char *); int fchecktime(struct buffer *); int fupdstat(struct buffer *); +int backuptohomedir(int, int); +int toggleleavetmp(int, int); /* kbd.c X */ int do_meta(int, int); Index: fileio.c === RCS file: /cvs/src/usr.bin/mg/fileio.c,v retrieving revision 1.90 diff -u -p -r1.90 fileio.c --- fileio.c11 Jun 2012 18:30:03 - 1.90 +++ fileio.c13 Jun 2012 12:33:06 - @@ -22,6 +22,12 @@ #include kbd.h +static char *bkuplocation(const char *); +static int bkupleavetmp(const char *); + +static char *bkupdir; +static int leavetmp = 0; /* 1 = leave any '~' files in tmp dir */ + /* * Open a file for reading. */ @@ -203,23 +209,28 @@ fbackupfile(const char *fn) int from, to, serrno; ssize_t nread; char buf[BUFSIZ]; - char*nname, *tname; + char*nname, *tname, *bkpth; if (stat(fn, sb) == -1) { ewprintf(Can't stat %s : %s, fn, strerror(errno)); return (FALSE); } - if (asprintf(nname, %s~, fn) == -1) { + if ((bkpth = bkuplocation(fn)) == NULL) + return (FALSE); + + if (asprintf(nname, %s~, bkpth) == -1) { ewprintf(Can't allocate backup file name : %s, strerror(errno)); + free(bkpth); return (ABORT); } - - if (asprintf(tname, %s.XX, fn) == -1) { + if (asprintf(tname, %s.XX, bkpth) == -1) { ewprintf(Can't allocate temp file name : %s, strerror(errno)); + free(bkpth); free(nname); return (ABORT); } + free(bkpth); if ((from = open(fn, O_RDONLY)) == -1) { free(nname); @@ -610,4 +621,113 @@ fchecktime(struct buffer *bp) return (TRUE); +} + +/* + * Location of backup file. This function creates the correct path. + */ +static char * +bkuplocation(const char *fn) +{ + struct stat sb; + char *ret; + + if (bkupdir != NULL (stat(bkupdir, sb) == 0) + S_ISDIR(sb.st_mode) !bkupleavetmp(fn)) { + char fname[NFILEN]; + const char *c; + int i = 0, len; + + c = fn; + len = strlen(bkupdir); + + while (*c != '\0') { + /* Make sure we don't go over combined: + * strlen(bkupdir + '/' + fname + '\0') + */ + if (i = NFILEN - len - 1) + return (NULL); + if (*c == '/') { + fname[i] = '!'; + } else if (*c == '!') { + if (i = NFILEN - len - 2) + return (NULL); + fname[i++] = '!'; + fname[i] = '!'; + } else + fname[i] = *c; + i++; + c++; + } + fname[i] = '\0'; + if (asprintf(ret, %s/%s, bkupdir, fname) == -1) + return (NULL); + + } else if ((ret = strndup(fn, NFILEN)) == NULL) + return (NULL); + + return (ret); +} + +int +backuptohomedir(int f, int n) +{ + const char *c = ~/.mg.d; + char*p; + + if (bkupdir == NULL) { + p = adjustname(c, TRUE); + bkupdir = strndup(p, NFILEN); + if (bkupdir == NULL) + return(FALSE); + + if
Paga $53 por Pen Drive Kingston 8gb SOLO POR HOY!!!
Si no podes visualizar este mail, ingresa a: http://news1.bonuscupon.com.ar/r.html?uid=1.16.295h.ks.l5hch6npln
Support for UCD-DISKIO-MIB in snmpd
I'd like to monitor disk IO on my workstation, but snmpd doesn't currently export hw.diskstats as far as I can tell. I found net-snmp supports UCD-DISKIO-MIB and it's not too complex, so I went ahead and coded up an implementation. It's been a while since I've touched SNMP and/or snmpd, but it seems to work correctly: $ snmpwalk -m UCD-DISKIO-MIB -v1 -c public 127.0.0.1 diskIOTable UCD-DISKIO-MIB::diskIOIndex.1 = INTEGER: 1 UCD-DISKIO-MIB::diskIOIndex.2 = INTEGER: 2 UCD-DISKIO-MIB::diskIOIndex.3 = INTEGER: 3 UCD-DISKIO-MIB::diskIODevice.1 = STRING: sd0 UCD-DISKIO-MIB::diskIODevice.2 = STRING: sd1 UCD-DISKIO-MIB::diskIODevice.3 = STRING: cd0 UCD-DISKIO-MIB::diskIONRead.1 = Counter32: 3584 UCD-DISKIO-MIB::diskIONRead.2 = Counter32: 3128056320 UCD-DISKIO-MIB::diskIONRead.3 = Counter32: 0 UCD-DISKIO-MIB::diskIONWritten.1 = Counter32: 0 UCD-DISKIO-MIB::diskIONWritten.2 = Counter32: 1418602496 UCD-DISKIO-MIB::diskIONWritten.3 = Counter32: 0 UCD-DISKIO-MIB::diskIOReads.1 = Counter32: 7 UCD-DISKIO-MIB::diskIOReads.2 = Counter32: 18550342 UCD-DISKIO-MIB::diskIOReads.3 = Counter32: 0 UCD-DISKIO-MIB::diskIOWrites.1 = Counter32: 0 UCD-DISKIO-MIB::diskIOWrites.2 = Counter32: 19485959 UCD-DISKIO-MIB::diskIOWrites.3 = Counter32: 0 UCD-DISKIO-MIB::diskIONReadX.1 = Counter64: 3584 UCD-DISKIO-MIB::diskIONReadX.2 = Counter64: 539998968320 UCD-DISKIO-MIB::diskIONReadX.3 = Counter64: 0 UCD-DISKIO-MIB::diskIONWrittenX.1 = Counter64: 0 UCD-DISKIO-MIB::diskIONWrittenX.2 = Counter64: 357900888064 UCD-DISKIO-MIB::diskIONWrittenX.3 = Counter64: 0 Test reports from regular SNMP users would be great. ok? Index: mib.h === RCS file: /home/mdempsky/anoncvs/cvs/src/usr.sbin/snmpd/mib.h,v retrieving revision 1.25 diff -u -p -r1.25 mib.h --- mib.h 20 Mar 2012 03:01:26 - 1.25 +++ mib.h 13 Jun 2012 19:19:23 - @@ -397,6 +397,22 @@ #define MIB_vantronix MIB_enterprises, 26766 #define MIB_openBSDMIB_enterprises, 30155 +/* UCD-DISKIO-MIB */ +#define MIB_ucdExperimentalMIB_ucDavis, 13 +#define MIB_ucdDiskIOMIB MIB_ucdExperimental, 15 +#define MIB_diskIOTableMIB_ucdDiskIOMIB, 1 +#define MIB_diskIOEntryMIB_diskIOTable, 1 +#define OIDIDX_diskIO 11 +#define OIDIDX_diskIOEntry 12 +#define MIB_diskIOIndexMIB_diskIOEntry, 1 +#define MIB_diskIODevice MIB_diskIOEntry, 2 +#define MIB_diskIONReadMIB_diskIOEntry, 3 +#define MIB_diskIONWritten MIB_diskIOEntry, 4 +#define MIB_diskIOReadsMIB_diskIOEntry, 5 +#define MIB_diskIOWrites MIB_diskIOEntry, 6 +#define MIB_diskIONReadX MIB_diskIOEntry, 12 +#define MIB_diskIONWrittenXMIB_diskIOEntry, 13 + /* OPENBSD-MIB */ #define MIB_pfMIBObjects MIB_openBSD, 1 #define MIB_pfInfo MIB_pfMIBObjects, 1 @@ -892,6 +908,19 @@ { MIBDECL(microSystems) }, \ { MIBDECL(vantronix) }, \ { MIBDECL(openBSD) }, \ + \ + { MIBDECL(ucdExperimental) }, \ + { MIBDECL(ucdDiskIOMIB) }, \ + { MIBDECL(diskIOTable) }, \ + { MIBDECL(diskIOEntry) }, \ + { MIBDECL(diskIOIndex) }, \ + { MIBDECL(diskIODevice) }, \ + { MIBDECL(diskIONRead) }, \ + { MIBDECL(diskIONWritten) },\ + { MIBDECL(diskIOReads) }, \ + { MIBDECL(diskIOWrites) }, \ + { MIBDECL(diskIONReadX) }, \ + { MIBDECL(diskIONWrittenX) }, \ \ { MIBDECL(pfMIBObjects) }, \ { MIBDECL(pfInfo) },\ Index: mib.c === RCS file: /home/mdempsky/anoncvs/cvs/src/usr.sbin/snmpd/mib.c,v retrieving revision 1.52 diff -u -p -r1.52 mib.c --- mib.c 20 Mar 2012 03:01:26 - 1.52 +++ mib.c 13 Jun 2012 19:19:09 - @@ -32,6 +32,7 @@ #include sys/socket.h #include sys/mount.h #include sys/ioctl.h +#include sys/disk.h #include net/if.h #include net/if_types.h @@ -3362,6 +3363,99 @@ mib_ipfroute(struct oid *oid, struct ber } /* + * Defined in UCD-DISKIO-MIB.txt. + */ + +intmib_diskio(struct oid *oid, struct ber_oid *o, struct ber_element **elm); + +static struct oid diskio_mib[] = { + { MIB(ucdDiskIOMIB),OID_MIB }, + { MIB(diskIOIndex), OID_TRD, mib_diskio }, + {
vmyield diff (2) please test
Hi, This diff implements yielding in the vm system, with the intention to make expensive system calls preempt every once in a while, to allow userland system calls to progress. It's a very conservative application at the moment, only interleaving during memory unmapping. If this works, we can start adding the mechanic to other expensive system calls not just in uvm, but anywhere the kernel is kept locked for long stretches of time. Technically the diff is incomplete, since it does not consider the very big problem of the biglock. And that's because the biglock lacks a __mp_lock_is_contended() call: if we hold the biglock and another cpu wants the biglock, ideally it will inform us so we can sidestep and temporarily grant access. Most of the changes in the diff are actually adding some flags to allow propagating if we should do the yielding. The uvm_ileave() function implements the actual yield and has a big text where I mention the biglock thing again. The diff has a name ofcourse: vmyield.2.diff Please test this on your machines. -- Ariane diff --git arch/i386/i386/pmap.c arch/i386/i386/pmap.c index f8f05cb..f0f1257 100644 --- arch/i386/i386/pmap.c +++ arch/i386/i386/pmap.c @@ -1269,10 +1269,10 @@ pmap_free_pvpage(void) /* unmap the page */ TAILQ_INIT(dead_entries); uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE, - dead_entries, FALSE, TRUE); + dead_entries, 0); vm_map_unlock(map); - uvm_unmap_detach(dead_entries, 0); + uvm_unmap_detach(dead_entries, 0, 0); pv_nfpvents -= PVE_PER_PVPAGE; /* update free count */ } diff --git arch/sparc/sparc/iommu.c arch/sparc/sparc/iommu.c index 4f7261b..dda9e35 100644 --- arch/sparc/sparc/iommu.c +++ arch/sparc/sparc/iommu.c @@ -753,7 +753,7 @@ iommu_dmamem_unmap(bus_dma_tag_t t, void *kva, size_t size) size = round_page(size); pmap_kremove((vaddr_t)kva, size); pmap_update(pmap_kernel()); - uvm_unmap(kernel_map, (vaddr_t)kva, (vaddr_t)kva + size); + uvm_unmap(kernel_map, (vaddr_t)kva, (vaddr_t)kva + size, 0); } diff --git dev/pci/drm/i915_drv.c dev/pci/drm/i915_drv.c index e73fa15..96a2ebb 100644 --- dev/pci/drm/i915_drv.c +++ dev/pci/drm/i915_drv.c @@ -4079,7 +4079,7 @@ i915_gem_cleanup_hws(struct inteldrm_softc *dev_priv) obj = dev_priv-hws_obj; uvm_unmap(kernel_map, (vaddr_t)dev_priv-hw_status_page, - (vaddr_t)dev_priv-hw_status_page + PAGE_SIZE); + (vaddr_t)dev_priv-hw_status_page + PAGE_SIZE, 0); dev_priv-hw_status_page = NULL; drm_hold_object(obj); i915_gem_object_unpin(obj); diff --git kern/kern_exec.c kern/kern_exec.c index e7a2b3a..6682511 100644 --- kern/kern_exec.c +++ kern/kern_exec.c @@ -825,7 +825,7 @@ exec_sigcode_map(struct proc *p, struct emul *e) return (ENOMEM); } memcpy((void *)va, e-e_sigcode, sz); - uvm_unmap(kernel_map, va, va + round_page(sz)); + uvm_unmap(kernel_map, va, va + round_page(sz), 0); } p-p_sigcode = 0; /* no hint */ diff --git kern/kern_malloc_debug.c kern/kern_malloc_debug.c index 68ee1e0..2b80838 100644 --- kern/kern_malloc_debug.c +++ kern/kern_malloc_debug.c @@ -259,7 +259,7 @@ debug_malloc_allocate_free(int wait) break; if (wait == 0) { - uvm_unmap(kmem_map, va, va + PAGE_SIZE * 2); + uvm_unmap(kmem_map, va, va + PAGE_SIZE * 2, 0); pool_put(debug_malloc_pool, md); return; } diff --git kern/kern_sysctl.c kern/kern_sysctl.c index 5e51607..4f69bad 100644 --- kern/kern_sysctl.c +++ kern/kern_sysctl.c @@ -1758,7 +1758,7 @@ more: error = copyout(rarg, rargv, sizeof(rarg)); out: - uvmspace_free(vm); + uvmspace_free(vm, 0); free(buf, M_TEMP); return (error); } diff --git kern/sys_process.c kern/sys_process.c index b36da4f..be75012 100644 --- kern/sys_process.c +++ kern/sys_process.c @@ -728,7 +728,7 @@ process_domem(struct proc *curp, struct proc *p, struct uio *uio, int req) error = uvm_io(vm-vm_map, uio, (req == PT_WRITE_I) ? UVM_IO_FIXPROT : 0); - uvmspace_free(vm); + uvmspace_free(vm, 0); if (error == 0 req == PT_WRITE_I) pmap_proc_iflush(p, addr, len); diff --git miscfs/procfs/procfs_cmdline.c miscfs/procfs/procfs_cmdline.c index b80aff9..9956bdf 100644 --- miscfs/procfs/procfs_cmdline.c +++ miscfs/procfs/procfs_cmdline.c @@ -180,7 +180,7 @@ procfs_docmdline(struct proc *curp, struct proc *p, struct pfsnode *pfs, struct bad: - uvmspace_free(vm); + uvmspace_free(vm, 0); free(arg, M_TEMP); return (error); } diff --git uvm/uvm.h uvm/uvm.h index c236fb4..8e9ff81 100644